diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java index 28c390ac..87ffb274 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRD2PullProvider.java @@ -436,35 +436,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml += "" + XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + ""; } - String allowanceChargeStr = ""; - if (currentItem.getProduct().getAllowances() != null) { - for (final IZUGFeRDAllowanceCharge allowance : currentItem.getProduct().getAllowances()) { - allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem); - } - } - if (currentItem.getProduct().getCharges() != null) { - for (final IZUGFeRDAllowanceCharge charge : currentItem.getProduct().getCharges()) { - allowanceChargeStr += getAllowanceChargeStr(charge, currentItem); - - } - } - - String itemTotalAllowanceChargeStr = ""; - if (currentItem.getAllowances() != null) { - for (final IZUGFeRDAllowanceCharge itemTotalAllowance : currentItem.getAllowances()) { - itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalAllowance, currentItem); - } - } - if (currentItem.getCharges() != null) { - for (final IZUGFeRDAllowanceCharge itemTotalCharges : currentItem.getCharges()) { - itemTotalAllowanceChargeStr += getItemTotalAllowanceChargeStr(itemTotalCharges, currentItem); - } - } xml += "" + XMLTools.encodeXML(currentItem.getProduct().getName()) + ""; if (currentItem.getProduct().getDescription() != null && !currentItem.getProduct().getDescription().isEmpty()) { xml += "" + 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) { for (IDesignatedProductClassification classification : currentItem.getProduct().getClassifications()) { xml += "" @@ -479,14 +464,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()) + @@ -517,6 +494,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()) @@ -549,10 +537,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 += ""; @@ -568,10 +555,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\" @@ -598,15 +595,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 += "" @@ -643,8 +633,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()) + ""; } @@ -662,11 +651,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { if (trans.getDeliveryDate() != null) { xml += "" - + ""; - xml += DATE.udtFormat(trans.getDeliveryDate()); - xml += ""; - xml += ""; - + + "" + DATE.udtFormat(trans.getDeliveryDate()) + "" + + ""; } /* * + "" + @@ -725,8 +711,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(); @@ -735,7 +720,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { String exemptionReasonTextXML = ""; if ((displayExemptionReason) && (amount.getVatExemptionReasonText() != null)) { exemptionReasonTextXML = "" + XMLTools.encodeXML(amount.getVatExemptionReasonText()) + ""; - } xml += "" @@ -788,11 +772,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 += "" + @@ -835,13 +816,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" + @@ -957,8 +934,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); }