diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 99f98180..15820835 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -33,7 +33,6 @@ import java.util.Arrays; import java.util.Base64; import java.util.Date; import java.util.List; -import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.stream.Collectors; @@ -433,30 +432,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + ""; } - String allowanceChargeStr = ""; - if (currentItem.getProduct().getAllowances() != null && currentItem.getProduct().getAllowances().length > 0) { - for (final IZUGFeRDAllowanceCharge allowance : currentItem.getProduct().getAllowances()) { - allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem); - } - } - if (currentItem.getProduct().getCharges() != null && currentItem.getProduct().getCharges().length > 0) { - for (final IZUGFeRDAllowanceCharge charge : currentItem.getProduct().getCharges()) { - allowanceChargeStr += getAllowanceChargeStr(charge, currentItem); - - } - } - - String itemTotalAllowanceChargeStr = ""; - if (currentItem.getAllowances() != null && currentItem.getAllowances().length > 0) { - for (final IZUGFeRDAllowanceCharge itemTotalAllowance : currentItem.getAllowances()) { - itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalAllowance, currentItem); - } - } - if (currentItem.getCharges() != null && currentItem.getCharges().length > 0) { - for (final IZUGFeRDAllowanceCharge itemTotalCharges : currentItem.getCharges()) { - itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalCharges, currentItem); - } - } xml += "" + XMLTools.encodeXML(currentItem.getProduct().getName()) + ""; if (currentItem.getProduct().getDescription() != null && currentItem.getProduct().getDescription().length() > 0) { @@ -464,6 +439,14 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { XMLTools.encodeXML(currentItem.getProduct().getDescription()) + ""; } + if (currentItem.getProduct().getAttributes() != null) { + for (Entry entry : currentItem.getProduct().getAttributes().entrySet()) { + xml += "" + + "" + XMLTools.encodeXML(entry.getKey()) + "" + + "" + XMLTools.encodeXML(entry.getValue()) + "" + + ""; + } + } if (currentItem.getProduct().getClassifications() != null && currentItem.getProduct().getClassifications().length > 0) { for (IDesignatedProductClassification classification : currentItem.getProduct().getClassifications()) { xml += "" @@ -478,14 +461,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += ""; } } - if (currentItem.getProduct().getAttributes() != null) { - for (Entry entry : currentItem.getProduct().getAttributes().entrySet()) { - xml += "" + - "" + XMLTools.encodeXML(entry.getKey()) + "" + - "" + XMLTools.encodeXML(entry.getValue()) + "" + - ""; - } - } if (currentItem.getProduct().getCountryOfOrigin() != null) { xml += "" + XMLTools.encodeXML(currentItem.getProduct().getCountryOfOrigin()) + @@ -516,6 +491,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += ""; } + String allowanceChargeStr = ""; + if (currentItem.getProduct().getAllowances() != null && currentItem.getProduct().getAllowances().length > 0) { + for (final IZUGFeRDAllowanceCharge allowance : currentItem.getProduct().getAllowances()) { + allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem); + } + } + if (currentItem.getProduct().getCharges() != null && currentItem.getProduct().getCharges().length > 0) { + for (final IZUGFeRDAllowanceCharge charge : currentItem.getProduct().getCharges()) { + allowanceChargeStr += getAllowanceChargeStr(charge, currentItem); + } + } if (!allowanceChargeStr.isEmpty()) { xml += "" + "" + priceFormat(lc.getPriceGross()) @@ -548,10 +534,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (currentItem.getProduct().getTaxExemptionReason() != null) { xml += "" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + ""; } - xml += "" + currentItem.getProduct().getTaxCategoryCode() + ""; + xml += "" + currentItem.getProduct().getTaxCategoryCode() + ""; if (!currentItem.getProduct().getTaxCategoryCode().equals(TaxCategoryCodeTypeConstants.UNTAXEDSERVICE)) { - xml += "" - + vatFormat(currentItem.getProduct().getVATPercent()) + ""; + xml += "" + vatFormat(currentItem.getProduct().getVATPercent()) + ""; } xml += ""; @@ -567,10 +552,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } // item charges/allowances - if (!itemTotalAllowanceChargeStr.isEmpty()) { - xml += itemTotalAllowanceChargeStr ; + String itemTotalAllowanceChargeStr = ""; + if (currentItem.getAllowances() != null && currentItem.getAllowances().length > 0) { + for (final IZUGFeRDAllowanceCharge itemTotalAllowance : currentItem.getAllowances()) { + itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalAllowance, currentItem); + } + } + if (currentItem.getCharges() != null && currentItem.getCharges().length > 0) { + for (final IZUGFeRDAllowanceCharge itemTotalCharges : currentItem.getCharges()) { + itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalCharges, currentItem); + } + } + if (!itemTotalAllowanceChargeStr.isEmpty()) { + xml += itemTotalAllowanceChargeStr ; } - xml += "" + "" + currencyFormat(lc.getItemTotalNetAmount()) + "" // currencyID=\"EUR\" @@ -597,15 +592,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + XMLTools.encodeXML(trans.getReferenceNumber()) + ""; } - xml += "" - + getTradePartyAsXML(trans.getSender(), true, false) - + "" - + ""; - // + "GE2020211" - // + "4000001987658" - - xml += getTradePartyAsXML(trans.getRecipient(), false, false); - xml += ""; + xml += "" + getTradePartyAsXML(trans.getSender(), true, false) + ""; + xml += "" + getTradePartyAsXML(trans.getRecipient(), false, false) + ""; if (trans.getSellerOrderReferencedDocumentID() != null && !trans.getSellerOrderReferencedDocumentID().trim().isEmpty()) { xml += "" @@ -642,8 +630,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (trans.getSpecifiedProcuringProjectID() != null) { xml += "" - + "" - + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + ""; + + "" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + ""; if (trans.getSpecifiedProcuringProjectName() != null) { xml += "" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectName()) + ""; } @@ -661,11 +648,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (trans.getDeliveryDate() != null) { xml += "" - + ""; - xml += DATE.udtFormat(trans.getDeliveryDate()); - xml += ""; - xml += ""; - + + "" + DATE.udtFormat(trans.getDeliveryDate()) + "" + + ""; } /* * + "" + @@ -723,8 +707,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { } final List vatAmounts = calc.getVATAmountList(); - for (final VATAmount amount : vatAmounts) - { + for (final VATAmount amount : vatAmounts) { if (amount != null) { final String amountCategoryCode = amount.getCategoryCode(); final String amountDueDateTypeCode = amount.getDueDateTypeCode(); @@ -733,7 +716,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { String exemptionReasonTextXML = ""; if ((displayExemptionReason) && (amount.getVatExemptionReasonText() != null)) { exemptionReasonTextXML = "" + XMLTools.encodeXML(amount.getVatExemptionReasonText()) + ""; - } xml += "" @@ -786,11 +768,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + ""; } - } - else - { - for (final VATAmount amount : vatAmounts) - { + } else { + for (final VATAmount amount : vatAmounts) { if (calc.getChargesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0) { xml += "" + @@ -833,13 +812,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + ""; } - } - else - { - for (final VATAmount amount : vatAmounts) - { - if (calc.getAllowancesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0) - { + } else { + for (final VATAmount amount : vatAmounts) { + if (calc.getAllowancesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0) { xml += "" + "" + "false" + @@ -955,8 +930,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + ""; - final byte[] zugferdRaw; - zugferdRaw = xml.getBytes(StandardCharsets.UTF_8); + final byte[] zugferdRaw = xml.getBytes(StandardCharsets.UTF_8); zugferdData = XMLTools.removeBOM(zugferdRaw); }