Merge pull request #816 from fleigm/bugfix/ubl_wrong_total_gross_amount
Bugfix: Wrong grand total amount for UBL invoices
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
181
library/src/test/resources/ubl/XRECHNUNG_teilrechnung.ubl.xml
Normal file
181
library/src/test/resources/ubl/XRECHNUNG_teilrechnung.ubl.xml
Normal file
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
|
||||
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</cbc:CustomizationID>
|
||||
<cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>
|
||||
<cbc:ID>471102</cbc:ID>
|
||||
<cbc:IssueDate>2024-11-15</cbc:IssueDate>
|
||||
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
|
||||
<cbc:Note>Rechnung gemäß Bestellung vom 01.11.2024.</cbc:Note>
|
||||
<cbc:Note>#REG#Lieferant GmbH
|
||||
Lieferantenstraße 20
|
||||
80333 München
|
||||
Deutschland
|
||||
Geschäftsführer: Hans Muster
|
||||
Handelsregisternummer: H A 123
|
||||
</cbc:Note>
|
||||
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>
|
||||
<cbc:BuyerReference>04011000-12345-34</cbc:BuyerReference>
|
||||
<cac:AccountingSupplierParty>
|
||||
<cac:Party>
|
||||
<cbc:EndpointID schemeID="EM">info@Mustermann.de</cbc:EndpointID>
|
||||
<cac:PartyIdentification>
|
||||
<cbc:ID schemeID="0088">4000001123452</cbc:ID>
|
||||
</cac:PartyIdentification>
|
||||
<cac:PostalAddress>
|
||||
<cbc:StreetName>Lieferantenstraße 20</cbc:StreetName>
|
||||
<cbc:CityName>München</cbc:CityName>
|
||||
<cbc:PostalZone>80333</cbc:PostalZone>
|
||||
<cac:Country>
|
||||
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
|
||||
</cac:Country>
|
||||
</cac:PostalAddress>
|
||||
<cac:PartyTaxScheme>
|
||||
<cbc:CompanyID>201/113/40209</cbc:CompanyID>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>FC</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:PartyTaxScheme>
|
||||
<cac:PartyTaxScheme>
|
||||
<cbc:CompanyID>DE123456789</cbc:CompanyID>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:PartyTaxScheme>
|
||||
<cac:PartyLegalEntity>
|
||||
<cbc:RegistrationName>Lieferant GmbH</cbc:RegistrationName>
|
||||
</cac:PartyLegalEntity>
|
||||
<cac:Contact>
|
||||
<cbc:Name>Max Mustermann</cbc:Name>
|
||||
<cbc:Telephone>+49891234567</cbc:Telephone>
|
||||
<cbc:ElectronicMail>Max@Mustermann.de</cbc:ElectronicMail>
|
||||
</cac:Contact>
|
||||
</cac:Party>
|
||||
</cac:AccountingSupplierParty>
|
||||
<cac:AccountingCustomerParty>
|
||||
<cac:Party>
|
||||
<cbc:EndpointID schemeID="EM">info@kunde.de</cbc:EndpointID>
|
||||
<cac:PartyIdentification>
|
||||
<cbc:ID>GE2020211</cbc:ID>
|
||||
</cac:PartyIdentification>
|
||||
<cac:PostalAddress>
|
||||
<cbc:StreetName>Kundenstraße 15</cbc:StreetName>
|
||||
<cbc:CityName>Frankfurt</cbc:CityName>
|
||||
<cbc:PostalZone>69876</cbc:PostalZone>
|
||||
<cac:Country>
|
||||
<cbc:IdentificationCode>DE</cbc:IdentificationCode>
|
||||
</cac:Country>
|
||||
</cac:PostalAddress>
|
||||
<cac:PartyLegalEntity>
|
||||
<cbc:RegistrationName>Kunden AG Mitte</cbc:RegistrationName>
|
||||
</cac:PartyLegalEntity>
|
||||
</cac:Party>
|
||||
</cac:AccountingCustomerParty>
|
||||
<cac:Delivery>
|
||||
<cbc:ActualDeliveryDate>2024-11-14</cbc:ActualDeliveryDate>
|
||||
</cac:Delivery>
|
||||
<cac:PaymentMeans>
|
||||
<cbc:PaymentMeansCode name="Zahlung per SEPA Überweisung.">58</cbc:PaymentMeansCode>
|
||||
<cac:PayeeFinancialAccount>
|
||||
<cbc:ID>DE02120300000000202051</cbc:ID>
|
||||
<cbc:Name>Kunden AG</cbc:Name>
|
||||
<cac:FinancialInstitutionBranch>
|
||||
<cbc:ID>BYLADEM1001</cbc:ID>
|
||||
</cac:FinancialInstitutionBranch>
|
||||
</cac:PayeeFinancialAccount>
|
||||
</cac:PaymentMeans>
|
||||
<cac:PaymentTerms>
|
||||
<cbc:Note>Zahlbar innerhalb 30 Tagen netto bis 15.12.2024, 3% Skonto innerhalb 10 Tagen bis 25.11.2024</cbc:Note>
|
||||
</cac:PaymentTerms>
|
||||
<cac:TaxTotal>
|
||||
<cbc:TaxAmount currencyID="EUR">56.87</cbc:TaxAmount>
|
||||
<cac:TaxSubtotal>
|
||||
<cbc:TaxableAmount currencyID="EUR">275</cbc:TaxableAmount>
|
||||
<cbc:TaxAmount currencyID="EUR">19.25</cbc:TaxAmount>
|
||||
<cac:TaxCategory>
|
||||
<cbc:ID>S</cbc:ID>
|
||||
<cbc:Percent>7</cbc:Percent>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:TaxCategory>
|
||||
</cac:TaxSubtotal>
|
||||
<cac:TaxSubtotal>
|
||||
<cbc:TaxableAmount currencyID="EUR">198</cbc:TaxableAmount>
|
||||
<cbc:TaxAmount currencyID="EUR">37.62</cbc:TaxAmount>
|
||||
<cac:TaxCategory>
|
||||
<cbc:ID>S</cbc:ID>
|
||||
<cbc:Percent>19</cbc:Percent>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:TaxCategory>
|
||||
</cac:TaxSubtotal>
|
||||
</cac:TaxTotal>
|
||||
<cac:LegalMonetaryTotal>
|
||||
<cbc:LineExtensionAmount currencyID="EUR">473</cbc:LineExtensionAmount>
|
||||
<cbc:TaxExclusiveAmount currencyID="EUR">473</cbc:TaxExclusiveAmount>
|
||||
<cbc:TaxInclusiveAmount currencyID="EUR">529.87</cbc:TaxInclusiveAmount>
|
||||
<cbc:AllowanceTotalAmount currencyID="EUR">0</cbc:AllowanceTotalAmount>
|
||||
<cbc:ChargeTotalAmount currencyID="EUR">0</cbc:ChargeTotalAmount>
|
||||
<cbc:PrepaidAmount currencyID="EUR">500</cbc:PrepaidAmount>
|
||||
<cbc:PayableAmount currencyID="EUR">29.87</cbc:PayableAmount>
|
||||
</cac:LegalMonetaryTotal>
|
||||
<cac:InvoiceLine>
|
||||
<cbc:ID>1</cbc:ID>
|
||||
<cbc:InvoicedQuantity unitCode="H87">20</cbc:InvoicedQuantity>
|
||||
<cbc:LineExtensionAmount currencyID="EUR">198</cbc:LineExtensionAmount>
|
||||
<cac:Item>
|
||||
<cbc:Name>Trennblätter A4</cbc:Name>
|
||||
<cac:SellersItemIdentification>
|
||||
<cbc:ID>TB100A4</cbc:ID>
|
||||
</cac:SellersItemIdentification>
|
||||
<cac:StandardItemIdentification>
|
||||
<cbc:ID schemeID="0160">4012345001235</cbc:ID>
|
||||
</cac:StandardItemIdentification>
|
||||
<cac:ClassifiedTaxCategory>
|
||||
<cbc:ID>S</cbc:ID>
|
||||
<cbc:Percent>19</cbc:Percent>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:ClassifiedTaxCategory>
|
||||
</cac:Item>
|
||||
<cac:Price>
|
||||
<cbc:PriceAmount currencyID="EUR">9.9</cbc:PriceAmount>
|
||||
<cac:AllowanceCharge>
|
||||
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
|
||||
<cbc:Amount currencyID="EUR">0</cbc:Amount>
|
||||
<cbc:BaseAmount currencyID="EUR">9.9</cbc:BaseAmount>
|
||||
</cac:AllowanceCharge>
|
||||
</cac:Price>
|
||||
</cac:InvoiceLine>
|
||||
<cac:InvoiceLine>
|
||||
<cbc:ID>2</cbc:ID>
|
||||
<cbc:InvoicedQuantity unitCode="H87">50</cbc:InvoicedQuantity>
|
||||
<cbc:LineExtensionAmount currencyID="EUR">275</cbc:LineExtensionAmount>
|
||||
<cac:Item>
|
||||
<cbc:Name>Joghurt Banane</cbc:Name>
|
||||
<cac:SellersItemIdentification>
|
||||
<cbc:ID>ARNR2</cbc:ID>
|
||||
</cac:SellersItemIdentification>
|
||||
<cac:StandardItemIdentification>
|
||||
<cbc:ID schemeID="0160">4000050986428</cbc:ID>
|
||||
</cac:StandardItemIdentification>
|
||||
<cac:ClassifiedTaxCategory>
|
||||
<cbc:ID>S</cbc:ID>
|
||||
<cbc:Percent>7</cbc:Percent>
|
||||
<cac:TaxScheme>
|
||||
<cbc:ID>VAT</cbc:ID>
|
||||
</cac:TaxScheme>
|
||||
</cac:ClassifiedTaxCategory>
|
||||
</cac:Item>
|
||||
<cac:Price>
|
||||
<cbc:PriceAmount currencyID="EUR">5.5</cbc:PriceAmount>
|
||||
<cac:AllowanceCharge>
|
||||
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
|
||||
<cbc:Amount currencyID="EUR">0</cbc:Amount>
|
||||
<cbc:BaseAmount currencyID="EUR">5.5</cbc:BaseAmount>
|
||||
</cac:AllowanceCharge>
|
||||
</cac:Price>
|
||||
</cac:InvoiceLine>
|
||||
</Invoice>
|
||||
Reference in New Issue
Block a user