diff --git a/History.md b/History.md index c6f6238f..020198b9 100644 --- a/History.md +++ b/History.md @@ -1,19 +1,21 @@ -### 2.0.1 todo -- 2.1 support kleinunternehmer, reverse charge? -- dont show empty tax number field -- fail when no bankverbindung? -- fail when xr attrs missing? -- build xr skonto??? -- *validator not to XR error on ZF files (only notices) -- xmp errors may not show correctly in log -### 2.0.1 done +2.0.1 +===== +2020-11-21 + +- corrected VAT calculation on prices with >2 decimals (PR#195 thanks to weclapp-dev) +- have fax numbers only in appropriate profiles, i.e., extended - do not list tax numbers for shiptotradeparties - do not expect dueDate for corrected invoices -- XR test now includes guideline ID #172 +- XR test now includes guideline ID (of XRechnung 1.2.2) #172 - BigDecimal specific refactoring PR #192 Thanks to weclapp-dev - Preserving metadata PR #193 Thanks to mr-stephan - support zero-rated goods: confirm that VAT category code switches from S to Z on 0%VAT +- new sample invoice +- delivery period also on item level +- corrected more than 100 javadoc entries +- support specification of account (holder) names +- new sample invoice (20201121_508) 2.0.0 ===== diff --git a/Mustang-CLI/pom.xml b/Mustang-CLI/pom.xml index d7601bbf..0df1b88d 100644 --- a/Mustang-CLI/pom.xml +++ b/Mustang-CLI/pom.xml @@ -3,14 +3,14 @@ org.mustangproject core - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT 4.0.0 org.mustangproject Mustang-CLI Mustang commandline tool jar - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT @@ -31,7 +31,7 @@ org.mustangproject validator - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT diff --git a/library/pom.xml b/library/pom.xml index 01e43ddc..a6e19a95 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -3,13 +3,13 @@ org.mustangproject core - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT 4.0.0 org.mustangproject library - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT jar Library to write and read FacturX and ZUGFeRD e-invoices. The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs. To write files, a provided PDF/A will be combined with generated or provided XML. diff --git a/library/src/main/java/org/mustangproject/BankDetails.java b/library/src/main/java/org/mustangproject/BankDetails.java index 0b4298cb..766396b0 100644 --- a/library/src/main/java/org/mustangproject/BankDetails.java +++ b/library/src/main/java/org/mustangproject/BankDetails.java @@ -6,7 +6,7 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementPayment; * provides e.g. the IBAN to transfer money to :-) */ public class BankDetails implements IZUGFeRDTradeSettlementPayment { - protected String IBAN, BIC; + protected String IBAN, BIC, accountName=null; public BankDetails(String IBAN, String BIC) { this.IBAN = IBAN; @@ -34,6 +34,11 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment { return BIC; } + /*** + * The bank identifier. Bank name is no longer neccessary in SEPA. + * @param BIC the bic code + * @return fluent setter + */ public BankDetails setBIC(String BIC) { this.BIC = BIC; return this; @@ -55,6 +60,21 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment { } + /** + * set Holder + * @param name account name (usually account holder if != sender) + * @return fluent setter + */ + public BankDetails setAccountName(String name) { + accountName=name; + return this; + } + + @Override + public String getAccountName() { + return accountName; + } + } diff --git a/library/src/main/java/org/mustangproject/Item.java b/library/src/main/java/org/mustangproject/Item.java index 7ba5c359..a51afb97 100644 --- a/library/src/main/java/org/mustangproject/Item.java +++ b/library/src/main/java/org/mustangproject/Item.java @@ -5,12 +5,14 @@ import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Date; /*** * describes any invoice line */ public class Item implements IZUGFeRDExportableItem { protected BigDecimal price, quantity, tax, grossPrice, lineTotalAmount; + protected Date detailedDeliveryPeriodFrom=null, detailedDeliveryPeriodTo=null; protected String id; protected Product product; protected ArrayList notes = null; @@ -58,6 +60,7 @@ public class Item implements IZUGFeRDExportableItem { return this; } + public BigDecimal getTax() { return tax; } @@ -135,11 +138,23 @@ public class Item implements IZUGFeRDExportableItem { } + /*** + * Adds a item level addition to the price (will be multiplied by quantity) + * @see org.mustangproject.Charge + * @param izac a relative or absolute charge + * @return fluent setter + */ public Item addCharge(IZUGFeRDAllowanceCharge izac) { Charges.add(izac); return this; } + /*** + * Adds a item level reduction the price (will be multiplied by quantity) + * @see org.mustangproject.Allowance + * @param izac a relative or absolute allowance + * @return fluent setter + */ public Item addAllowance(IZUGFeRDAllowanceCharge izac) { Allowances.add(izac); return this; @@ -158,5 +173,37 @@ public class Item implements IZUGFeRDExportableItem { return this; } + /*** + * specify a item level delivery period + * (apart from the document level delivery period, and the document level + * delivery day, which is probably anyway required) + * + * @param from start date + * @param to end date + * @return fluent setter + */ + public Item setDetailedDeliveryPeriod(Date from, Date to) { + detailedDeliveryPeriodFrom=from; + detailedDeliveryPeriodTo=to; + return this; + } + + /*** + * specifies the item level delivery period (there is also one on document level), + * this will be included in a BillingSpecifiedPeriod element + * @return the beginning of the delivery period + */ + public Date getDetailedDeliveryPeriodFrom() { + return detailedDeliveryPeriodFrom; + } + + /*** + * specifies the item level delivery period (there is also one on document level), + * this will be included in a BillingSpecifiedPeriod element + * @return the end of the delivery period + */ + public Date getDetailedDeliveryPeriodTo() { + return detailedDeliveryPeriodTo; + } } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableItem.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableItem.java index 8f542274..80ead5ed 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableItem.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableItem.java @@ -27,6 +27,7 @@ package org.mustangproject.ZUGFeRD; * */ import java.math.BigDecimal; +import java.util.Date; public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{ @@ -88,4 +89,24 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{ return null; } + + + /*** + * specifies the item level delivery period (there is also one on document level), + * this will be included in a BillingSpecifiedPeriod element + * @return the beginning of the delivery period + */ + default Date getDetailedDeliveryPeriodFrom() { + return null; + } + + /*** + * specifies the item level delivery period (there is also one on document level), + * this will be included in a BillingSpecifiedPeriod element + * @return the end of the delivery period + */ + default Date getDetailedDeliveryPeriodTo() { + return null; + } + } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableProduct.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableProduct.java index ae5d6bbd..55af8ee1 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableProduct.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDExportableProduct.java @@ -1,21 +1,23 @@ -/** ********************************************************************** - * +/** + * ********************************************************************* + *

* Copyright 2018 Jochen Staerk - * + *

* Use is subject to license terms. - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0. - * + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * + *

* See the License for the specific language governing permissions and * limitations under the License. - * - *********************************************************************** */ + *

+ * ********************************************************************** + */ package org.mustangproject.ZUGFeRD; import java.math.BigDecimal; @@ -78,7 +80,7 @@ public interface IZUGFeRDExportableProduct { /** * Get the ID that had been assigned by the seller to * identify the product - * + * * @return seller assigned product ID */ default String getSellerAssignedID() { @@ -88,33 +90,34 @@ public interface IZUGFeRDExportableProduct { /** * Get the ID that had been assigned by the buyer to * identify the product - * + * * @return buyer assigned product ID */ default String getBuyerAssignedID() { return null; } + /** * VAT percent of the product (e.g. 19, or 5.1 if you like) * * @return VAT percent of the product */ BigDecimal getVATPercent(); - + default boolean isIntraCommunitySupply() { return false; } - + default String getTaxCategoryCode() { - if (getVATPercent().equals(new BigDecimal(0))) { + if (isIntraCommunitySupply()) { + return "K"; + } else if (getVATPercent().equals(new BigDecimal(0))) { return "Z"; // zero rated goods - } else if (isIntraCommunitySupply()) { - return "K"; - } else { - return "S"; // one of the "standard" rates (not neccessarily a default rate, even a deducted VAT is standard calculation) - } - } - + } else { + return "S"; // one of the "standard" rates (not neccessarily a default rate, even a deducted VAT is standard calculation) + } + } + default String getTaxExemptionReason() { if (isIntraCommunitySupply()) return "Intra-community supply"; diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDTradeSettlementPayment.java b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDTradeSettlementPayment.java index bfb1cc66..65561315 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDTradeSettlementPayment.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/IZUGFeRDTradeSettlementPayment.java @@ -52,14 +52,28 @@ public interface IZUGFeRDTradeSettlementPayment extends IZUGFeRDTradeSettlement return null; } + /*** + * Account name + * + * @return the name of the account holder (if not identical to sender) + */ + default String getAccountName() { return null; } + default String getSettlementXML() { + String accountNameStr=""; + if (getAccountName()!=null) { + accountNameStr="" + XMLTools.encodeXML(getAccountName()) + "\n"; //$NON-NLS-2$ + + } + String xml = " \n" + " 42\n" - + " Überweisung\n" + + " Bank transfer\n" + " \n" + " " + XMLTools.encodeXML(getOwnIBAN()) + "\n"; //$NON-NLS-2$ - xml+= " \n" + xml+= accountNameStr; + xml+= " \n" + " \n" + " " + XMLTools.encodeXML(getOwnBIC()) + "\n" //$NON-NLS-2$ // + " "+trans.getOwnBankName()+"\n" diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java b/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java index a2930b31..7221a333 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java @@ -33,7 +33,7 @@ public class Profiles { {"BASIC", new Profile("BASIC", "urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic")}, {"EN16931", new Profile("EN16931", "urn:cen.eu:en16931:2017")}, {"EXTENDED", new Profile("EXTENDED", "urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended")}, - {"XRECHNUNG", new Profile("XRECHNUNG", "urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0")} + {"XRECHNUNG", new Profile("XRECHNUNG", "urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_1.2")} }).collect(Collectors.toMap(data -> (String) data[0], data -> (Profile) data[1])); static Map zf1Map = Stream.of(new Object[][]{ diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 867cd303..f31176df 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -107,6 +107,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } // @todo check if the two boolean args can be refactored + /*** * returns the UN/CEFACT CII XML for companies(tradeparties), which is actually * the same for ZF1 (v 2013b) and ZF2 (v 2016b) @@ -127,7 +128,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } xml += " " + XMLTools.encodeXML(party.getName()) + "\n"; //$NON-NLS-2$ - if ((party.getContact() != null)&&(isSender||profile==Profiles.getByName("Extended"))) { + if ((party.getContact() != null) && (isSender || profile == Profiles.getByName("Extended"))) { xml = xml + "\n" + " " + XMLTools.encodeXML(party.getContact().getName()) + "\n"; if (party.getContact().getPhone() != null) { @@ -137,8 +138,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + " \n"; } - if (party.getContact().getFax() != null) { - + if ((party.getContact().getFax() != null) && (profile == Profiles.getByName("Extended"))) { xml = xml + " \n" + " " + XMLTools.encodeXML(party.getContact().getFax()) + "\n" + " \n"; @@ -167,13 +167,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + " " + XMLTools.encodeXML(party.getCountry()) + "\n" + " \n"; - if ((party.getVATID() != null)&&(!isShipToTradeParty)) { + if ((party.getVATID() != null) && (!isShipToTradeParty)) { xml += " \n" + " " + XMLTools.encodeXML(party.getVATID()) + "\n" + " \n"; } - if ((party.getTaxID() != null)&&(!isShipToTradeParty)) { + if ((party.getTaxID() != null) && (!isShipToTradeParty)) { xml += " \n" + " " + XMLTools.encodeXML(party.getTaxID()) + "\n" @@ -194,7 +194,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { protected String getAllowanceChargeStr(IZUGFeRDAllowanceCharge allowance, IAbsoluteValueProvider item) { String percentage = ""; String chargeIndicator = "false"; - if ((allowance.getPercent() != null)&&(profile==Profiles.getByName("Extended"))) { + if ((allowance.getPercent() != null) && (profile == Profiles.getByName("Extended"))) { percentage = "" + vatFormat(allowance.getPercent()) + ""; percentage += "" + item.getValue() + ""; } @@ -202,15 +202,15 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { chargeIndicator = "true"; } - String reason=""; - if ((allowance.getReason()!=null)&&(profile==Profiles.getByName("Extended"))) { + String reason = ""; + if ((allowance.getReason() != null) && (profile == Profiles.getByName("Extended"))) { // only in extended profile - reason=""+XMLTools.encodeXML(allowance.getReason())+""; + reason = "" + XMLTools.encodeXML(allowance.getReason()) + ""; } String allowanceChargeStr = "" + chargeIndicator + "" + percentage + "" + priceFormat(allowance.getTotalAmount(item)) + "" + - reason+ + reason + ""; return allowanceChargeStr; } @@ -229,7 +229,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { paymentTermsDescription = trans.getPaymentTermDescription(); } - if ((paymentTermsDescription == null)&&(trans.getDocumentCode()!= org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants.CORRECTEDINVOICE)) { + if ((paymentTermsDescription == null) && (trans.getDocumentCode() != org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants.CORRECTEDINVOICE)) { paymentTermsDescription = "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate()); } @@ -379,8 +379,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + " " + vatFormat(currentItem.getProduct().getVATPercent()) + "\n" - + " \n" - + " \n" + + " \n"; + if ((currentItem.getDetailedDeliveryPeriodFrom() != null) || (currentItem.getDetailedDeliveryPeriodTo() != null)) { + xml = xml + ""; + if (currentItem.getDetailedDeliveryPeriodFrom() != null) { + xml = xml + "" + zugferdDateFormat.format(currentItem.getDetailedDeliveryPeriodFrom()) + ""; + } + if (currentItem.getDetailedDeliveryPeriodTo() != null) { + xml = xml + "" + zugferdDateFormat.format(currentItem.getDetailedDeliveryPeriodTo()) + ""; + } + xml = xml + ""; + + } + + xml = xml + " \n" + " " + currencyFormat(lc.getItemTotalNetAmount()) + "\n" // currencyID=\"EUR\" + " \n"; @@ -430,7 +442,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + " 916\n" + " " + f.getDescription() + "\n" + " " + documentContent + "\n" + + " filename=\"" + f.getFilename() + "\">" + documentContent + "\n" + " \n"; } } @@ -482,8 +494,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } } } - if (trans.getDocumentCode()== DocumentCodeTypeConstants.CORRECTEDINVOICE) { - hasDueDate=false; + if (trans.getDocumentCode() == DocumentCodeTypeConstants.CORRECTEDINVOICE) { + hasDueDate = false; } HashMap VATPercentAmountMap = calc.getVATPercentAmountMap(); @@ -518,7 +530,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if ((trans.getZFCharges() != null) && (trans.getZFCharges().length > 0)) { for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) { - if (calc.getChargesForPercent(currentTaxPercent).compareTo(BigDecimal.ZERO)!=0) { + if (calc.getChargesForPercent(currentTaxPercent).compareTo(BigDecimal.ZERO) != 0) { xml = xml + " \n" + @@ -526,7 +538,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { " true\n" + " \n" + " " + currencyFormat(calc.getChargesForPercent(currentTaxPercent)) + "\n" + - " "+XMLTools.encodeXML(calc.getChargeReasonForPercent(currentTaxPercent))+"\n" + + " " + XMLTools.encodeXML(calc.getChargeReasonForPercent(currentTaxPercent)) + "\n" + " \n" + " VAT\n" + " " + VATPercentAmountMap.get(currentTaxPercent).getCategoryCode() + "\n" + @@ -541,13 +553,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if ((trans.getZFAllowances() != null) && (trans.getZFAllowances().length > 0)) { for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) { - if (calc.getAllowancesForPercent(currentTaxPercent).compareTo(BigDecimal.ZERO)!= 0) { + if (calc.getAllowancesForPercent(currentTaxPercent).compareTo(BigDecimal.ZERO) != 0) { xml = xml + " \n" + " \n" + " false\n" + " \n" + " " + currencyFormat(calc.getAllowancesForPercent(currentTaxPercent)) + "\n" + - " "+XMLTools.encodeXML(calc.getAllowanceReasonForPercent(currentTaxPercent))+"\n" + + " " + XMLTools.encodeXML(calc.getAllowanceReasonForPercent(currentTaxPercent)) + "\n" + " \n" + " VAT\n" + " " + VATPercentAmountMap.get(currentTaxPercent).getCategoryCode() + "\n" + @@ -621,7 +633,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { try { zugferdRaw = xml.getBytes("UTF-8"); - zugferdData=XMLTools.removeBOM(zugferdRaw); + zugferdData = XMLTools.removeBOM(zugferdRaw); } catch (UnsupportedEncodingException e) { Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e); } diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java index 30d92d78..cb94525c 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderTestCase.java @@ -141,6 +141,11 @@ public abstract class MustangReaderTestCase extends TestCase implements IExporta return "0815"; } + @Override + public String getVATID() { + return "DE0815"; + } + } protected class Item implements IZUGFeRDExportableItem { diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java index 5dd64e24..89e96242 100644 --- a/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java +++ b/library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java @@ -37,7 +37,7 @@ import junit.framework.TestCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ZF2PushTest extends TestCase { - final String TARGET_PDF = "./target/testout-ZF2Push.pdf"; + final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20201121_508.pdf"; final String TARGET_ALLOWANCESPDF = "./target/testout-ZF2PushAllowances.pdf"; final String TARGET_CORRECTIONPDF = "./target/testout-ZF2PushCorrection.pdf"; final String TARGET_ITEMCHARGESALLOWANCESPDF = "./target/testout-ZF2PushItemChargesAllowances.pdf"; @@ -50,46 +50,48 @@ public class ZF2PushTest extends TestCase { // the writing part - String orgname = "Test company"; - String number = "RE-20170509/505"; - String priceStr = "1.00"; + String orgname = "Bei Spiel GmbH"; + String number = "RE-20201121/508"; + String priceStr = "160.00"; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + BigDecimal price = new BigDecimal(priceStr); - String occurenceFrom = "20201001"; - String occurenceTo = "20201005"; - String contractID = "376zreurzu0983"; try (InputStream SOURCE_PDF = this.getClass() - .getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf"); + .getResourceAsStream("/MustangGnuaccountingBeispielRE-20201121_508blanko.pdf"); ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application") .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors() .load(SOURCE_PDF)) { - try { - ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setContractReferencedDocument(contractID).setDetailedDeliveryPeriod(new SimpleDateFormat("yyyyMMdd").parse(occurenceFrom), new SimpleDateFormat("yyyyMMdd").parse(occurenceTo)).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addBankDetails(new BankDetails("777666555", "DE4321"))).setOwnTaxID("4711").setOwnVATID("DE19990815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").setAdditionalAddress("Hinterhaus 3").setContact(new Contact("nameRep", "phoneRep", "emailRep@test.com"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0)))); - } catch (ParseException ex) { - throw new RuntimeException("Parse exception"); - } + + ze.setTransaction(new Invoice().setDueDate(sdf.parse("2020-12-12")).setIssueDate(sdf.parse("2020-11-21")).setDeliveryDate(sdf.parse("2020-11-10")) + .setSender(new TradeParty(orgname, "Ecke 12", "12345", "Stadthausen", "DE").addBankDetails(new BankDetails("DE88200800000970375700", "COBADEFFXXX").setAccountName("Max Mustermann")).addVATID("DE136695976")) + .setRecipient(new TradeParty("Theodor Est", "Bahnstr. 42", "88802", "Spielkreis", "DE") + .setContact(new Contact("Ingmar N. Fo", "(555) 23 78-23", "info@localhost.local")).setID("2")) + .setNumber(number) + .setReferenceNumber("AB321") + .addItem(new Item(new Product("Design (hours)", "Of a sample invoice", "HUR", new BigDecimal(7)), price, new BigDecimal(1.0))) + .addItem(new Item(new Product("Ballons", "various colors, ~2000ml", "H87", new BigDecimal(19)), new BigDecimal("0.79"), new BigDecimal(400.0))) + .addItem(new Item(new Product("Hot air „heiße Luft“ (litres)", "", "LTR", new BigDecimal(19)), new BigDecimal("0.025"), new BigDecimal(800.0))) + ); ze.export(TARGET_PDF); - } catch (IOException e) { - fail("IOException should not be raised in testEdgeExport"); + } catch (IOException | ParseException e) { + fail("Exception should not be raised in testPushExport"); } // now check the contents (like MustangReaderTest) ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF); - assertTrue(zi.getUTF8().contains("777666555")); //the iban + assertTrue(zi.getUTF8().contains("DE88200800000970375700")); //the iban + assertTrue(zi.getUTF8().contains("Max Mustermann")); //account holder assertTrue(zi.getUTF8().contains("4.0.0 org.mustangproject core - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT pom Mustang diff --git a/validator/pom.xml b/validator/pom.xml index a7f839e3..bd74cd8b 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -3,7 +3,7 @@ org.mustangproject core - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT 4.0.0 org.mustangproject @@ -11,7 +11,7 @@ Library to validate e-invoices (ZUGFeRD, Factur-X and Xrechnung) jar - 2.0.0-alpha4-SNAPSHOT + 2.0.2-SNAPSHOT @@ -75,10 +75,7 @@ org.mustangproject library - 2.0.0-alpha4-SNAPSHOT - + 2.0.2-SNAPSHOT org.xmlunit diff --git a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java index 06188838..977d85d3 100644 --- a/validator/src/test/java/org/mustangproject/validator/LibraryTest.java +++ b/validator/src/test/java/org/mustangproject/validator/LibraryTest.java @@ -12,7 +12,7 @@ import static org.xmlunit.assertj.XmlAssert.assertThat; public class LibraryTest extends ResourceCase { public void testLibraryPush() { - File tempFile = new File("../library/target/testout-ZF2Push.pdf"); + File tempFile = new File("../library/target/testout-MustangGnuaccountingBeispielRE-20201121_508.pdf"); assertTrue(tempFile.exists()); ZUGFeRDValidator zfv = new ZUGFeRDValidator();