corrections to intra community supply, the possibility to set it manually via exemptionreasoncode and another test

This commit is contained in:
jstaerk
2024-09-21 08:47:13 +02:00
parent c8a2f7e204
commit c521f58ef1
3 changed files with 71 additions and 3 deletions

View File

@@ -212,6 +212,8 @@ public class Product implements IZUGFeRDExportableProduct {
public Product setIntraCommunitySupply() { public Product setIntraCommunitySupply() {
isIntraCommunitySupply = true; isIntraCommunitySupply = true;
setVATPercent(BigDecimal.ZERO); setVATPercent(BigDecimal.ZERO);
setTaxExemptionReason("Intra-community supply");
setTaxCategoryCode("K");
return this; return this;
} }

View File

@@ -134,11 +134,11 @@ public class VATAmount {
} }
public VATAmount add(VATAmount v) { public VATAmount add(VATAmount v) {
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()), this.categoryCode, this.dueDateTypeCode); return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()), this.categoryCode, this.dueDateTypeCode).setVatExemptionReasonText(v.getVatExemptionReasonText());
} }
public VATAmount subtract(VATAmount v) { public VATAmount subtract(VATAmount v) {
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()), this.categoryCode, this.dueDateTypeCode); return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()), this.categoryCode, this.dueDateTypeCode).setVatExemptionReasonText(v.getVatExemptionReasonText());
} }
} }

View File

@@ -56,6 +56,7 @@ public class ZF2PushTest extends TestCase {
final String TARGET_ATTACHMENTSPDF = "./target/testout-ZF2PushAttachments.pdf"; final String TARGET_ATTACHMENTSPDF = "./target/testout-ZF2PushAttachments.pdf";
final String TARGET_BANKPDF = "./target/testout-ZF2PushBank.pdf"; final String TARGET_BANKPDF = "./target/testout-ZF2PushBank.pdf";
final String TARGET_PUSHEDGE = "./target/testout-ZF2PushEdge.pdf"; final String TARGET_PUSHEDGE = "./target/testout-ZF2PushEdge.pdf";
final String TARGET_INTRACOMMUNITYSUPPLYMANUALPDF = "./target/testout-ZF2PushIntraCommunitySupplyManual.pdf";
final String TARGET_INTRACOMMUNITYSUPPLYPDF = "./target/testout-ZF2PushIntraCommunitySupply.pdf"; final String TARGET_INTRACOMMUNITYSUPPLYPDF = "./target/testout-ZF2PushIntraCommunitySupply.pdf";
final String TARGET_REVERSECHARGEPDF = "./target/testout-ZF2PushReverseCharge.pdf"; final String TARGET_REVERSECHARGEPDF = "./target/testout-ZF2PushReverseCharge.pdf";
@@ -272,7 +273,10 @@ public class ZF2PushTest extends TestCase {
} }
public void testIntraCommunitySupplyExport() { /***
* you can activate intra community suppliy on item level
*/
public void testIntraCommunitySupplyItemExport() {
String orgname = "Test company"; String orgname = "Test company";
String number = "123"; String number = "123";
@@ -323,6 +327,68 @@ public class ZF2PushTest extends TestCase {
} }
} }
/**
* or manually, in which case the transaction needs a delivery address outside DE, and the items a 0 tax with reason K and reason code
*/
public void testIntraCommunitySupplyManualExport() {
String orgname = "Test company";
String number = "123";
String priceStr = "1.00";
String taxID = "9990815";
BigDecimal price = new BigDecimal(priceStr);
try {
InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1();
ze.ignorePDFAErrors();
ze.load(SOURCE_PDF);
ze.setProducer("My Application").setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2);
ze.setTransaction(new Invoice().setDeliveryAddress(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "FR")).setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
.setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID).addVATID("DE0815"))
.setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "FR").addVATID("DE4711")
.setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE")))
.setNumber(number)
.addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)).setTaxExemptionReason("Kein Ausweis der Umsatzsteuer bei innergemeinschaftlichen Lieferungen").setTaxCategoryCode("K"), price, new BigDecimal(1.0)))
);
String theXML = new String(ze.getProvider().getXML());
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
ze.export(TARGET_INTRACOMMUNITYSUPPLYMANUALPDF);
} catch (IOException e) {
fail("IOException should not be raised");
}
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(TARGET_INTRACOMMUNITYSUPPLYMANUALPDF);
Invoice i= null;
try {
i = zii.extractInvoice();
} catch (XPathExpressionException e) {
throw new RuntimeException(e);
} catch (ParseException e) {
throw new RuntimeException(e);
}
// now check the contents (like MustangReaderTest)
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_INTRACOMMUNITYSUPPLYMANUALPDF);
assertEquals("EUR", zi.getInvoiceCurrencyCode());
assertTrue(zi.getUTF8().contains(taxID));
// Reading ZUGFeRD
assertEquals("1.00", zi.getAmount());
assertEquals(orgname, zi.getHolder());
assertEquals(number, zi.getForeignReference());
try {
assertEquals(zi.getVersion(), 2);
} catch (Exception e) {
e.printStackTrace();
}
}
public void testReverseChargeExport() { public void testReverseChargeExport() {
String orgname = "Test company"; String orgname = "Test company";