Merge pull request #741 from InnuceEAN/position_accounting_reference

read position accountingReference
This commit is contained in:
Jochen Staerk
2025-04-01 16:30:45 +02:00
committed by GitHub
3 changed files with 24 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ public class Item implements IZUGFeRDExportableItem {
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<>(); protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<>();
protected ArrayList<IZUGFeRDAllowanceCharge> Charges = new ArrayList<>(); protected ArrayList<IZUGFeRDAllowanceCharge> Charges = new ArrayList<>();
protected List<IncludedNote> includedNotes = null; protected List<IncludedNote> includedNotes = null;
protected String accountingReference;
//protected HashMap<String, String> attributes = new HashMap<>(); //protected HashMap<String, String> attributes = new HashMap<>();
/*** /***
@@ -214,6 +215,8 @@ public class Item implements IZUGFeRDExportableItem {
icnm.getAllNodes("AdditionalReferencedDocument").map(ReferencedDocument::fromNode).forEach(this::addAdditionalReference); icnm.getAllNodes("AdditionalReferencedDocument").map(ReferencedDocument::fromNode).forEach(this::addAdditionalReference);
icnm.getAsString("ReceivableSpecifiedTradeAccountingAccount").ifPresent(s -> this.accountingReference = s == null ? null : s.trim());
icnm.getAsNodeMap("BillingSpecifiedPeriod").ifPresent(periodNode -> { icnm.getAsNodeMap("BillingSpecifiedPeriod").ifPresent(periodNode -> {
Date start = periodNode.getAsNodeMap("StartDateTime").flatMap(dateTimeNode -> dateTimeNode.getNode("DateTimeString")).map(dts -> XMLTools.tryDate(dts)).orElse(null); Date start = periodNode.getAsNodeMap("StartDateTime").flatMap(dateTimeNode -> dateTimeNode.getNode("DateTimeString")).map(dts -> XMLTools.tryDate(dts)).orElse(null);
Date end = periodNode.getAsNodeMap("EndDateTime").flatMap(dateTimeNode -> dateTimeNode.getNode("DateTimeString")).map(dts -> XMLTools.tryDate(dts)).orElse(null); Date end = periodNode.getAsNodeMap("EndDateTime").flatMap(dateTimeNode -> dateTimeNode.getNode("DateTimeString")).map(dts -> XMLTools.tryDate(dts)).orElse(null);
@@ -561,4 +564,9 @@ public class Item implements IZUGFeRDExportableItem {
public List<IncludedNote> getNotesWithSubjectCode() { public List<IncludedNote> getNotesWithSubjectCode() {
return includedNotes; return includedNotes;
} }
@Override
public String getAccountingReference() {
return accountingReference;
}
} }

View File

@@ -172,4 +172,8 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
default List<IncludedNote> getNotesWithSubjectCode() { default List<IncludedNote> getNotesWithSubjectCode() {
return null; return null;
} }
default String getAccountingReference() {
return null;
}
} }

View File

@@ -585,4 +585,16 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
assertEquals("0", zii.importedInvoice.getDuePayable().toPlainString()); assertEquals("0", zii.importedInvoice.getDuePayable().toPlainString());
} }
@Test
public void test() throws FileNotFoundException, XPathExpressionException, ParseException {
File inputFile = getResourceAsFile("ORDER-X_EX01_ORDER_FULL_DATA-COMFORTorder-x.xml");
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter();
zii.doIgnoreCalculationErrors();
zii.setInputStream(new FileInputStream(inputFile));
Invoice invoice = zii.extractInvoice();
assertEquals(3, invoice.getZFItems().length);
assertEquals("BUYER_ACCOUNTING_REF", invoice.getZFItems()[0].getAccountingReference());
}
} }