Enhance Charges/Allowances with reasonCode.
This commit is contained in:
@@ -26,6 +26,10 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
* a simple human readable description
|
||||
*/
|
||||
protected String reason;
|
||||
/**
|
||||
* Code from list UNTDID 5189
|
||||
*/
|
||||
protected String reasonCode;
|
||||
/**
|
||||
* the category ID why this charge has been applied
|
||||
*/
|
||||
@@ -94,6 +98,22 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getReasonCode() {
|
||||
return reasonCode;
|
||||
}
|
||||
|
||||
/***
|
||||
* Reason code for the charge
|
||||
* @param reasonCode from list UNTDID 5189
|
||||
* @return fluid setter
|
||||
*/
|
||||
public Charge setReasonCode(String reasonCode) {
|
||||
this.reasonCode = reasonCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BigDecimal getTotalAmount(IAbsoluteValueProvider currentItem) {
|
||||
if (totalAmount!=null) {
|
||||
@@ -137,7 +157,7 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
|
||||
|
||||
/***
|
||||
* machine readable reason for this allowance/charge
|
||||
* the category ID why this has been applied
|
||||
* @param categoryCode usually S
|
||||
* @return fluid setter
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,12 @@ public interface IZUGFeRDAllowanceCharge {
|
||||
*/
|
||||
String getReason();
|
||||
|
||||
/***
|
||||
* get the code for the allowance/charge
|
||||
* @return the code
|
||||
*/
|
||||
String getReasonCode();
|
||||
|
||||
/***
|
||||
* get the applicable tax percentage for the allowance/charge
|
||||
* @return the percentage
|
||||
|
||||
@@ -244,10 +244,16 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
// only in extended profile
|
||||
reason = "<ram:Reason>" + XMLTools.encodeXML(allowance.getReason()) + "</ram:Reason>";
|
||||
}
|
||||
String reasonCode = "";
|
||||
if ((allowance.getReasonCode() != null) && (profile == Profiles.getByName("XRechnung"))) {
|
||||
// only in XRechnung profile
|
||||
reasonCode = "<ram:ReasonCode>" + allowance.getReasonCode() + "</ram:ReasonCode>";
|
||||
}
|
||||
final String allowanceChargeStr = "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>" +
|
||||
chargeIndicator + "</udt:Indicator></ram:ChargeIndicator>" + percentage +
|
||||
"<ram:ActualAmount>" + priceFormat(allowance.getTotalAmount(item)) + "</ram:ActualAmount>" +
|
||||
reason +
|
||||
reasonCode +
|
||||
"</ram:AppliedTradeAllowanceCharge>";
|
||||
return allowanceChargeStr;
|
||||
}
|
||||
@@ -269,10 +275,21 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
chargeIndicator = "true";
|
||||
}
|
||||
|
||||
String reason = "";
|
||||
if ((allowance.getReason() != null) && (profile == Profiles.getByName("Extended"))) {
|
||||
// only in extended profile
|
||||
reason = "<ram:Reason>" + XMLTools.encodeXML(allowance.getReason()) + "</ram:Reason>";
|
||||
}
|
||||
String reasonCode = "";
|
||||
if ((allowance.getReasonCode() != null) && (profile == Profiles.getByName("XRechnung"))) {
|
||||
// only in XRechnung profile
|
||||
reasonCode = "<ram:ReasonCode>" + allowance.getReasonCode() + "</ram:ReasonCode>";
|
||||
}
|
||||
final String itemTotalAllowanceChargeStr = "<ram:SpecifiedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>" +
|
||||
chargeIndicator + "</udt:Indicator></ram:ChargeIndicator>" + percentage +
|
||||
"<ram:ActualAmount>" + currencyFormat(allowance.getTotalAmount(item)) + "</ram:ActualAmount>" +
|
||||
"<ram:Reason>" + XMLTools.encodeXML(allowance.getReason()) + "</ram:Reason>" +
|
||||
reason +
|
||||
reasonCode +
|
||||
"</ram:SpecifiedTradeAllowanceCharge>";
|
||||
return itemTotalAllowanceChargeStr;
|
||||
}
|
||||
@@ -645,7 +662,29 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
}
|
||||
|
||||
if ((trans.getZFCharges() != null) && (trans.getZFCharges().length > 0)) {
|
||||
|
||||
if (profile == Profiles.getByName("XRechnung")) {
|
||||
for(IZUGFeRDAllowanceCharge charge : trans.getZFCharges()) {
|
||||
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
||||
"<ram:ChargeIndicator>" +
|
||||
"<udt:Indicator>true</udt:Indicator>" +
|
||||
"</ram:ChargeIndicator>" +
|
||||
"<ram:ActualAmount>" + currencyFormat(charge.getTotalAmount(calc)) + "</ram:ActualAmount>";
|
||||
if (charge.getReason() != null) {
|
||||
xml += "<ram:Reason>" + XMLTools.encodeXML(charge.getReason()) + "</ram:Reason>";
|
||||
}
|
||||
if (charge.getReasonCode() != null) {
|
||||
xml += "<ram:ReasonCode>" + charge.getReasonCode() + "</ram:ReasonCode>";
|
||||
}
|
||||
xml += "<ram:CategoryTradeTax>" +
|
||||
"<ram:TypeCode>VAT</ram:TypeCode>" +
|
||||
"<ram:CategoryCode>" + charge.getCategoryCode() + "</ram:CategoryCode>";
|
||||
if (charge.getTaxPercent() != null) {
|
||||
xml += "<ram:RateApplicablePercent>" + vatFormat(charge.getTaxPercent()) + "</ram:RateApplicablePercent>";
|
||||
}
|
||||
xml += "</ram:CategoryTradeTax>" +
|
||||
"</ram:SpecifiedTradeAllowanceCharge>";
|
||||
}
|
||||
} else {
|
||||
for (final BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
||||
if (calc.getChargesForPercent(currentTaxPercent).compareTo(BigDecimal.ZERO) != 0) {
|
||||
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
||||
@@ -663,8 +702,32 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((trans.getZFAllowances() != null) && (trans.getZFAllowances().length > 0)) {
|
||||
if (profile == Profiles.getByName("XRechnung")) {
|
||||
for(IZUGFeRDAllowanceCharge allowance : trans.getZFAllowances()) {
|
||||
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
||||
"<ram:ChargeIndicator>" +
|
||||
"<udt:Indicator>false</udt:Indicator>" +
|
||||
"</ram:ChargeIndicator>" +
|
||||
"<ram:ActualAmount>" + currencyFormat(allowance.getTotalAmount(calc)) + "</ram:ActualAmount>";
|
||||
if (allowance.getReason() != null) {
|
||||
xml += "<ram:Reason>" + XMLTools.encodeXML(allowance.getReason()) + "</ram:Reason>";
|
||||
}
|
||||
if (allowance.getReasonCode() != null) {
|
||||
xml += "<ram:ReasonCode>" + allowance.getReasonCode() + "</ram:ReasonCode>";
|
||||
}
|
||||
xml += "<ram:CategoryTradeTax>" +
|
||||
"<ram:TypeCode>VAT</ram:TypeCode>" +
|
||||
"<ram:CategoryCode>" + allowance.getCategoryCode() + "</ram:CategoryCode>";
|
||||
if (allowance.getTaxPercent() != null) {
|
||||
xml += "<ram:RateApplicablePercent>" + vatFormat(allowance.getTaxPercent()) + "</ram:RateApplicablePercent>";
|
||||
}
|
||||
xml += "</ram:CategoryTradeTax>" +
|
||||
"</ram:SpecifiedTradeAllowanceCharge>";
|
||||
}
|
||||
} else {
|
||||
for (final BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
||||
if (calc.getAllowancesForPercent(currentTaxPercent).compareTo(BigDecimal.ZERO) != 0) {
|
||||
xml += "<ram:SpecifiedTradeAllowanceCharge>" +
|
||||
@@ -682,6 +745,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((trans.getPaymentTerms() == null) && (getProfile() != Profiles.getByName("Minimum")) && ((paymentTermsDescription != null) || (trans.getTradeSettlement() != null) || (hasDueDate))) {
|
||||
|
||||
@@ -357,6 +357,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||
boolean isCharge = true;
|
||||
String chargeAmount = null;
|
||||
String reason = null;
|
||||
String reasonCode = null;
|
||||
String taxPercent = null;
|
||||
for (int chargeChildIndex = 0; chargeChildIndex < chargeNodeChilds.getLength(); chargeChildIndex++) {
|
||||
String chargeChildName = chargeNodeChilds.item(chargeChildIndex).getLocalName();
|
||||
@@ -377,6 +378,8 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||
chargeAmount = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
||||
} else if (chargeChildName.equals("Reason")) {
|
||||
reason = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
||||
} else if (chargeChildName.equals("ReasonCode")) {
|
||||
reasonCode = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
||||
} else if (chargeChildName.equals("CategoryTradeTax")) {
|
||||
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
||||
@@ -395,16 +398,21 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||
if (reason != null) {
|
||||
c.setReason(reason);
|
||||
}
|
||||
if (reasonCode != null) {
|
||||
c.setReasonCode(reasonCode);
|
||||
}
|
||||
if (taxPercent != null) {
|
||||
c.setTaxPercent(new BigDecimal(taxPercent));
|
||||
}
|
||||
|
||||
zpp.addCharge(c);
|
||||
} else {
|
||||
Allowance a = new Allowance(new BigDecimal(chargeAmount));
|
||||
if (reason != null) {
|
||||
a.setReason(reason);
|
||||
}
|
||||
if (reasonCode != null) {
|
||||
a.setReasonCode(reasonCode);
|
||||
}
|
||||
if (taxPercent != null) {
|
||||
a.setTaxPercent(new BigDecimal(taxPercent));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
||||
public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
||||
private BigDecimal totalAmount;
|
||||
private String reason;
|
||||
private String reasonCode;
|
||||
private BigDecimal taxPercent;
|
||||
boolean isCharge=true;
|
||||
|
||||
@@ -36,6 +37,11 @@ public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
||||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReasonCode() {
|
||||
return reasonCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTaxPercent() {
|
||||
return taxPercent;
|
||||
@@ -61,6 +67,11 @@ public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
||||
return this;
|
||||
}
|
||||
|
||||
public IZUGFeRDAllowanceChargeImpl setReasonCode(String reasonCode) {
|
||||
this.reasonCode = reasonCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IZUGFeRDAllowanceChargeImpl setTaxPercent(BigDecimal taxPercent) {
|
||||
this.taxPercent = taxPercent;
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user