Merge pull request #882 from langfr/bugfix/issue841b
Change order of ApplicableProductCharacteristic and DesignatedProduct…
This commit is contained in:
@@ -436,35 +436,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "<ram:BuyerAssignedID>"
|
xml += "<ram:BuyerAssignedID>"
|
||||||
+ XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + "</ram:BuyerAssignedID>";
|
+ XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + "</ram:BuyerAssignedID>";
|
||||||
}
|
}
|
||||||
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 += "<ram:Name>" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "</ram:Name>";
|
xml += "<ram:Name>" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "</ram:Name>";
|
||||||
if (currentItem.getProduct().getDescription() != null && !currentItem.getProduct().getDescription().isEmpty()) {
|
if (currentItem.getProduct().getDescription() != null && !currentItem.getProduct().getDescription().isEmpty()) {
|
||||||
xml += "<ram:Description>" + XMLTools.encodeXML(currentItem.getProduct().getDescription()) + "</ram:Description>";
|
xml += "<ram:Description>" + XMLTools.encodeXML(currentItem.getProduct().getDescription()) + "</ram:Description>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentItem.getProduct().getAttributes() != null) {
|
||||||
|
for (Entry<String, String> entry : currentItem.getProduct().getAttributes().entrySet()) {
|
||||||
|
xml += "<ram:ApplicableProductCharacteristic>" +
|
||||||
|
"<ram:Description>" + XMLTools.encodeXML(entry.getKey()) + "</ram:Description>" +
|
||||||
|
"<ram:Value>" + XMLTools.encodeXML(entry.getValue()) + "</ram:Value>" +
|
||||||
|
"</ram:ApplicableProductCharacteristic>";
|
||||||
|
}
|
||||||
|
}
|
||||||
if (currentItem.getProduct().getClassifications() != null) {
|
if (currentItem.getProduct().getClassifications() != null) {
|
||||||
for (IDesignatedProductClassification classification : currentItem.getProduct().getClassifications()) {
|
for (IDesignatedProductClassification classification : currentItem.getProduct().getClassifications()) {
|
||||||
xml += "<ram:DesignatedProductClassification>"
|
xml += "<ram:DesignatedProductClassification>"
|
||||||
@@ -479,14 +464,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "</ram:DesignatedProductClassification>";
|
xml += "</ram:DesignatedProductClassification>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentItem.getProduct().getAttributes() != null) {
|
|
||||||
for (Entry<String, String> entry : currentItem.getProduct().getAttributes().entrySet()) {
|
|
||||||
xml += "<ram:ApplicableProductCharacteristic>" +
|
|
||||||
"<ram:Description>" + XMLTools.encodeXML(entry.getKey()) + "</ram:Description>" +
|
|
||||||
"<ram:Value>" + XMLTools.encodeXML(entry.getValue()) + "</ram:Value>" +
|
|
||||||
"</ram:ApplicableProductCharacteristic>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentItem.getProduct().getCountryOfOrigin() != null) {
|
if (currentItem.getProduct().getCountryOfOrigin() != null) {
|
||||||
xml += "<ram:OriginTradeCountry><ram:ID>" +
|
xml += "<ram:OriginTradeCountry><ram:ID>" +
|
||||||
XMLTools.encodeXML(currentItem.getProduct().getCountryOfOrigin()) +
|
XMLTools.encodeXML(currentItem.getProduct().getCountryOfOrigin()) +
|
||||||
@@ -517,6 +494,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "</ram:BuyerOrderReferencedDocument>";
|
xml += "</ram:BuyerOrderReferencedDocument>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()) {
|
if (!allowanceChargeStr.isEmpty()) {
|
||||||
xml += "<ram:GrossPriceProductTradePrice>"
|
xml += "<ram:GrossPriceProductTradePrice>"
|
||||||
+ "<ram:ChargeAmount>" + priceFormat(lc.getPriceGross())
|
+ "<ram:ChargeAmount>" + priceFormat(lc.getPriceGross())
|
||||||
@@ -549,10 +537,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
if (currentItem.getProduct().getTaxExemptionReason() != null) {
|
if (currentItem.getProduct().getTaxExemptionReason() != null) {
|
||||||
xml += "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
|
xml += "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
|
||||||
}
|
}
|
||||||
xml += "<ram:CategoryCode>" + currentItem.getProduct().getTaxCategoryCode() + "</ram:CategoryCode>";
|
xml += "<ram:CategoryCode>" + currentItem.getProduct().getTaxCategoryCode() + "</ram:CategoryCode>";
|
||||||
if (!currentItem.getProduct().getTaxCategoryCode().equals(TaxCategoryCodeTypeConstants.UNTAXEDSERVICE)) {
|
if (!currentItem.getProduct().getTaxCategoryCode().equals(TaxCategoryCodeTypeConstants.UNTAXEDSERVICE)) {
|
||||||
xml += "<ram:RateApplicablePercent>"
|
xml += "<ram:RateApplicablePercent>" + vatFormat(currentItem.getProduct().getVATPercent()) + "</ram:RateApplicablePercent>";
|
||||||
+ vatFormat(currentItem.getProduct().getVATPercent()) + "</ram:RateApplicablePercent>";
|
|
||||||
}
|
}
|
||||||
xml += "</ram:ApplicableTradeTax>";
|
xml += "</ram:ApplicableTradeTax>";
|
||||||
|
|
||||||
@@ -568,10 +555,20 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// item charges/allowances
|
// item charges/allowances
|
||||||
if (!itemTotalAllowanceChargeStr.isEmpty()) {
|
String itemTotalAllowanceChargeStr = "";
|
||||||
xml += 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 += "<ram:SpecifiedTradeSettlementLineMonetarySummation>"
|
xml += "<ram:SpecifiedTradeSettlementLineMonetarySummation>"
|
||||||
+ "<ram:LineTotalAmount>" + currencyFormat(lc.getItemTotalNetAmount())
|
+ "<ram:LineTotalAmount>" + currencyFormat(lc.getItemTotalNetAmount())
|
||||||
+ "</ram:LineTotalAmount>" // currencyID=\"EUR\"
|
+ "</ram:LineTotalAmount>" // currencyID=\"EUR\"
|
||||||
@@ -598,15 +595,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "<ram:BuyerReference>" + XMLTools.encodeXML(trans.getReferenceNumber()) + "</ram:BuyerReference>";
|
xml += "<ram:BuyerReference>" + XMLTools.encodeXML(trans.getReferenceNumber()) + "</ram:BuyerReference>";
|
||||||
|
|
||||||
}
|
}
|
||||||
xml += "<ram:SellerTradeParty>"
|
xml += "<ram:SellerTradeParty>" + getTradePartyAsXML(trans.getSender(), true, false) + "</ram:SellerTradeParty>";
|
||||||
+ getTradePartyAsXML(trans.getSender(), true, false)
|
xml += "<ram:BuyerTradeParty>" + getTradePartyAsXML(trans.getRecipient(), false, false) + "</ram:BuyerTradeParty>";
|
||||||
+ "</ram:SellerTradeParty>"
|
|
||||||
+ "<ram:BuyerTradeParty>";
|
|
||||||
// + "<ID>GE2020211</ID>"
|
|
||||||
// + "<GlobalID schemeID=\"0088\">4000001987658</GlobalID>"
|
|
||||||
|
|
||||||
xml += getTradePartyAsXML(trans.getRecipient(), false, false);
|
|
||||||
xml += "</ram:BuyerTradeParty>";
|
|
||||||
|
|
||||||
if (trans.getSellerOrderReferencedDocumentID() != null && !trans.getSellerOrderReferencedDocumentID().trim().isEmpty()) {
|
if (trans.getSellerOrderReferencedDocumentID() != null && !trans.getSellerOrderReferencedDocumentID().trim().isEmpty()) {
|
||||||
xml += "<ram:SellerOrderReferencedDocument>"
|
xml += "<ram:SellerOrderReferencedDocument>"
|
||||||
@@ -643,8 +633,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
if (trans.getSpecifiedProcuringProjectID() != null) {
|
if (trans.getSpecifiedProcuringProjectID() != null) {
|
||||||
xml += "<ram:SpecifiedProcuringProject>"
|
xml += "<ram:SpecifiedProcuringProject>"
|
||||||
+ "<ram:ID>"
|
+ "<ram:ID>" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + "</ram:ID>";
|
||||||
+ XMLTools.encodeXML(trans.getSpecifiedProcuringProjectID()) + "</ram:ID>";
|
|
||||||
if (trans.getSpecifiedProcuringProjectName() != null) {
|
if (trans.getSpecifiedProcuringProjectName() != null) {
|
||||||
xml += "<ram:Name>" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectName()) + "</ram:Name>";
|
xml += "<ram:Name>" + XMLTools.encodeXML(trans.getSpecifiedProcuringProjectName()) + "</ram:Name>";
|
||||||
}
|
}
|
||||||
@@ -662,11 +651,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
if (trans.getDeliveryDate() != null) {
|
if (trans.getDeliveryDate() != null) {
|
||||||
xml += "<ram:ActualDeliverySupplyChainEvent>"
|
xml += "<ram:ActualDeliverySupplyChainEvent>"
|
||||||
+ "<ram:OccurrenceDateTime>";
|
+ "<ram:OccurrenceDateTime>" + DATE.udtFormat(trans.getDeliveryDate()) + "</ram:OccurrenceDateTime>"
|
||||||
xml += DATE.udtFormat(trans.getDeliveryDate());
|
+ "</ram:ActualDeliverySupplyChainEvent>";
|
||||||
xml += "</ram:OccurrenceDateTime>";
|
|
||||||
xml += "</ram:ActualDeliverySupplyChainEvent>";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* + "<DeliveryNoteReferencedDocument>" +
|
* + "<DeliveryNoteReferencedDocument>" +
|
||||||
@@ -725,8 +711,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<VATAmount> vatAmounts = calc.getVATAmountList();
|
final List<VATAmount> vatAmounts = calc.getVATAmountList();
|
||||||
for (final VATAmount amount : vatAmounts)
|
for (final VATAmount amount : vatAmounts) {
|
||||||
{
|
|
||||||
if (amount != null) {
|
if (amount != null) {
|
||||||
final String amountCategoryCode = amount.getCategoryCode();
|
final String amountCategoryCode = amount.getCategoryCode();
|
||||||
final String amountDueDateTypeCode = amount.getDueDateTypeCode();
|
final String amountDueDateTypeCode = amount.getDueDateTypeCode();
|
||||||
@@ -735,7 +720,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
String exemptionReasonTextXML = "";
|
String exemptionReasonTextXML = "";
|
||||||
if ((displayExemptionReason) && (amount.getVatExemptionReasonText() != null)) {
|
if ((displayExemptionReason) && (amount.getVatExemptionReasonText() != null)) {
|
||||||
exemptionReasonTextXML = "<ram:ExemptionReason>" + XMLTools.encodeXML(amount.getVatExemptionReasonText()) + "</ram:ExemptionReason>";
|
exemptionReasonTextXML = "<ram:ExemptionReason>" + XMLTools.encodeXML(amount.getVatExemptionReasonText()) + "</ram:ExemptionReason>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xml += "<ram:ApplicableTradeTax>"
|
xml += "<ram:ApplicableTradeTax>"
|
||||||
@@ -788,11 +772,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "</ram:CategoryTradeTax>" +
|
xml += "</ram:CategoryTradeTax>" +
|
||||||
"</ram:SpecifiedTradeAllowanceCharge>";
|
"</ram:SpecifiedTradeAllowanceCharge>";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (final VATAmount amount : vatAmounts) {
|
||||||
{
|
|
||||||
for (final VATAmount amount : vatAmounts)
|
|
||||||
{
|
|
||||||
if (calc.getChargesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0)
|
if (calc.getChargesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0)
|
||||||
{
|
{
|
||||||
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
||||||
@@ -835,13 +816,9 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "</ram:CategoryTradeTax>" +
|
xml += "</ram:CategoryTradeTax>" +
|
||||||
"</ram:SpecifiedTradeAllowanceCharge>";
|
"</ram:SpecifiedTradeAllowanceCharge>";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (final VATAmount amount : vatAmounts) {
|
||||||
{
|
if (calc.getAllowancesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0) {
|
||||||
for (final VATAmount amount : vatAmounts)
|
|
||||||
{
|
|
||||||
if (calc.getAllowancesForPercent(amount.getApplicablePercent()).compareTo(BigDecimal.ZERO) != 0)
|
|
||||||
{
|
|
||||||
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
||||||
"<ram:ChargeIndicator>" +
|
"<ram:ChargeIndicator>" +
|
||||||
"<udt:Indicator>false</udt:Indicator>" +
|
"<udt:Indicator>false</udt:Indicator>" +
|
||||||
@@ -957,8 +934,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
xml += "</rsm:SupplyChainTradeTransaction>"
|
xml += "</rsm:SupplyChainTradeTransaction>"
|
||||||
+ "</rsm:CrossIndustryInvoice>";
|
+ "</rsm:CrossIndustryInvoice>";
|
||||||
|
|
||||||
final byte[] zugferdRaw;
|
final byte[] zugferdRaw = xml.getBytes(StandardCharsets.UTF_8);
|
||||||
zugferdRaw = xml.getBytes(StandardCharsets.UTF_8);
|
|
||||||
|
|
||||||
zugferdData = XMLTools.removeBOM(zugferdRaw);
|
zugferdData = XMLTools.removeBOM(zugferdRaw);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user