diff --git a/History.md b/History.md index d0423352..62eeec43 100644 --- a/History.md +++ b/History.md @@ -1,7 +1,8 @@ -- correcly write charge reason codes also for non-Xrechnung +- correcly write charge reason codes also for non-Xrechnung #617 - correctly import additional referenced documents into invoice/corrected setting of attachments from jackson - corrected parseException structure - allow 1p0 as potential xmp version number +- #618 import BT-20 2.15.1 ======= diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index da2c8792..5189bee6 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -262,7 +262,7 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter { * @return the Payment Terms */ public String getPaymentTerms() { - return extractString("//*[local-name() = 'SpecifiedTradePaymentTerms']//*[local-name() = 'Description']"); + return importedInvoice.getPaymentTermDescription(); } /** diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index 05aae56e..da10d8dd 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -644,6 +644,12 @@ public class ZUGFeRDInvoiceImporter { String currency = extractString("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]/*[local-name()=\"InvoiceCurrencyCode\"]|//*[local-name()=\"DocumentCurrencyCode\"]"); zpp.setCurrency(currency); + String paymentTermsDescription = extractString("//*[local-name()=\"SpecifiedTradePaymentTerms\"]/*[local-name()=\"Description\"]|//*[local-name()=\"PaymentTerms\"]/*[local-name()=\"Note\"]"); + if ((paymentTermsDescription!=null)&&(!paymentTermsDescription.isEmpty())) { + zpp.setPaymentTermDescription(paymentTermsDescription); + } + + xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]"); NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET); List bankDetails = new ArrayList<>(); @@ -660,6 +666,9 @@ public class ZUGFeRDInvoiceImporter { && (headerTradeSettlementChilds.item(settlementChildIndex).getLocalName().equals("SpecifiedTradePaymentTerms"))) { NodeList paymentTermChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes(); for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds.getLength(); paymentTermChildIndex++) { + if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("Description"))) { + zpp.setPaymentTermDescription(paymentTermChilds.item(paymentTermChildIndex).getTextContent()); + } if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("DueDateDateTime"))) { NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes(); for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds.getLength(); dueDateChildIndex++) { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index b6fac219..9771c76d 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -76,6 +76,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { assertEquals("LTR", invoice.getZFItems()[2].getProduct().getUnit()); assertEquals("7.00", invoice.getZFItems()[0].getProduct().getVATPercent().toString()); assertEquals("RE-20170509/505", invoice.getNumber()); + assertEquals("Zahlbar ohne Abzug bis zum 30.05.2017", invoice.getPaymentTermDescription()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); assertEquals("2017-05-09", sdf.format(invoice.getIssueDate())); @@ -127,7 +128,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { assertEquals(invoice.getZFItems()[0].getNotesWithSubjectCode().get(0).getContent(),"Something"); assertEquals(invoice.getZFItems()[0].getNotesWithSubjectCode().size(),1); assertEquals("400", invoice.getZFItems()[1].getQuantity().toString()); - + assertEquals("Zahlbar ohne Abzug bis zum 30.05.2017", invoice.getPaymentTermDescription()); assertEquals("AB321", invoice.getReferenceNumber()); assertEquals("160", invoice.getZFItems()[0].getPrice().toString()); assertEquals("Heiße Luft pro Liter", invoice.getZFItems()[2].getProduct().getName());