verbesserte Prüfung der Partner.ID Eingabe , Speziallösung Frau Mwanig für sonder Gutschriften Export an Cargosoft
This commit is contained in:
parent
6c1fa2c094
commit
15e37ff2c8
9 changed files with 1393 additions and 192 deletions
|
|
@ -129,9 +129,10 @@ public class BusinessPartnerService {
|
|||
*
|
||||
* @param partnerID
|
||||
* @param workitem
|
||||
* @return BusinessPartner Object
|
||||
* @throws PluginException
|
||||
*/
|
||||
public void updateBusinessPartnerData(ItemCollection workitem) throws PluginException {
|
||||
public ItemCollection updateBusinessPartnerData(ItemCollection workitem) throws PluginException {
|
||||
String partnerID = workitem.getItemValueString("partner.id");
|
||||
// Migration wenn keine partner.id existier!
|
||||
if (partnerID.isEmpty()) {
|
||||
|
|
@ -145,12 +146,35 @@ public class BusinessPartnerService {
|
|||
}
|
||||
|
||||
if (partnerID == null || partnerID.isEmpty()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// load Business Partner
|
||||
//
|
||||
// DO NOT CHANGE THIS LOGIC!
|
||||
//
|
||||
ItemCollection businessPartner = getBusinessPartnerByID(partnerID);
|
||||
if (businessPartner == null) {
|
||||
return;
|
||||
// Falls jemand eine ungültige Partner ID eingetippt hat und einfach auf weiter
|
||||
// klickt , müssen wir genau prüfen
|
||||
// Wir prüfen ob es eine Zahl war - dann versuchen wir nochmal mit dem Prefix BP
|
||||
// zu suchen....
|
||||
// Beispiel: 13342
|
||||
try {
|
||||
Integer.parseInt(partnerID);
|
||||
// it is an int - get last 4 digits
|
||||
partnerID = "BP" + partnerID.substring(Math.max(0, partnerID.length() - 4));
|
||||
workitem.setItemValue("partner.id", partnerID);
|
||||
businessPartner = getBusinessPartnerByID(partnerID);
|
||||
} catch (NumberFormatException e) {
|
||||
/* not an int */
|
||||
}
|
||||
if (businessPartner == null) {
|
||||
workitem.removeItem("partner.id");
|
||||
logger.warning("Business Partner for Partner ID " + partnerID + " not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
// because the method can be called multiple times within one worklfow
|
||||
// processing cycle
|
||||
|
|
@ -158,14 +182,16 @@ public class BusinessPartnerService {
|
|||
businessPartner = documentService.load(businessPartner.getUniqueID());
|
||||
if (businessPartner != null) {
|
||||
workitem.setItemValue("partner.name", businessPartner.getItemValueString("partner.name"));
|
||||
|
||||
logger.info("check invoice type....");
|
||||
// Update Invoice Partner Meta Data
|
||||
if (InvoiceUtil.isDebitorInvoice(workitem)) {
|
||||
logger.info("...is debitor invoice");
|
||||
workitem.setItemValue("dbtr.number", businessPartner.getItemValueString("dbtr.number"));
|
||||
workitem.setItemValue("dbtr.name", businessPartner.getItemValueString("partner.name"));
|
||||
workitem.setItemValue("dbtr.mail", businessPartner.getItemValueString("dbtr.mail"));
|
||||
workitem.setItemValue("invoice.country", businessPartner.getItemValueString("_vendor_country"));
|
||||
}
|
||||
logger.info("...is creditor invoice");
|
||||
if (InvoiceUtil.isCreditorInvoice(workitem)) {
|
||||
workitem.setItemValue("cdtr.number", businessPartner.getItemValueString("cdtr.number"));
|
||||
workitem.setItemValue("cdtr.name", businessPartner.getItemValueString("partner.name"));
|
||||
|
|
@ -195,8 +221,10 @@ public class BusinessPartnerService {
|
|||
} catch (PluginException | ProcessingErrorException | AccessDeniedException | ModelException e) {
|
||||
logger.warning("Failed to update BusinessPartner object '" + partnerID + "'!");
|
||||
}
|
||||
return businessPartner;
|
||||
} else {
|
||||
logger.warning("BusinessPartner '" + partnerID + "' not found!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import jakarta.inject.Inject;
|
|||
* notwendig, da Cargosoft selbst nicht mit unterschiedlichen Buchungsperioden
|
||||
* in einer Rechnung umgehen kann.
|
||||
* <p>
|
||||
* adapter exports the invoice data to a ftp server connected to cargosoft. Da
|
||||
* Die Daten werden als XML Datei auf einem FTP Laufwerk abgelegt. Da
|
||||
* auch eine fortlaufene Rechnungsnummer von Cargosoft zwingend vorgeschrieben
|
||||
* ist, erzeugt der adapter auch für jedes weiteres cargosoft export worktiem
|
||||
* ein neue Sequencenummer die im Hautpworkitem gespeichert wird.
|
||||
|
|
@ -48,9 +48,13 @@ import jakarta.inject.Inject;
|
|||
* Because we also export the attachment data to cargosoft, the adapter lookups
|
||||
* the conente of the attachment in the snapshot of the origin workitem
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Der Adapter validiert zusätzlich ob die Kreditorennnummer cdtr.number gültig
|
||||
* ist.
|
||||
* <p>
|
||||
* Es kann auch vorkommen das speziell Gutschriften auf ein alternatives
|
||||
* Cargosoft Konto gebucht werden müssen. Dies prüfen wir und ändern ggf. das
|
||||
* Konto ab (Anforderung Frau Mahner 18.9.2025)
|
||||
*
|
||||
* @version 1.0
|
||||
* @author rsoika
|
||||
|
|
@ -89,6 +93,20 @@ public class CargosoftSplitAdapter implements SignalAdapter {
|
|||
throw new PluginException(CargosoftSplitAdapter.class.getSimpleName(), CONFIG_ERROR,
|
||||
"Missing or wrong Creditor Number, please check your data.");
|
||||
}
|
||||
/**
|
||||
* Sonderfall:
|
||||
* Es kann sein, das Frau Mahner oder Frau Mwangi für diesen Kreditor
|
||||
* Gutschriften (NUR Gutschriften!!) auf ein alternatives Konto buchen will.
|
||||
* In diesem Fall ändern wir JETZT das feld cdtr.number!!!!
|
||||
*/
|
||||
if ("credit".equals(workitem.getItemValueString("payment.type"))) {
|
||||
// Haben wir ein alternative Konto im Business Partner hinterlegt?
|
||||
String alternativKonto = partner.getItemValueString("cargosot.credit.cdtr.number");
|
||||
if (!alternativKonto.isBlank()) {
|
||||
cdtrNumber = alternativKonto;
|
||||
workitem.setItemValue("cdtr.number", alternativKonto);
|
||||
}
|
||||
}
|
||||
|
||||
// read the cargosoft split options
|
||||
ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "cargosoft", workitem, false);
|
||||
|
|
@ -107,10 +125,10 @@ public class CargosoftSplitAdapter implements SignalAdapter {
|
|||
"missing cargosoft configuration 'model', 'task', 'event' - please check model configuration");
|
||||
}
|
||||
|
||||
// Zunaechst müssen wir festelstellen, ob es mehrere unterschiedliche
|
||||
// Zunaechst müssen wir feststellen, ob es mehrere unterschiedliche
|
||||
// Buchungsperioden in der Positionstabelle gibt.
|
||||
List<String> buchungsPersioden = new ArrayList<String>();
|
||||
// add haupt buchungsperiode
|
||||
// add Haupt-Buchungsperiode
|
||||
buchungsPersioden.add(workitem.getItemValueString("invoice.period"));
|
||||
List<ItemCollection> positionsTabelle = InvoiceUtil.explodeChildList(workitem);
|
||||
for (ItemCollection posItem : positionsTabelle) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class InvoicePlugin extends AbstractPlugin {
|
|||
public ItemCollection run(ItemCollection workitem, ItemCollection event) throws PluginException {
|
||||
|
||||
// Update BUsiness Partner Data
|
||||
businessPartnerService.updateBusinessPartnerData(workitem);
|
||||
ItemCollection businessPartner = businessPartnerService.updateBusinessPartnerData(workitem);
|
||||
|
||||
updateImg(workitem);
|
||||
|
||||
|
|
@ -102,6 +102,13 @@ public class InvoicePlugin extends AbstractPlugin {
|
|||
boolean isPublicEvent = !("0".equals(event.getItemValueString("keypublicresult")));
|
||||
|
||||
if (isPublicEvent) {
|
||||
|
||||
// validate Partner id....
|
||||
if (businessPartner == null) {
|
||||
String message = resourceBundleHandler.findMessage("ERROR_MISSING_BUSINESSPARTNER");
|
||||
throw new PluginException(InvoicePlugin.class.getName(), ERROR_MISSING_DATA, message);
|
||||
}
|
||||
|
||||
validateInvoiceNumber(workitem);
|
||||
validateBuchungsperiode(workitem.getItemValueString(InvoiceUtil.ITEM_INVOICE_PERIOD));
|
||||
checkIBANNumber(workitem);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,15 @@
|
|||
|
||||
package com.alexanderlogistics.api;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.imixs.marty.team.TeamService;
|
||||
|
|
@ -51,7 +58,6 @@ import jakarta.ejb.TransactionAttribute;
|
|||
import jakarta.ejb.TransactionAttributeType;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
|
@ -122,9 +128,9 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
* @throws PluginException
|
||||
* @throws ModelException
|
||||
*/
|
||||
@GET
|
||||
@Path("/bp-sync")
|
||||
@Produces({ MediaType.TEXT_PLAIN })
|
||||
// @GET
|
||||
// @Path("/bp-sync")
|
||||
// @Produces({ MediaType.TEXT_PLAIN })
|
||||
public String syncBusinessPartner(@QueryParam("maxcount") int maxcount)
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||
StringBuffer messageBuffer = new StringBuffer();
|
||||
|
|
@ -199,100 +205,100 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
// @GET
|
||||
// @Path("/cargosoft-renew_cdtr_number")
|
||||
// @Produces({ MediaType.TEXT_PLAIN })
|
||||
// public String migrationAdresswandlungOpenInvoices(@QueryParam("maxcount") int
|
||||
// maxcount,
|
||||
// @QueryParam("type") String type)
|
||||
// throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||
// PluginException, ModelException {
|
||||
// StringBuffer messageBuffer = new StringBuffer();
|
||||
// if (maxcount <= 0) {
|
||||
// maxcount = 10;
|
||||
// }
|
||||
// if (type == null || type.isEmpty()) {
|
||||
// type = "workitem";
|
||||
// }
|
||||
public String migrationAdresswandlungOpenInvoices(@QueryParam("maxcount") int maxcount,
|
||||
@QueryParam("type") String type)
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||
PluginException, ModelException {
|
||||
StringBuffer messageBuffer = new StringBuffer();
|
||||
if (maxcount <= 0) {
|
||||
maxcount = 10;
|
||||
}
|
||||
if (type == null || type.isEmpty()) {
|
||||
type = "workitem";
|
||||
}
|
||||
|
||||
// if (isRunning) {
|
||||
// log("├── sync process already running!", messageBuffer);
|
||||
// return messageBuffer.toString();
|
||||
// }
|
||||
// isRunning = true;
|
||||
if (isRunning) {
|
||||
log("├── sync process already running!", messageBuffer);
|
||||
return messageBuffer.toString();
|
||||
}
|
||||
isRunning = true;
|
||||
|
||||
// log("├── read cargosoft migration file....", messageBuffer);
|
||||
// Map<String, String> mapping = readAdressMapping();
|
||||
// log("├── found " + mapping.size() + " mappings", messageBuffer);
|
||||
log("├── read cargosoft migration file....", messageBuffer);
|
||||
Map<String, String> mapping = readAdressMapping();
|
||||
log("├── found " + mapping.size() + " mappings", messageBuffer);
|
||||
|
||||
// String query = "(type:" + type + ") AND ($modelversion:rechnungseingang*)";
|
||||
// // int syncs = 0;
|
||||
// long l = System.currentTimeMillis();
|
||||
// int batchSize = 100;
|
||||
// int totalUpdates = 0;
|
||||
String query = "(type:" + type + ") AND ($modelversion:rechnungseingang*)";
|
||||
// int syncs = 0;
|
||||
long l = System.currentTimeMillis();
|
||||
int batchSize = 100;
|
||||
int totalUpdates = 0;
|
||||
|
||||
// log("├── migration cargosoft addresses....", messageBuffer);
|
||||
// log("│ ├── query=" + query, messageBuffer);
|
||||
log("├── migration cargosoft addresses....", messageBuffer);
|
||||
log("│ ├── query=" + query, messageBuffer);
|
||||
|
||||
// int totalCount = documentService.count(query);
|
||||
// log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
||||
int totalCount = documentService.count(query);
|
||||
log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
||||
|
||||
// // Berechne Anzahl der benötigten Pages
|
||||
// int totalPages = (int) Math.ceil((double) totalCount / batchSize);
|
||||
// Berechne Anzahl der benötigten Pages
|
||||
int totalPages = (int) Math.ceil((double) totalCount / batchSize);
|
||||
|
||||
// // Verarbeite Page für Page
|
||||
// for (int pageIndex = 0; pageIndex < totalPages; pageIndex++) {
|
||||
// log("│ ├── read page " + pageIndex, messageBuffer);
|
||||
// List<ItemCollection> invoiceList = documentService.find(query, batchSize,
|
||||
// pageIndex);
|
||||
// long l1 = System.currentTimeMillis();
|
||||
// log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
||||
// messageBuffer);
|
||||
// int updates = migratateInvioceBPAddress(invoiceList, mapping);
|
||||
// totalUpdates = totalUpdates + updates;
|
||||
// log("│ ├── " + updates + " invoices migrated in " +
|
||||
// (System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
||||
// // break;
|
||||
// if (totalUpdates >= maxcount) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// long duration = System.currentTimeMillis() - l;
|
||||
// double objectsPerSecond = totalUpdates / (duration / 1000.0);
|
||||
// log("├── Successfully " + totalUpdates + " invoices migrated in " + duration
|
||||
// + "ms ("
|
||||
// + String.format("%.1f", objectsPerSecond) + " objects/sec)", messageBuffer);
|
||||
// Verarbeite Page für Page
|
||||
for (int pageIndex = 0; pageIndex < totalPages; pageIndex++) {
|
||||
log("│ ├── read page " + pageIndex, messageBuffer);
|
||||
List<ItemCollection> invoiceList = documentService.find(query, batchSize,
|
||||
pageIndex);
|
||||
long l1 = System.currentTimeMillis();
|
||||
log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
||||
messageBuffer);
|
||||
int updates = migratateInvioceBPAddress(invoiceList, mapping);
|
||||
totalUpdates = totalUpdates + updates;
|
||||
log("│ ├── " + updates + " invoices migrated in " +
|
||||
(System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
||||
// break;
|
||||
if (totalUpdates >= maxcount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
long duration = System.currentTimeMillis() - l;
|
||||
double objectsPerSecond = totalUpdates / (duration / 1000.0);
|
||||
log("├── Successfully " + totalUpdates + " invoices migrated in " + duration
|
||||
+ "ms ("
|
||||
+ String.format("%.1f", objectsPerSecond) + " objects/sec)", messageBuffer);
|
||||
|
||||
// isRunning = false;
|
||||
// return messageBuffer.toString();
|
||||
// }
|
||||
isRunning = false;
|
||||
return messageBuffer.toString();
|
||||
}
|
||||
|
||||
// @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
|
||||
// private int migratateInvioceBPAddress(List<ItemCollection> invoices,
|
||||
// Map<String, String> map) {
|
||||
// int count = 0;
|
||||
// for (ItemCollection invoice : invoices) {
|
||||
// String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
||||
// if (cdtrNumber.isBlank()) {
|
||||
// logger.warning(" ..Invoice " + invoice.getUniqueID() + " has no
|
||||
// cdtr.number!");
|
||||
// continue;
|
||||
// }
|
||||
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
|
||||
private int migratateInvioceBPAddress(List<ItemCollection> invoices,
|
||||
Map<String, String> map) {
|
||||
int count = 0;
|
||||
for (ItemCollection invoice : invoices) {
|
||||
String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
||||
if (cdtrNumber.isBlank()) {
|
||||
logger.warning(" ..Invoice " + invoice.getUniqueID() + " has no cdtr.number!");
|
||||
continue;
|
||||
}
|
||||
|
||||
// // logger.info("==> check cdtr.number: " + cdtrNumber);
|
||||
// // K überspringen
|
||||
// String newNumber = map.get(cdtrNumber.substring(1));
|
||||
// if (newNumber != null) {
|
||||
// // migrate number
|
||||
// invoice.setItemValue("cdtr.number.old", cdtrNumber);
|
||||
// invoice.setItemValue("cdtr.number", "K" + newNumber);
|
||||
// logger.info("==> check cdtr.number: " + cdtrNumber);
|
||||
// K überspringen
|
||||
String newNumber = map.get(cdtrNumber.substring(1));
|
||||
if (newNumber != null) {
|
||||
// migrate number
|
||||
invoice.setItemValue("cdtr.number.old", cdtrNumber);
|
||||
invoice.setItemValue("cdtr.number", "K" + newNumber);
|
||||
|
||||
// logger.info("│ ├── replace " + cdtrNumber + " -> K" + newNumber + " : " +
|
||||
// invoice.getUniqueID());
|
||||
// documentService.save(invoice);
|
||||
// count++;
|
||||
logger.info("│ ├── replace " + cdtrNumber + " -> K" + newNumber + " : " +
|
||||
invoice.getUniqueID());
|
||||
documentService.save(invoice);
|
||||
|
||||
// }
|
||||
// }
|
||||
// return count;
|
||||
// }
|
||||
// logger.info("-- kein update! disabled save!!");
|
||||
count++;
|
||||
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migriert die Rechnungen mit den neuen cdtr. Nummern
|
||||
|
|
@ -302,114 +308,111 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
// @GET
|
||||
// @Path("/fix-separun")
|
||||
// @Produces({ MediaType.TEXT_PLAIN })
|
||||
// public String fixSepaRun(@QueryParam("maxcount") int maxcount)
|
||||
// throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||
// PluginException, ModelException {
|
||||
// StringBuffer messageBuffer = new StringBuffer();
|
||||
// int totalUpdates = 0;
|
||||
// if (maxcount <= 0) {
|
||||
// maxcount = 10;
|
||||
public String fixSepaRun(@QueryParam("maxcount") int maxcount)
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||
PluginException, ModelException {
|
||||
StringBuffer messageBuffer = new StringBuffer();
|
||||
int totalUpdates = 0;
|
||||
if (maxcount <= 0) {
|
||||
maxcount = 10;
|
||||
|
||||
// if (isRunning) {
|
||||
// log("├── sync process already running!", messageBuffer);
|
||||
// return messageBuffer.toString();
|
||||
// }
|
||||
// isRunning = true;
|
||||
if (isRunning) {
|
||||
log("├── sync process already running!", messageBuffer);
|
||||
return messageBuffer.toString();
|
||||
}
|
||||
isRunning = true;
|
||||
|
||||
// String query = "(type:workitem) AND ($modelversion:rechnungseingang*) AND
|
||||
// ($taskid:5500)";
|
||||
// // int syncs = 0;
|
||||
// long l = System.currentTimeMillis();
|
||||
String query = "(type:workitem) AND ($modelversion:rechnungseingang*) AND ($taskid:5500)";
|
||||
// int syncs = 0;
|
||||
long l = System.currentTimeMillis();
|
||||
|
||||
// log("├── migration sepa run....", messageBuffer);
|
||||
// log("│ ├── query=" + query, messageBuffer);
|
||||
// int totalCount = documentService.count(query);
|
||||
// log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
||||
// List<ItemCollection> invoiceList = documentService.find(query, 999, 0);
|
||||
// long l1 = System.currentTimeMillis();
|
||||
// log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
||||
// messageBuffer);
|
||||
log("├── migration sepa run....", messageBuffer);
|
||||
log("│ ├── query=" + query, messageBuffer);
|
||||
int totalCount = documentService.count(query);
|
||||
log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
||||
List<ItemCollection> invoiceList = documentService.find(query, 999, 0);
|
||||
long l1 = System.currentTimeMillis();
|
||||
log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
||||
messageBuffer);
|
||||
|
||||
// for (ItemCollection invoice : invoiceList) {
|
||||
for (ItemCollection invoice : invoiceList) {
|
||||
|
||||
// String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
||||
// String cdtrNumberOld = invoice.getItemValueString("cdtr.number.old");
|
||||
// String bpPartnerID = invoice.getItemValueString("partner.id");
|
||||
// if (bpPartnerID.isEmpty()) {
|
||||
// continue;
|
||||
// }
|
||||
// if (cdtrNumberOld.isEmpty()) {
|
||||
// continue;
|
||||
// }
|
||||
String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
||||
String cdtrNumberOld = invoice.getItemValueString("cdtr.number.old");
|
||||
String bpPartnerID = invoice.getItemValueString("partner.id");
|
||||
if (bpPartnerID.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (cdtrNumberOld.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// // lookup bp ....
|
||||
// ItemCollection bpPartner =
|
||||
// businessPartnerService.getBusinessPartnerByID(InvoiceUtil.getBPID(invoice));
|
||||
// String fixPartnerName = bpPartner.getItemValueString("partner.name");
|
||||
// String fixPartnerId = bpPartner.getItemValueString("partner.id");
|
||||
// lookup bp ....
|
||||
ItemCollection bpPartner = businessPartnerService.getBusinessPartnerByID(InvoiceUtil.getBPID(invoice));
|
||||
String fixPartnerName = bpPartner.getItemValueString("partner.name");
|
||||
String fixPartnerId = bpPartner.getItemValueString("partner.id");
|
||||
|
||||
// if (!bpPartnerID.equals(fixPartnerId)) {
|
||||
// logger.info("Problem found with invoice: " + invoice.getUniqueID() + " wrong
|
||||
// partnerID="
|
||||
// + bpPartnerID + " correct= " + fixPartnerId);
|
||||
// logger.info(" correct name= " + fixPartnerName);
|
||||
if (!bpPartnerID.equals(fixPartnerId)) {
|
||||
logger.info("Problem found with invoice: " + invoice.getUniqueID() + " wrong partnerID="
|
||||
+ bpPartnerID + " correct= " + fixPartnerId);
|
||||
logger.info(" correct name= " + fixPartnerName);
|
||||
|
||||
// invoice.setItemValue("partner.id", fixPartnerId);
|
||||
// invoice.setItemValue("cdtr.name", fixPartnerName);
|
||||
// invoice.setItemValue("partner.name", fixPartnerName);
|
||||
// documentService.save(invoice);
|
||||
// // workflowService.processWorkItem(invoice.event(10));
|
||||
// totalUpdates++;
|
||||
// }
|
||||
// }
|
||||
invoice.setItemValue("partner.id", fixPartnerId);
|
||||
invoice.setItemValue("cdtr.name", fixPartnerName);
|
||||
invoice.setItemValue("partner.name", fixPartnerName);
|
||||
documentService.save(invoice);
|
||||
// workflowService.processWorkItem(invoice.event(10));
|
||||
totalUpdates++;
|
||||
}
|
||||
}
|
||||
|
||||
// log("│ ├── " + totalUpdates + " invoices migrated in " +
|
||||
// (System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
||||
log("│ ├── " + totalUpdates + " invoices migrated in " +
|
||||
(System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// log("├── Successfully " + totalUpdates + " invoices migrated",
|
||||
// messageBuffer);
|
||||
log("├── Successfully " + totalUpdates + " invoices migrated",
|
||||
messageBuffer);
|
||||
|
||||
// isRunning = false;
|
||||
// return messageBuffer.toString();
|
||||
// }
|
||||
isRunning = false;
|
||||
return messageBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese hilfsmethode liest die Cargosoft Datei mit den Mapping - alt->neu ein
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// private Map<String, String> readAdressMapping() {
|
||||
// Map<String, String> result = new HashMap<>();
|
||||
// try (InputStream inputStream = getClass().getClassLoader()
|
||||
// .getResourceAsStream("agl_wandlung_20250822.csv");
|
||||
// BufferedReader reader = new BufferedReader(
|
||||
// new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
||||
private Map<String, String> readAdressMapping() {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
try (InputStream inputStream = getClass().getClassLoader()
|
||||
.getResourceAsStream("agl_wandlung_20250822.csv");
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
||||
|
||||
// String line;
|
||||
// boolean firstLine = true;
|
||||
String line;
|
||||
boolean firstLine = true;
|
||||
|
||||
// while ((line = reader.readLine()) != null) {
|
||||
// if (firstLine) {
|
||||
// firstLine = false;
|
||||
// continue; // Header überspringen
|
||||
// }
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (firstLine) {
|
||||
firstLine = false;
|
||||
continue; // Header überspringen
|
||||
}
|
||||
|
||||
// String[] parts = line.split(";");
|
||||
// if (parts.length == 2) {
|
||||
// String oldID = parts[0].trim();
|
||||
// String newID = parts[1].trim();
|
||||
// result.put(oldID, newID);
|
||||
String[] parts = line.split(";");
|
||||
if (parts.length == 2) {
|
||||
String oldID = parts[0].trim();
|
||||
String newID = parts[1].trim();
|
||||
result.put(oldID, newID);
|
||||
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// // Logging framework verwenden
|
||||
// System.err.println("Fehler beim Laden der CSV: " + e.getMessage());
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Logging framework verwenden
|
||||
System.err.println("Fehler beim Laden der CSV: " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hilfsmethode speichert eine cargoosft kreditor object...
|
||||
|
|
@ -444,9 +447,9 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
* @throws PluginException
|
||||
* @throws ModelException
|
||||
*/
|
||||
@GET
|
||||
@Path("/bp-delete")
|
||||
@Produces({ MediaType.TEXT_PLAIN })
|
||||
// @GET
|
||||
// @Path("/bp-delete")
|
||||
// @Produces({ MediaType.TEXT_PLAIN })
|
||||
public String deleteBusinessPartner(@QueryParam("maxcount") int maxcount)
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||
StringBuffer messageBuffer = new StringBuffer();
|
||||
|
|
@ -526,9 +529,9 @@ public class CargosoftMigrationRestService implements Serializable {
|
|||
* @throws PluginException
|
||||
* @throws ModelException
|
||||
*/
|
||||
@GET
|
||||
@Path("/remove-dubletten")
|
||||
@Produces({ MediaType.TEXT_PLAIN })
|
||||
// @GET
|
||||
// @Path("/remove-dubletten")
|
||||
// @Produces({ MediaType.TEXT_PLAIN })
|
||||
public String deleteCargosoftDupplicates(@QueryParam("maxcount") int maxcount)
|
||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||
StringBuffer messageBuffer = new StringBuffer();
|
||||
|
|
|
|||
|
|
@ -144,12 +144,12 @@ public class BusinessPartnerImportService {
|
|||
String cargosoftID = importDoc.getItemValueString("name");
|
||||
String partnerID = InvoiceUtil.buildBPID(cargosoftID);
|
||||
ItemCollection businesspartner = lookupBusinessPartner(partnerID);
|
||||
if (businesspartner != null) {
|
||||
if (businesspartner != null && businesspartner.getTaskID() != 1800) {
|
||||
logger.info("lock business partner object....");
|
||||
try {
|
||||
businesspartner.setEventID(80);
|
||||
workflowService.processWorkItemByNewTransaction(businesspartner);
|
||||
} catch (AccessDeniedException | ProcessingErrorException | PluginException | ModelException e) {
|
||||
} catch (Exception e) {
|
||||
logger.warning(
|
||||
"Failed to lock Business Partner Object " + cargosoftID + " - " + e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,3 +75,5 @@ ERROR_PAYMENT1="Der Zahlungseingang kann nicht verbucht werden, da die Währung
|
|||
ERROR_PAYMENT2="Der Zahlungseingang ist nicht identisch mit den ausgebuchten Rechnungssalden. Sollte die Eingabe korrekt sein, wiederholen Sie die Aktion."
|
||||
ERROR_PAYMENT3="Der Zahlungseingang kann nicht verbucht werden, da der Restsaldo der Rechnung {1} kleiner als der Zahlbetrag ist!"
|
||||
ERROR_PAYMENT4="Wenigstens eine ausgewählte Währung muss der Hauptwährung {1} entsprechen!"
|
||||
|
||||
ERROR_MISSING_BUSINESSPARTNER="Bitte wählen Sie einen Business Partner aus!"
|
||||
|
|
@ -76,3 +76,5 @@ ERROR_PAYMENT1="The payment cannot be posted because the currency {1} does not m
|
|||
ERROR_PAYMENT2="The incoming payment does not match the posted invoice balances. If the input is correct, please repeat the action."
|
||||
ERROR_PAYMENT3="The payment cannot be posted because the remaining balance of invoice {1} is less than the payment amount!"
|
||||
ERROR_PAYMENT4="At least one selected currency must match the main currency {1}!"
|
||||
|
||||
ERROR_MISSING_BUSINESSPARTNER="Please select a Business Partner!"
|
||||
1141
workflow/businesspartner-de-1.0.3.bpmn
Normal file
1141
workflow/businesspartner-de-1.0.3.bpmn
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -4101,7 +4101,7 @@ result.isValid=true;
|
|||
<imixs-form>
|
||||
<imixs-form-section columns="2" label="Invoice data">
|
||||
<item name="cdtr.name" type="text" readonly="true" label="Vendor:"/>
|
||||
<item name="partner.id" type="custom" options="rerender" path="alexander/businesspartner_search" requred="true" label="Vendor number1:" options="rerender"/>
|
||||
<item name="partner.id" type="custom" options="rerender" path="alexander/businesspartner_search" requred="true" label="Vendor number:" />
|
||||
</imixs-form-section>
|
||||
<imixs-form-section columns="3">
|
||||
<item name="invoice.number" type="text" label="Invoice number:" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue