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 partnerID
|
||||||
* @param workitem
|
* @param workitem
|
||||||
|
* @return BusinessPartner Object
|
||||||
* @throws PluginException
|
* @throws PluginException
|
||||||
*/
|
*/
|
||||||
public void updateBusinessPartnerData(ItemCollection workitem) throws PluginException {
|
public ItemCollection updateBusinessPartnerData(ItemCollection workitem) throws PluginException {
|
||||||
String partnerID = workitem.getItemValueString("partner.id");
|
String partnerID = workitem.getItemValueString("partner.id");
|
||||||
// Migration wenn keine partner.id existier!
|
// Migration wenn keine partner.id existier!
|
||||||
if (partnerID.isEmpty()) {
|
if (partnerID.isEmpty()) {
|
||||||
|
|
@ -145,12 +146,35 @@ public class BusinessPartnerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partnerID == null || partnerID.isEmpty()) {
|
if (partnerID == null || partnerID.isEmpty()) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load Business Partner
|
// load Business Partner
|
||||||
|
//
|
||||||
|
// DO NOT CHANGE THIS LOGIC!
|
||||||
|
//
|
||||||
ItemCollection businessPartner = getBusinessPartnerByID(partnerID);
|
ItemCollection businessPartner = getBusinessPartnerByID(partnerID);
|
||||||
if (businessPartner == null) {
|
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
|
// because the method can be called multiple times within one worklfow
|
||||||
// processing cycle
|
// processing cycle
|
||||||
|
|
@ -158,14 +182,16 @@ public class BusinessPartnerService {
|
||||||
businessPartner = documentService.load(businessPartner.getUniqueID());
|
businessPartner = documentService.load(businessPartner.getUniqueID());
|
||||||
if (businessPartner != null) {
|
if (businessPartner != null) {
|
||||||
workitem.setItemValue("partner.name", businessPartner.getItemValueString("partner.name"));
|
workitem.setItemValue("partner.name", businessPartner.getItemValueString("partner.name"));
|
||||||
|
logger.info("check invoice type....");
|
||||||
// Update Invoice Partner Meta Data
|
// Update Invoice Partner Meta Data
|
||||||
if (InvoiceUtil.isDebitorInvoice(workitem)) {
|
if (InvoiceUtil.isDebitorInvoice(workitem)) {
|
||||||
|
logger.info("...is debitor invoice");
|
||||||
workitem.setItemValue("dbtr.number", businessPartner.getItemValueString("dbtr.number"));
|
workitem.setItemValue("dbtr.number", businessPartner.getItemValueString("dbtr.number"));
|
||||||
workitem.setItemValue("dbtr.name", businessPartner.getItemValueString("partner.name"));
|
workitem.setItemValue("dbtr.name", businessPartner.getItemValueString("partner.name"));
|
||||||
workitem.setItemValue("dbtr.mail", businessPartner.getItemValueString("dbtr.mail"));
|
workitem.setItemValue("dbtr.mail", businessPartner.getItemValueString("dbtr.mail"));
|
||||||
workitem.setItemValue("invoice.country", businessPartner.getItemValueString("_vendor_country"));
|
workitem.setItemValue("invoice.country", businessPartner.getItemValueString("_vendor_country"));
|
||||||
}
|
}
|
||||||
|
logger.info("...is creditor invoice");
|
||||||
if (InvoiceUtil.isCreditorInvoice(workitem)) {
|
if (InvoiceUtil.isCreditorInvoice(workitem)) {
|
||||||
workitem.setItemValue("cdtr.number", businessPartner.getItemValueString("cdtr.number"));
|
workitem.setItemValue("cdtr.number", businessPartner.getItemValueString("cdtr.number"));
|
||||||
workitem.setItemValue("cdtr.name", businessPartner.getItemValueString("partner.name"));
|
workitem.setItemValue("cdtr.name", businessPartner.getItemValueString("partner.name"));
|
||||||
|
|
@ -195,8 +221,10 @@ public class BusinessPartnerService {
|
||||||
} catch (PluginException | ProcessingErrorException | AccessDeniedException | ModelException e) {
|
} catch (PluginException | ProcessingErrorException | AccessDeniedException | ModelException e) {
|
||||||
logger.warning("Failed to update BusinessPartner object '" + partnerID + "'!");
|
logger.warning("Failed to update BusinessPartner object '" + partnerID + "'!");
|
||||||
}
|
}
|
||||||
|
return businessPartner;
|
||||||
} else {
|
} else {
|
||||||
logger.warning("BusinessPartner '" + partnerID + "' not found!");
|
logger.warning("BusinessPartner '" + partnerID + "' not found!");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import jakarta.inject.Inject;
|
||||||
* notwendig, da Cargosoft selbst nicht mit unterschiedlichen Buchungsperioden
|
* notwendig, da Cargosoft selbst nicht mit unterschiedlichen Buchungsperioden
|
||||||
* in einer Rechnung umgehen kann.
|
* in einer Rechnung umgehen kann.
|
||||||
* <p>
|
* <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
|
* auch eine fortlaufene Rechnungsnummer von Cargosoft zwingend vorgeschrieben
|
||||||
* ist, erzeugt der adapter auch für jedes weiteres cargosoft export worktiem
|
* ist, erzeugt der adapter auch für jedes weiteres cargosoft export worktiem
|
||||||
* ein neue Sequencenummer die im Hautpworkitem gespeichert wird.
|
* 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
|
* Because we also export the attachment data to cargosoft, the adapter lookups
|
||||||
* the conente of the attachment in the snapshot of the origin workitem
|
* 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
|
* Der Adapter validiert zusätzlich ob die Kreditorennnummer cdtr.number gültig
|
||||||
* ist.
|
* 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
|
* @version 1.0
|
||||||
* @author rsoika
|
* @author rsoika
|
||||||
|
|
@ -89,6 +93,20 @@ public class CargosoftSplitAdapter implements SignalAdapter {
|
||||||
throw new PluginException(CargosoftSplitAdapter.class.getSimpleName(), CONFIG_ERROR,
|
throw new PluginException(CargosoftSplitAdapter.class.getSimpleName(), CONFIG_ERROR,
|
||||||
"Missing or wrong Creditor Number, please check your data.");
|
"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
|
// read the cargosoft split options
|
||||||
ItemCollection evalItemCollection = workflowService.evalWorkflowResult(event, "cargosoft", workitem, false);
|
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");
|
"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.
|
// Buchungsperioden in der Positionstabelle gibt.
|
||||||
List<String> buchungsPersioden = new ArrayList<String>();
|
List<String> buchungsPersioden = new ArrayList<String>();
|
||||||
// add haupt buchungsperiode
|
// add Haupt-Buchungsperiode
|
||||||
buchungsPersioden.add(workitem.getItemValueString("invoice.period"));
|
buchungsPersioden.add(workitem.getItemValueString("invoice.period"));
|
||||||
List<ItemCollection> positionsTabelle = InvoiceUtil.explodeChildList(workitem);
|
List<ItemCollection> positionsTabelle = InvoiceUtil.explodeChildList(workitem);
|
||||||
for (ItemCollection posItem : positionsTabelle) {
|
for (ItemCollection posItem : positionsTabelle) {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class InvoicePlugin extends AbstractPlugin {
|
||||||
public ItemCollection run(ItemCollection workitem, ItemCollection event) throws PluginException {
|
public ItemCollection run(ItemCollection workitem, ItemCollection event) throws PluginException {
|
||||||
|
|
||||||
// Update BUsiness Partner Data
|
// Update BUsiness Partner Data
|
||||||
businessPartnerService.updateBusinessPartnerData(workitem);
|
ItemCollection businessPartner = businessPartnerService.updateBusinessPartnerData(workitem);
|
||||||
|
|
||||||
updateImg(workitem);
|
updateImg(workitem);
|
||||||
|
|
||||||
|
|
@ -102,6 +102,13 @@ public class InvoicePlugin extends AbstractPlugin {
|
||||||
boolean isPublicEvent = !("0".equals(event.getItemValueString("keypublicresult")));
|
boolean isPublicEvent = !("0".equals(event.getItemValueString("keypublicresult")));
|
||||||
|
|
||||||
if (isPublicEvent) {
|
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);
|
validateInvoiceNumber(workitem);
|
||||||
validateBuchungsperiode(workitem.getItemValueString(InvoiceUtil.ITEM_INVOICE_PERIOD));
|
validateBuchungsperiode(workitem.getItemValueString(InvoiceUtil.ITEM_INVOICE_PERIOD));
|
||||||
checkIBANNumber(workitem);
|
checkIBANNumber(workitem);
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,15 @@
|
||||||
|
|
||||||
package com.alexanderlogistics.api;
|
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.io.Serializable;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.imixs.marty.team.TeamService;
|
import org.imixs.marty.team.TeamService;
|
||||||
|
|
@ -51,7 +58,6 @@ import jakarta.ejb.TransactionAttribute;
|
||||||
import jakarta.ejb.TransactionAttributeType;
|
import jakarta.ejb.TransactionAttributeType;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.ws.rs.GET;
|
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.QueryParam;
|
import jakarta.ws.rs.QueryParam;
|
||||||
|
|
@ -122,9 +128,9 @@ public class CargosoftMigrationRestService implements Serializable {
|
||||||
* @throws PluginException
|
* @throws PluginException
|
||||||
* @throws ModelException
|
* @throws ModelException
|
||||||
*/
|
*/
|
||||||
@GET
|
// @GET
|
||||||
@Path("/bp-sync")
|
// @Path("/bp-sync")
|
||||||
@Produces({ MediaType.TEXT_PLAIN })
|
// @Produces({ MediaType.TEXT_PLAIN })
|
||||||
public String syncBusinessPartner(@QueryParam("maxcount") int maxcount)
|
public String syncBusinessPartner(@QueryParam("maxcount") int maxcount)
|
||||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||||
StringBuffer messageBuffer = new StringBuffer();
|
StringBuffer messageBuffer = new StringBuffer();
|
||||||
|
|
@ -199,100 +205,100 @@ public class CargosoftMigrationRestService implements Serializable {
|
||||||
// @GET
|
// @GET
|
||||||
// @Path("/cargosoft-renew_cdtr_number")
|
// @Path("/cargosoft-renew_cdtr_number")
|
||||||
// @Produces({ MediaType.TEXT_PLAIN })
|
// @Produces({ MediaType.TEXT_PLAIN })
|
||||||
// public String migrationAdresswandlungOpenInvoices(@QueryParam("maxcount") int
|
public String migrationAdresswandlungOpenInvoices(@QueryParam("maxcount") int maxcount,
|
||||||
// maxcount,
|
@QueryParam("type") String type)
|
||||||
// @QueryParam("type") String type)
|
throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||||
// throws QueryException, AccessDeniedException, ProcessingErrorException,
|
PluginException, ModelException {
|
||||||
// PluginException, ModelException {
|
StringBuffer messageBuffer = new StringBuffer();
|
||||||
// StringBuffer messageBuffer = new StringBuffer();
|
if (maxcount <= 0) {
|
||||||
// if (maxcount <= 0) {
|
maxcount = 10;
|
||||||
// maxcount = 10;
|
}
|
||||||
// }
|
if (type == null || type.isEmpty()) {
|
||||||
// if (type == null || type.isEmpty()) {
|
type = "workitem";
|
||||||
// type = "workitem";
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// if (isRunning) {
|
if (isRunning) {
|
||||||
// log("├── sync process already running!", messageBuffer);
|
log("├── sync process already running!", messageBuffer);
|
||||||
// return messageBuffer.toString();
|
return messageBuffer.toString();
|
||||||
// }
|
}
|
||||||
// isRunning = true;
|
isRunning = true;
|
||||||
|
|
||||||
// log("├── read cargosoft migration file....", messageBuffer);
|
log("├── read cargosoft migration file....", messageBuffer);
|
||||||
// Map<String, String> mapping = readAdressMapping();
|
Map<String, String> mapping = readAdressMapping();
|
||||||
// log("├── found " + mapping.size() + " mappings", messageBuffer);
|
log("├── found " + mapping.size() + " mappings", messageBuffer);
|
||||||
|
|
||||||
// String query = "(type:" + type + ") AND ($modelversion:rechnungseingang*)";
|
String query = "(type:" + type + ") AND ($modelversion:rechnungseingang*)";
|
||||||
// // int syncs = 0;
|
// int syncs = 0;
|
||||||
// long l = System.currentTimeMillis();
|
long l = System.currentTimeMillis();
|
||||||
// int batchSize = 100;
|
int batchSize = 100;
|
||||||
// int totalUpdates = 0;
|
int totalUpdates = 0;
|
||||||
|
|
||||||
// log("├── migration cargosoft addresses....", messageBuffer);
|
log("├── migration cargosoft addresses....", messageBuffer);
|
||||||
// log("│ ├── query=" + query, messageBuffer);
|
log("│ ├── query=" + query, messageBuffer);
|
||||||
|
|
||||||
// int totalCount = documentService.count(query);
|
int totalCount = documentService.count(query);
|
||||||
// log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
||||||
|
|
||||||
// // Berechne Anzahl der benötigten Pages
|
// Berechne Anzahl der benötigten Pages
|
||||||
// int totalPages = (int) Math.ceil((double) totalCount / batchSize);
|
int totalPages = (int) Math.ceil((double) totalCount / batchSize);
|
||||||
|
|
||||||
// // Verarbeite Page für Page
|
// Verarbeite Page für Page
|
||||||
// for (int pageIndex = 0; pageIndex < totalPages; pageIndex++) {
|
for (int pageIndex = 0; pageIndex < totalPages; pageIndex++) {
|
||||||
// log("│ ├── read page " + pageIndex, messageBuffer);
|
log("│ ├── read page " + pageIndex, messageBuffer);
|
||||||
// List<ItemCollection> invoiceList = documentService.find(query, batchSize,
|
List<ItemCollection> invoiceList = documentService.find(query, batchSize,
|
||||||
// pageIndex);
|
pageIndex);
|
||||||
// long l1 = System.currentTimeMillis();
|
long l1 = System.currentTimeMillis();
|
||||||
// log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
||||||
// messageBuffer);
|
messageBuffer);
|
||||||
// int updates = migratateInvioceBPAddress(invoiceList, mapping);
|
int updates = migratateInvioceBPAddress(invoiceList, mapping);
|
||||||
// totalUpdates = totalUpdates + updates;
|
totalUpdates = totalUpdates + updates;
|
||||||
// log("│ ├── " + updates + " invoices migrated in " +
|
log("│ ├── " + updates + " invoices migrated in " +
|
||||||
// (System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
(System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
||||||
// // break;
|
// break;
|
||||||
// if (totalUpdates >= maxcount) {
|
if (totalUpdates >= maxcount) {
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// long duration = System.currentTimeMillis() - l;
|
long duration = System.currentTimeMillis() - l;
|
||||||
// double objectsPerSecond = totalUpdates / (duration / 1000.0);
|
double objectsPerSecond = totalUpdates / (duration / 1000.0);
|
||||||
// log("├── Successfully " + totalUpdates + " invoices migrated in " + duration
|
log("├── Successfully " + totalUpdates + " invoices migrated in " + duration
|
||||||
// + "ms ("
|
+ "ms ("
|
||||||
// + String.format("%.1f", objectsPerSecond) + " objects/sec)", messageBuffer);
|
+ String.format("%.1f", objectsPerSecond) + " objects/sec)", messageBuffer);
|
||||||
|
|
||||||
// isRunning = false;
|
isRunning = false;
|
||||||
// return messageBuffer.toString();
|
return messageBuffer.toString();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
|
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
|
||||||
// private int migratateInvioceBPAddress(List<ItemCollection> invoices,
|
private int migratateInvioceBPAddress(List<ItemCollection> invoices,
|
||||||
// Map<String, String> map) {
|
Map<String, String> map) {
|
||||||
// int count = 0;
|
int count = 0;
|
||||||
// for (ItemCollection invoice : invoices) {
|
for (ItemCollection invoice : invoices) {
|
||||||
// String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
||||||
// if (cdtrNumber.isBlank()) {
|
if (cdtrNumber.isBlank()) {
|
||||||
// logger.warning(" ..Invoice " + invoice.getUniqueID() + " has no
|
logger.warning(" ..Invoice " + invoice.getUniqueID() + " has no cdtr.number!");
|
||||||
// cdtr.number!");
|
continue;
|
||||||
// continue;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// // logger.info("==> check cdtr.number: " + cdtrNumber);
|
// logger.info("==> check cdtr.number: " + cdtrNumber);
|
||||||
// // K überspringen
|
// K überspringen
|
||||||
// String newNumber = map.get(cdtrNumber.substring(1));
|
String newNumber = map.get(cdtrNumber.substring(1));
|
||||||
// if (newNumber != null) {
|
if (newNumber != null) {
|
||||||
// // migrate number
|
// migrate number
|
||||||
// invoice.setItemValue("cdtr.number.old", cdtrNumber);
|
invoice.setItemValue("cdtr.number.old", cdtrNumber);
|
||||||
// invoice.setItemValue("cdtr.number", "K" + newNumber);
|
invoice.setItemValue("cdtr.number", "K" + newNumber);
|
||||||
|
|
||||||
// logger.info("│ ├── replace " + cdtrNumber + " -> K" + newNumber + " : " +
|
logger.info("│ ├── replace " + cdtrNumber + " -> K" + newNumber + " : " +
|
||||||
// invoice.getUniqueID());
|
invoice.getUniqueID());
|
||||||
// documentService.save(invoice);
|
documentService.save(invoice);
|
||||||
// count++;
|
|
||||||
|
|
||||||
// }
|
// logger.info("-- kein update! disabled save!!");
|
||||||
// }
|
count++;
|
||||||
// return count;
|
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migriert die Rechnungen mit den neuen cdtr. Nummern
|
* Migriert die Rechnungen mit den neuen cdtr. Nummern
|
||||||
|
|
@ -302,114 +308,111 @@ public class CargosoftMigrationRestService implements Serializable {
|
||||||
// @GET
|
// @GET
|
||||||
// @Path("/fix-separun")
|
// @Path("/fix-separun")
|
||||||
// @Produces({ MediaType.TEXT_PLAIN })
|
// @Produces({ MediaType.TEXT_PLAIN })
|
||||||
// public String fixSepaRun(@QueryParam("maxcount") int maxcount)
|
public String fixSepaRun(@QueryParam("maxcount") int maxcount)
|
||||||
// throws QueryException, AccessDeniedException, ProcessingErrorException,
|
throws QueryException, AccessDeniedException, ProcessingErrorException,
|
||||||
// PluginException, ModelException {
|
PluginException, ModelException {
|
||||||
// StringBuffer messageBuffer = new StringBuffer();
|
StringBuffer messageBuffer = new StringBuffer();
|
||||||
// int totalUpdates = 0;
|
int totalUpdates = 0;
|
||||||
// if (maxcount <= 0) {
|
if (maxcount <= 0) {
|
||||||
// maxcount = 10;
|
maxcount = 10;
|
||||||
|
|
||||||
// if (isRunning) {
|
if (isRunning) {
|
||||||
// log("├── sync process already running!", messageBuffer);
|
log("├── sync process already running!", messageBuffer);
|
||||||
// return messageBuffer.toString();
|
return messageBuffer.toString();
|
||||||
// }
|
}
|
||||||
// isRunning = true;
|
isRunning = true;
|
||||||
|
|
||||||
// String query = "(type:workitem) AND ($modelversion:rechnungseingang*) AND
|
String query = "(type:workitem) AND ($modelversion:rechnungseingang*) AND ($taskid:5500)";
|
||||||
// ($taskid:5500)";
|
// int syncs = 0;
|
||||||
// // int syncs = 0;
|
long l = System.currentTimeMillis();
|
||||||
// long l = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// log("├── migration sepa run....", messageBuffer);
|
log("├── migration sepa run....", messageBuffer);
|
||||||
// log("│ ├── query=" + query, messageBuffer);
|
log("│ ├── query=" + query, messageBuffer);
|
||||||
// int totalCount = documentService.count(query);
|
int totalCount = documentService.count(query);
|
||||||
// log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
log("│ ├── found " + totalCount + " invoices", messageBuffer);
|
||||||
// List<ItemCollection> invoiceList = documentService.find(query, 999, 0);
|
List<ItemCollection> invoiceList = documentService.find(query, 999, 0);
|
||||||
// long l1 = System.currentTimeMillis();
|
long l1 = System.currentTimeMillis();
|
||||||
// log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
log("│ ├── ...verifying " + invoiceList.size() + " invoices...",
|
||||||
// messageBuffer);
|
messageBuffer);
|
||||||
|
|
||||||
// for (ItemCollection invoice : invoiceList) {
|
for (ItemCollection invoice : invoiceList) {
|
||||||
|
|
||||||
// String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
String cdtrNumber = invoice.getItemValueString("cdtr.number");
|
||||||
// String cdtrNumberOld = invoice.getItemValueString("cdtr.number.old");
|
String cdtrNumberOld = invoice.getItemValueString("cdtr.number.old");
|
||||||
// String bpPartnerID = invoice.getItemValueString("partner.id");
|
String bpPartnerID = invoice.getItemValueString("partner.id");
|
||||||
// if (bpPartnerID.isEmpty()) {
|
if (bpPartnerID.isEmpty()) {
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// if (cdtrNumberOld.isEmpty()) {
|
if (cdtrNumberOld.isEmpty()) {
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // lookup bp ....
|
// lookup bp ....
|
||||||
// ItemCollection bpPartner =
|
ItemCollection bpPartner = businessPartnerService.getBusinessPartnerByID(InvoiceUtil.getBPID(invoice));
|
||||||
// businessPartnerService.getBusinessPartnerByID(InvoiceUtil.getBPID(invoice));
|
String fixPartnerName = bpPartner.getItemValueString("partner.name");
|
||||||
// String fixPartnerName = bpPartner.getItemValueString("partner.name");
|
String fixPartnerId = bpPartner.getItemValueString("partner.id");
|
||||||
// String fixPartnerId = bpPartner.getItemValueString("partner.id");
|
|
||||||
|
|
||||||
// if (!bpPartnerID.equals(fixPartnerId)) {
|
if (!bpPartnerID.equals(fixPartnerId)) {
|
||||||
// logger.info("Problem found with invoice: " + invoice.getUniqueID() + " wrong
|
logger.info("Problem found with invoice: " + invoice.getUniqueID() + " wrong partnerID="
|
||||||
// partnerID="
|
+ bpPartnerID + " correct= " + fixPartnerId);
|
||||||
// + bpPartnerID + " correct= " + fixPartnerId);
|
logger.info(" correct name= " + fixPartnerName);
|
||||||
// logger.info(" correct name= " + fixPartnerName);
|
|
||||||
|
|
||||||
// invoice.setItemValue("partner.id", fixPartnerId);
|
invoice.setItemValue("partner.id", fixPartnerId);
|
||||||
// invoice.setItemValue("cdtr.name", fixPartnerName);
|
invoice.setItemValue("cdtr.name", fixPartnerName);
|
||||||
// invoice.setItemValue("partner.name", fixPartnerName);
|
invoice.setItemValue("partner.name", fixPartnerName);
|
||||||
// documentService.save(invoice);
|
documentService.save(invoice);
|
||||||
// // workflowService.processWorkItem(invoice.event(10));
|
// workflowService.processWorkItem(invoice.event(10));
|
||||||
// totalUpdates++;
|
totalUpdates++;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// log("│ ├── " + totalUpdates + " invoices migrated in " +
|
log("│ ├── " + totalUpdates + " invoices migrated in " +
|
||||||
// (System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
(System.currentTimeMillis() - l1) + "ms ", messageBuffer);
|
||||||
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
// log("├── Successfully " + totalUpdates + " invoices migrated",
|
log("├── Successfully " + totalUpdates + " invoices migrated",
|
||||||
// messageBuffer);
|
messageBuffer);
|
||||||
|
|
||||||
// isRunning = false;
|
isRunning = false;
|
||||||
// return messageBuffer.toString();
|
return messageBuffer.toString();
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diese hilfsmethode liest die Cargosoft Datei mit den Mapping - alt->neu ein
|
* Diese hilfsmethode liest die Cargosoft Datei mit den Mapping - alt->neu ein
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// private Map<String, String> readAdressMapping() {
|
private Map<String, String> readAdressMapping() {
|
||||||
// Map<String, String> result = new HashMap<>();
|
Map<String, String> result = new HashMap<>();
|
||||||
// try (InputStream inputStream = getClass().getClassLoader()
|
try (InputStream inputStream = getClass().getClassLoader()
|
||||||
// .getResourceAsStream("agl_wandlung_20250822.csv");
|
.getResourceAsStream("agl_wandlung_20250822.csv");
|
||||||
// BufferedReader reader = new BufferedReader(
|
BufferedReader reader = new BufferedReader(
|
||||||
// new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
||||||
|
|
||||||
// String line;
|
String line;
|
||||||
// boolean firstLine = true;
|
boolean firstLine = true;
|
||||||
|
|
||||||
// while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
// if (firstLine) {
|
if (firstLine) {
|
||||||
// firstLine = false;
|
firstLine = false;
|
||||||
// continue; // Header überspringen
|
continue; // Header überspringen
|
||||||
// }
|
}
|
||||||
|
|
||||||
// String[] parts = line.split(";");
|
String[] parts = line.split(";");
|
||||||
// if (parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
// String oldID = parts[0].trim();
|
String oldID = parts[0].trim();
|
||||||
// String newID = parts[1].trim();
|
String newID = parts[1].trim();
|
||||||
// result.put(oldID, newID);
|
result.put(oldID, newID);
|
||||||
|
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// // Logging framework verwenden
|
// Logging framework verwenden
|
||||||
// System.err.println("Fehler beim Laden der CSV: " + e.getMessage());
|
System.err.println("Fehler beim Laden der CSV: " + e.getMessage());
|
||||||
// }
|
}
|
||||||
// return result;
|
return result;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hilfsmethode speichert eine cargoosft kreditor object...
|
* Hilfsmethode speichert eine cargoosft kreditor object...
|
||||||
|
|
@ -444,9 +447,9 @@ public class CargosoftMigrationRestService implements Serializable {
|
||||||
* @throws PluginException
|
* @throws PluginException
|
||||||
* @throws ModelException
|
* @throws ModelException
|
||||||
*/
|
*/
|
||||||
@GET
|
// @GET
|
||||||
@Path("/bp-delete")
|
// @Path("/bp-delete")
|
||||||
@Produces({ MediaType.TEXT_PLAIN })
|
// @Produces({ MediaType.TEXT_PLAIN })
|
||||||
public String deleteBusinessPartner(@QueryParam("maxcount") int maxcount)
|
public String deleteBusinessPartner(@QueryParam("maxcount") int maxcount)
|
||||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||||
StringBuffer messageBuffer = new StringBuffer();
|
StringBuffer messageBuffer = new StringBuffer();
|
||||||
|
|
@ -526,9 +529,9 @@ public class CargosoftMigrationRestService implements Serializable {
|
||||||
* @throws PluginException
|
* @throws PluginException
|
||||||
* @throws ModelException
|
* @throws ModelException
|
||||||
*/
|
*/
|
||||||
@GET
|
// @GET
|
||||||
@Path("/remove-dubletten")
|
// @Path("/remove-dubletten")
|
||||||
@Produces({ MediaType.TEXT_PLAIN })
|
// @Produces({ MediaType.TEXT_PLAIN })
|
||||||
public String deleteCargosoftDupplicates(@QueryParam("maxcount") int maxcount)
|
public String deleteCargosoftDupplicates(@QueryParam("maxcount") int maxcount)
|
||||||
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
throws QueryException, AccessDeniedException, ProcessingErrorException, PluginException, ModelException {
|
||||||
StringBuffer messageBuffer = new StringBuffer();
|
StringBuffer messageBuffer = new StringBuffer();
|
||||||
|
|
|
||||||
|
|
@ -144,12 +144,12 @@ public class BusinessPartnerImportService {
|
||||||
String cargosoftID = importDoc.getItemValueString("name");
|
String cargosoftID = importDoc.getItemValueString("name");
|
||||||
String partnerID = InvoiceUtil.buildBPID(cargosoftID);
|
String partnerID = InvoiceUtil.buildBPID(cargosoftID);
|
||||||
ItemCollection businesspartner = lookupBusinessPartner(partnerID);
|
ItemCollection businesspartner = lookupBusinessPartner(partnerID);
|
||||||
if (businesspartner != null) {
|
if (businesspartner != null && businesspartner.getTaskID() != 1800) {
|
||||||
logger.info("lock business partner object....");
|
logger.info("lock business partner object....");
|
||||||
try {
|
try {
|
||||||
businesspartner.setEventID(80);
|
businesspartner.setEventID(80);
|
||||||
workflowService.processWorkItemByNewTransaction(businesspartner);
|
workflowService.processWorkItemByNewTransaction(businesspartner);
|
||||||
} catch (AccessDeniedException | ProcessingErrorException | PluginException | ModelException e) {
|
} catch (Exception e) {
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Failed to lock Business Partner Object " + cargosoftID + " - " + e.getMessage());
|
"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_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_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_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_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_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_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>
|
||||||
<imixs-form-section columns="2" label="Invoice data">
|
<imixs-form-section columns="2" label="Invoice data">
|
||||||
<item name="cdtr.name" type="text" readonly="true" label="Vendor:"/>
|
<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>
|
||||||
<imixs-form-section columns="3">
|
<imixs-form-section columns="3">
|
||||||
<item name="invoice.number" type="text" label="Invoice number:" />
|
<item name="invoice.number" type="text" label="Invoice number:" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue