From 83ddc99fc68d5831a4c1d0796ed6eade8f71ae2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Sta=CC=88rk?= Date: Sun, 26 Jan 2020 17:48:14 +0100 Subject: [PATCH] corrected intra community suppli/vat exemption sequence --- .../ZUGFeRD/ZUGFeRD2PullProvider.java | 166 +++++++++--------- 1 file changed, 86 insertions(+), 80 deletions(-) diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 5b143d5e..5181ab58 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -246,18 +246,18 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { public void generateXML(IZUGFeRDExportableTransaction trans) { this.trans = trans; - boolean hasDueDate=false; - String taxCategoryCode=""; + boolean hasDueDate = false; + String taxCategoryCode = ""; SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$ SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$ - String exemptionReason=""; + String exemptionReason = ""; + + if (paymentTermsDescription == null) { + paymentTermsDescription = "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate()); - if (paymentTermsDescription==null) { - paymentTermsDescription= "Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate()); - } - if (trans.getPaymentTermDescription()!=null) { - paymentTermsDescription=trans.getPaymentTermDescription(); + if (trans.getPaymentTermDescription() != null) { + paymentTermsDescription = trans.getPaymentTermDescription(); } String senderReg = ""; @@ -311,11 +311,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { int lineID = 0; for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) { lineID++; - taxCategoryCode=currentItem.getProduct().getTaxCategoryCode(); - if (currentItem.getProduct().isIntraCommunitySupply()) { - exemptionReason="Intra-community supply"; + taxCategoryCode = currentItem.getProduct().getTaxCategoryCode(); + if (currentItem.getProduct().isIntraCommunitySupply()) { + exemptionReason = "Intra-community supply"; } - + LineCalc lc = new LineCalc(currentItem); xml = xml + " \n" + //$NON-NLS-1$ " \n" //$NON-NLS-1$ @@ -325,7 +325,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { // + " 4012345001235\n" // + " KR3M\n" // + " 55T01\n" - + " " + XMLTools.encodeXML(currentItem.getProduct().getName()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ + + " " + XMLTools.encodeXML(currentItem.getProduct().getName()) //$NON-NLS-1$ + + "\n" //$NON-NLS-1$ + " " + XMLTools.encodeXML(currentItem.getProduct().getDescription()) //$NON-NLS-1$ + "\n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ @@ -334,8 +335,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + " \n" //$NON-NLS-1$ + " " + priceFormat(lc.getPriceGross()) //$NON-NLS-1$ + "\n" //$NON-NLS-1$ //currencyID=\"EUR\" - + " 1.0000\n" //$NON-NLS-1$ + + " 1.0000\n" //$NON-NLS-1$ // + " \n" // + " false\n" // + " 0.6667\n" @@ -345,21 +346,22 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + " \n" //$NON-NLS-1$ + " " + priceFormat(currentItem.getPrice()) //$NON-NLS-1$ + "\n" //$NON-NLS-1$ // currencyID=\"EUR\" - + " 1.0000\n" //$NON-NLS-1$ + + " 1.0000\n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ - + " " //$NON-NLS-1$ //$NON-NLS-2$ + + " " //$NON-NLS-1$ + quantityFormat(currentItem.getQuantity()) + "\n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " VAT\n" //$NON-NLS-1$ - + " "+currentItem.getProduct().getTaxCategoryCode()+"\n" //$NON-NLS-1$ - + exemptionReason - + " " //$NON-NLS-1$ + + exemptionReason + + " " + currentItem.getProduct().getTaxCategoryCode() //$NON-NLS-1$ + + "\n" + " " //$NON-NLS-2$ + vatFormat(currentItem.getProduct().getVATPercent()) + "\n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ @@ -373,24 +375,25 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { xml = xml + " \n"; //$NON-NLS-1$ if (trans.getReferenceNumber() != null) { - xml = xml + " " + XMLTools.encodeXML(trans.getReferenceNumber()) + "\n"; + xml = xml + " " + XMLTools.encodeXML(trans.getReferenceNumber()) + + "\n"; } xml = xml + " \n" //$NON-NLS-1$ // + " 4000001123452\n" + " " + XMLTools.encodeXML(trans.getOwnOrganisationName()) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ - if ((trans.getOwnVATID()!=null)&&(trans.getOwnOrganisationName()!=null)) { - + if ((trans.getOwnVATID() != null) && (trans.getOwnOrganisationName() != null)) { + xml = xml + " \n" + " " - + XMLTools.encodeXML(trans.getOwnVATID()) + "\n" + " " - + XMLTools.encodeXML(trans.getOwnOrganisationName()) + "\n" - + " "; + + XMLTools.encodeXML(trans.getOwnVATID()) + "\n" + + " " + XMLTools.encodeXML(trans.getOwnOrganisationName()) + + "\n" + " "; } if (trans.getOwnContact() != null) { - xml = xml + "\n" + " " + XMLTools.encodeXML(trans.getOwnContact().getName()) - + "\n"; + xml = xml + "\n" + " " + + XMLTools.encodeXML(trans.getOwnContact().getName()) + "\n"; if (trans.getOwnContact().getPhone() != null) { xml = xml + " \n" + " " @@ -409,36 +412,41 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { xml = xml + " \n" + " " + XMLTools.encodeXML(trans.getOwnZIP()) + "\n" + " " - + XMLTools.encodeXML(trans.getOwnStreet()) + "\n" + " " + XMLTools.encodeXML(trans.getOwnLocation()) - + "\n" + " " + XMLTools.encodeXML(trans.getOwnCountry()) - + "\n" + " \n" - + " \n" //$NON-NLS-1$ - + " " + XMLTools.encodeXML(trans.getOwnTaxID()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + " \n" //$NON-NLS-1$ - + " \n" //$NON-NLS-1$ - + " " + XMLTools.encodeXML(trans.getOwnVATID()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - + " \n" //$NON-NLS-1$ - + " \n" //$NON-NLS-1$ + + XMLTools.encodeXML(trans.getOwnStreet()) + "\n" + " " + + XMLTools.encodeXML(trans.getOwnLocation()) + "\n" + " " + + XMLTools.encodeXML(trans.getOwnCountry()) + "\n" + + " \n"; + if (trans.getOwnTaxID() != null) { + xml = xml + " \n" //$NON-NLS-1$ + + " " + XMLTools.encodeXML(trans.getOwnTaxID()) //$NON-NLS-1$ + + "\n" //$NON-NLS-1$ + + " \n"; //$NON-NLS-1$ + } + if (trans.getOwnTaxID() != null) { + xml = xml + " \n" //$NON-NLS-1$ + + " " + XMLTools.encodeXML(trans.getOwnVATID()) //$NON-NLS-1$ + + "\n" //$NON-NLS-1$ + + " \n"; //$NON-NLS-1$ + } + xml = xml + " \n" //$NON-NLS-1$ + " \n"; //$NON-NLS-1$ - // + " GE2020211\n" - // + " 4000001987658\n" - - xml+=getContactAsXML(trans.getRecipient()); - xml += " \n" //$NON-NLS-1$ + // + " GE2020211\n" + // + " 4000001987658\n" + + xml += getContactAsXML(trans.getRecipient()); + xml += " \n" //$NON-NLS-1$ // + " \n" // + " 20130301\n" // + " 2013-471331\n" // + " \n" + " \n" //$NON-NLS-1$ - + " \n" ; - if (this.trans.getDeliveryAddress()!=null) { - xml += ""+ - getContactAsXML(this.trans.getDeliveryAddress())+ - ""; + + " \n"; + if (this.trans.getDeliveryAddress() != null) { + xml += "" + getContactAsXML(this.trans.getDeliveryAddress()) + + ""; } - - xml+= " \n" - + " "; + + xml += " \n" + " "; if (trans.getZFDeliveryDate() != null) { ZUGFeRDDateFormat dateFormat = trans.getZFDeliveryDate().getFormat(); @@ -460,24 +468,25 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { * " \n" */ + " \n" + " \n" //$NON-NLS-2$ - + " " + XMLTools.encodeXML(trans.getNumber()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ + + " " + XMLTools.encodeXML(trans.getNumber()) //$NON-NLS-1$ + + "\n" //$NON-NLS-1$ + " " + trans.getCurrency() + "\n"; //$NON-NLS-1$ - if (trans.getTradeSettlementPayment()!=null) { + if (trans.getTradeSettlementPayment() != null) { for (IZUGFeRDTradeSettlementPayment payment : trans.getTradeSettlementPayment()) { - if(payment!=null) { - hasDueDate=true; - xml+=payment.getSettlementXML(); + if (payment != null) { + hasDueDate = true; + xml += payment.getSettlementXML(); } } } - if (trans.getTradeSettlement()!=null) { + if (trans.getTradeSettlement() != null) { for (IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) { - if(payment!=null) { + if (payment != null) { if (payment instanceof IZUGFeRDTradeSettlementPayment) { - hasDueDate=true; + hasDueDate = true; } - xml+=payment.getSettlementXML(); + xml += payment.getSettlementXML(); } } } @@ -490,9 +499,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + " " + currencyFormat(amount.getCalculated()) //$NON-NLS-1$ + "\n" //$NON-NLS-1$ //currencyID=\"EUR\" + " VAT\n" //$NON-NLS-1$ - + " " + currencyFormat(amount.getBasis()) + "\n" // currencyID=\"EUR\" - + " "+taxCategoryCode+"\n" //$NON-NLS-1$ + exemptionReason + + " " + currencyFormat(amount.getBasis()) + "\n" // currencyID=\"EUR\" + + " " + taxCategoryCode + "\n" //$NON-NLS-1$ + " " + vatFormat(currentTaxPercent) //$NON-NLS-1$ + "\n" + " \n"; //$NON-NLS-2$ @@ -500,26 +509,22 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { } xml = xml + " \n" //$NON-NLS-1$ - + " "+ - paymentTermsDescription - + "\n"; - - if (trans.getTradeSettlement()!=null) { + + " " + paymentTermsDescription + "\n"; + + if (trans.getTradeSettlement() != null) { for (IZUGFeRDTradeSettlement payment : trans.getTradeSettlement()) { - if(payment!=null) { - xml+=payment.getPaymentXML(); + if (payment != null) { + xml += payment.getPaymentXML(); } } } - if(hasDueDate) { - xml=xml+" " //$NON-NLS-2$ + if (hasDueDate) { + xml = xml + " " // $NON-NLS-2$ + zugferdDateFormat.format(trans.getDueDate()) + "\n";// 20130704 //$NON-NLS-1$ - - } - - + } + xml = xml + " \n" //$NON-NLS-1$ + " \n" //$NON-NLS-1$ + " " + currencyFormat(getTotal()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ @@ -537,10 +542,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { + " " + currencyFormat(getTotalGross()) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ // // // currencyID=\"EUR\" - + " " + currencyFormat(getTotalPrepaid()) + "\n" - + " " + currencyFormat(getTotalGross().subtract(getTotalPrepaid())) + "\n" //$NON-NLS-1$ //$NON-NLS-2$ - // // - // currencyID=\"EUR\" + + " " + currencyFormat(getTotalPrepaid()) + + "\n" + " " //$NON-NLS-2$ + + currencyFormat(getTotalGross().subtract(getTotalPrepaid())) + "\n" //$NON-NLS-1$ + // // + // currencyID=\"EUR\" + " \n" //$NON-NLS-1$ + " \n"; //$NON-NLS-1$ // + " \n"