diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/einvoice/KSeFAdapter.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/einvoice/KSeFAdapter.java index d700733..12842c3 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/einvoice/KSeFAdapter.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/einvoice/KSeFAdapter.java @@ -52,6 +52,12 @@ import jakarta.inject.Inject; * * *
+ * NIP: The adapter needs the NIP (vat-id). If we do not find the partner.vat in + * the business object, we do a lookup on the D-Cargosoft object and try the vat + * id from there. This is because the partner.vat is a field which was not + * defined before. + * + *
* Wenn Debug = true gibt der Adapter alle einzelschritte auf der console aus
* und erzeugt zusätzlich die factur-x xml und txt dateien.
*
@@ -202,6 +208,38 @@ public class KSeFAdapter implements SignalAdapter {
throw new PluginException(this.getClass().getName(), DOCUMENT_ERROR,
"Business Partner ID '" + partnerID + "' does not exist");
}
+
+ /**
+ * Migration:
+ * If the business partner does not yet have the item "partner.vat" we try here
+ * to resync this information from the cargosoftkreditor object. This is needed
+ * because the partner.vat was not initially defined by the synch processor and
+ * so many partner objects do not yet provide this information.
+ */
+ if (businessPartner.getItemValueString("partner.vat").isEmpty()) {
+ logger.info("│ ├── BusinessPartner " + partnerID + " does not provide vat-id - try to migrate....");
+ String dNumber = businessPartner.getItemValueString("dbtr.number");
+ if (!dNumber.isEmpty()) {
+ try {
+ String query = "(type:cargosoftkreditor) AND (name:" + dNumber + ")";
+ List