diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index 3015f91c..ee0d5a89 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -449,8 +449,8 @@ public class ZUGFeRDInvoiceImporter { xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]|//*[local-name()=\"HeaderExchangedDocument\"]"); NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET); - - xpr = xpath.compile("//*[local-name()=\"GrandTotalAmount\"]|//*[local-name()=\"PayableAmount\"]"); + + xpr = xpath.compile("//*[local-name()=\"GrandTotalAmount\"]|//*[local-name()=\"TaxInclusiveAmount\"]"); BigDecimal expectedGrandTotal = null; NodeList totalNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET); if (totalNodes.getLength() > 0) { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java index f5ecb15a..6e9ae9c5 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java @@ -501,6 +501,24 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase { } + @Test + public void testImportPrepaidUBL() throws XPathExpressionException, ParseException { + InputStream inputStream = this.getClass() + .getResourceAsStream("/ubl/XRECHNUNG_teilrechnung.ubl.xml"); + ZUGFeRDInvoiceImporter importer = new ZUGFeRDInvoiceImporter(); + importer.doIgnoreCalculationErrors(); + importer.setInputStream(inputStream); + + CalculatedInvoice invoice = new CalculatedInvoice(); + importer.extractInto(invoice); + + assertEquals(0, invoice.getGrandTotal().compareTo(new BigDecimal("529.87"))); + assertEquals(0, invoice.getLineTotalAmount().compareTo(new BigDecimal("473"))); + assertEquals(0, invoice.getTotalPrepaidAmount().compareTo(new BigDecimal("500"))); + assertEquals(0, invoice.getDuePayable().compareTo(new BigDecimal("29.87"))); + } + + @Test public void testImportIncludedNotes() throws XPathExpressionException, ParseException { InputStream inputStream = this.getClass() diff --git a/library/src/test/resources/ubl/XRECHNUNG_teilrechnung.ubl.xml b/library/src/test/resources/ubl/XRECHNUNG_teilrechnung.ubl.xml new file mode 100644 index 00000000..d745f84a --- /dev/null +++ b/library/src/test/resources/ubl/XRECHNUNG_teilrechnung.ubl.xml @@ -0,0 +1,181 @@ + + + urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0 + urn:fdc:peppol.eu:2017:poacc:billing:01:1.0 + 471102 + 2024-11-15 + 380 + Rechnung gemäß Bestellung vom 01.11.2024. + #REG#Lieferant GmbH +Lieferantenstraße 20 +80333 München +Deutschland +Geschäftsführer: Hans Muster +Handelsregisternummer: H A 123 + + EUR + 04011000-12345-34 + + + info@Mustermann.de + + 4000001123452 + + + Lieferantenstraße 20 + München + 80333 + + DE + + + + 201/113/40209 + + FC + + + + DE123456789 + + VAT + + + + Lieferant GmbH + + + Max Mustermann + +49891234567 + Max@Mustermann.de + + + + + + info@kunde.de + + GE2020211 + + + Kundenstraße 15 + Frankfurt + 69876 + + DE + + + + Kunden AG Mitte + + + + + 2024-11-14 + + + 58 + + DE02120300000000202051 + Kunden AG + + BYLADEM1001 + + + + + Zahlbar innerhalb 30 Tagen netto bis 15.12.2024, 3% Skonto innerhalb 10 Tagen bis 25.11.2024 + + + 56.87 + + 275 + 19.25 + + S + 7 + + VAT + + + + + 198 + 37.62 + + S + 19 + + VAT + + + + + + 473 + 473 + 529.87 + 0 + 0 + 500 + 29.87 + + + 1 + 20 + 198 + + Trennblätter A4 + + TB100A4 + + + 4012345001235 + + + S + 19 + + VAT + + + + + 9.9 + + false + 0 + 9.9 + + + + + 2 + 50 + 275 + + Joghurt Banane + + ARNR2 + + + 4000050986428 + + + S + 7 + + VAT + + + + + 5.5 + + false + 0 + 5.5 + + + +