lookup nip - migration

This commit is contained in:
Ralph Soika 2025-11-24 18:48:13 +01:00
parent cca28e9414
commit 6e65ed4468
3 changed files with 146 additions and 9 deletions

View file

@ -52,6 +52,12 @@ import jakarta.inject.Inject;
* </pre> * </pre>
* *
* <p> * <p>
* 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.
*
* <p>
* Wenn Debug = true gibt der Adapter alle einzelschritte auf der console aus * Wenn Debug = true gibt der Adapter alle einzelschritte auf der console aus
* und erzeugt zusätzlich die factur-x xml und txt dateien. * 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, throw new PluginException(this.getClass().getName(), DOCUMENT_ERROR,
"Business Partner ID '" + partnerID + "' does not exist"); "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<ItemCollection> result;
result = documentService.find(query, 1, 0);
if (result != null && result.size() > 0) {
ItemCollection creditorData = result.get(0);
String vatID = creditorData.getItemValueString("_vendor_vat_registration_id");
logger.info("│ ├── synchronize VAT Registrytion ID: " + vatID);
// update business partner
businessPartner.setItemValue("partner.vat", vatID);
documentService.saveByNewTransaction(businessPartner);
}
} catch (Exception e) {
// should not happen!
logger.info("│ ├── ⚠️ Failed to sync BusinessPartner : " + e.getMessage());
}
}
}
TradeParty tradeParty = new TradeParty(type); TradeParty tradeParty = new TradeParty(type);
// Name ist immer die erste Zeile // Name ist immer die erste Zeile

View file

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<Faktura xmlns="http://crd.gov.pl/wzor/2025/06/25/13775/" xmlns:etd="http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2022/01/05/eD/DefinicjeTypy/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Naglowek>
<KodFormularza kodSystemowy="FA (3)" wersjaSchemy="1-0E">FA</KodFormularza>
<WariantFormularza>3</WariantFormularza>
<DataWytworzeniaFa>2025-11-24T18:45:31.387561092Z</DataWytworzeniaFa>
<SystemInfo>Imixs eInvoice</SystemInfo>
</Naglowek>
<!-- Seller (Your Polish Company - Pre-filled) -->
<Podmiot1>
<DaneIdentyfikacyjne>
<NIP>9552521552</NIP>
<Nazwa>Alexander Global Logistics</Nazwa>
</DaneIdentyfikacyjne>
<Adres>
<KodKraju>PL</KodKraju>
<AdresL1>Gdanska 36</AdresL1>
<AdresL2>70-660 Szczecin</AdresL2>
</Adres>
<DaneKontaktowe>
<Email>MBudas@alexander-logistics.com</Email>
</DaneKontaktowe>
</Podmiot1>
<!-- Buyer (Customer - Empty, to be filled) -->
<Podmiot2>
<DaneIdentyfikacyjne>
<!-- NIP falls eine PL Ust Vorliegt
ansonsten NrID - geht immer -->
<!-- <NIP></NIP> -->
<!-- <Nazwa>#Customer Name#</Nazwa> -->
<NIP>6621004747</NIP>
<Nazwa>REGESTA Spolka Akcyjna</Nazwa>
</DaneIdentyfikacyjne>
<Adres>
<KodKraju>PL</KodKraju>
<AdresL1>ul. Nowowiejska 52a</AdresL1>
<AdresL2>28-400 Pinczow</AdresL2>
</Adres>
<!---
Contact information from buyer can be left
<DaneKontaktowe>
<Email></Email>
<Telefon></Telefon>
</DaneKontaktowe>
-->
<NrKlienta>D15231</NrKlienta>
<JST>2</JST>
<!-- fixed -->
<GV>2</GV>
<!-- fixed -->
</Podmiot2>
<!-- Invoice Data -->
<Fa>
<KodWaluty>EUR</KodWaluty>
<P_1>2024-04-03</P_1>
<!-- Invoice Date -->
<P_2>216525</P_2>
<!-- Invoice Number -->
<P_6>2024-06-02</P_6>
<!-- Due Date -->
<!-- Totals -->
<P_13_1>4128.00</P_13_1>
<!-- Total Net -->
<P_14_1>0.00</P_14_1>
<!-- Total VAT -->
<P_15>4128.00</P_15>
<!-- Total Gross -->
<Adnotacje>
<!-- 1 yes - 2 no -->
<P_16>2</P_16>
<!-- Keine Selbstfakturierung -->
<P_17>2</P_17>
<!-- Kein Reverse Charge -->
<P_18>2</P_18>
<!-- Kein Split Payment (Rechnung unter 15.000 PLN/EUR) -->
<P_18A>2</P_18A>
<!-- Keine Steuerbefreiung -->
<Zwolnienie>
<P_19N>1</P_19N>
</Zwolnienie>
<!-- Keine neuen Verkehrsmittel -->
<NoweSrodkiTransportu>
<P_22N>1</P_22N>
</NoweSrodkiTransportu>
<!-- Kein vereinfachtes Verfahren nach Art. 135 -->
<P_23>2</P_23>
<!-- Keine Margenregelung -->
<PMarzy>
<P_PMarzyN>1</P_PMarzyN>
</PMarzy>
</Adnotacje>
<!-- Invoice Type (VAT) -->
<RodzajFaktury>VAT</RodzajFaktury>
<!-- Invoice Positions: FaWiersz -->
<FaWiersz>
<NrWierszaFa>1</NrWierszaFa>
<UU_ID>8a8458dc-5b4f-462c-a964-8848d089a0f9</UU_ID>
<P_7>R IM-ZEL-2403-259</P_7>
<P_8A>szt.</P_8A>
<P_8B>1</P_8B>
<P_9A>4128.00</P_9A>
<P_11>4128.00</P_11>
</FaWiersz>
</Fa>
</Faktura>

View file

@ -32,8 +32,7 @@
<DaneIdentyfikacyjne> <DaneIdentyfikacyjne>
<!-- NIP falls eine PL Ust Vorliegt <!-- NIP falls eine PL Ust Vorliegt
ansonsten NrID - geht immer --> ansonsten NrID - geht immer -->
<!-- <NIP></NIP> --> <!-- <Nazwa>#Customer Name#</Nazwa> -->
<Nazwa>#Customer Name#</Nazwa>
</DaneIdentyfikacyjne> </DaneIdentyfikacyjne>
<Adres> <Adres>
<KodKraju></KodKraju> <KodKraju></KodKraju>
@ -59,16 +58,11 @@
<P_1></P_1> <!-- Invoice Date --> <P_1></P_1> <!-- Invoice Date -->
<P_2></P_2> <!-- Invoice Number --> <P_2></P_2> <!-- Invoice Number -->
<P_6></P_6> <!-- Due Date --> <P_6></P_6> <!-- Due Date -->
<!-- Line Items will be added here -->
<!-- Totals --> <!-- Totals -->
<P_13_1>0.00</P_13_1> <!-- Total Net --> <P_13_1>0.00</P_13_1> <!-- Total Net -->
<P_14_1>0.00</P_14_1> <!-- Total VAT --> <P_14_1>0.00</P_14_1> <!-- Total VAT -->
<P_15>0.00</P_15> <!-- Total Gross --> <P_15>0.00</P_15> <!-- Total Gross -->
<Adnotacje> <Adnotacje>
<!-- 1 yes - 2 no --> <!-- 1 yes - 2 no -->
<P_16>2</P_16> <P_16>2</P_16>
@ -100,11 +94,11 @@
<P_PMarzyN>1</P_PMarzyN> <P_PMarzyN>1</P_PMarzyN>
</PMarzy> </PMarzy>
</Adnotacje> </Adnotacje>
<!-- Normale Rechnung (VAT) --> <!-- Invoice Type (VAT) -->
<RodzajFaktury>VAT</RodzajFaktury> <RodzajFaktury>VAT</RodzajFaktury>
<!-- Invoice Poitions FaWiersz --> <!-- Invoice Positions: FaWiersz -->
</Fa> </Fa>
</Faktura> </Faktura>