From ed5423cb0d66b223e638000d390e4c26a75d3292 Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Thu, 27 Mar 2025 14:48:19 +0100 Subject: [PATCH] implement test --- .../src/test/java/org/mustangproject/ZUGFeRD/XRTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java index 564accbc..f819db12 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java @@ -194,15 +194,21 @@ public class XRTest extends TestCase { .setRecipient(recipient) .setReferenceNumber("991-01484-64")//leitweg-id // not using any VAT, this is also a test of zero-rated goods: - .setNumber(number).addItem(new org.mustangproject.Item(new org.mustangproject.Product("Testprodukt", "", "C62", java.math.BigDecimal.ZERO).setTaxCategoryCode(TaxCategoryCodeTypeConstants.UNTAXEDSERVICE), amount, new java.math.BigDecimal(1.0))); + .setNumber(number).addItem(new org.mustangproject.Item(new org.mustangproject.Product("Testprodukt", "", "C62", java.math.BigDecimal.ZERO).setTaxCategoryCode(TaxCategoryCodeTypeConstants.UNTAXEDSERVICE).setTaxExemptionReason("Expemtion reason"), amount, new java.math.BigDecimal(1.0))); ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider(); zf2p.setProfile(Profiles.getByName("XRechnung")); zf2p.generateXML(i); String theXML = new String(zf2p.getXML(), StandardCharsets.UTF_8); + // Untaxed services don't have the field RateApplicablePercent, since it would be always 0. An error is thrown on validation, if 0 is set. assertThat(theXML).valueByXPath("count(//*[local-name()='RateApplicablePercent'])") .asInt() .isEqualTo(0); + + //Exemption reason needs to be set if TaxCategoryCode == "O", reason should be at the product and in the ApplicableTradeTax + assertThat(theXML).valueByXPath("count(//*[local-name()='ExemptionReason'])") + .asInt() + .isEqualTo(2); } private org.mustangproject.Invoice createInvoice(TradeParty recipient) {