add chareg/allowance percent to XML, if set
This commit is contained in:
@@ -9,7 +9,7 @@ import java.math.BigDecimal;
|
||||
|
||||
public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
|
||||
protected BigDecimal percent;
|
||||
protected BigDecimal percent = null;
|
||||
protected BigDecimal totalAmount;
|
||||
protected BigDecimal taxPercent;
|
||||
protected String reason;
|
||||
@@ -67,6 +67,7 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BigDecimal getPercent() {
|
||||
return percent;
|
||||
}
|
||||
@@ -82,6 +83,7 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Charge setCategoryCode(String categoryCode) {
|
||||
this.categoryCode = categoryCode;
|
||||
return this;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.math.BigDecimal;
|
||||
public interface IZUGFeRDAllowanceCharge {
|
||||
|
||||
BigDecimal getTotalAmount(IAbsoluteValueProvider trans);
|
||||
default BigDecimal getPercent() {return null;}
|
||||
|
||||
String getReason();
|
||||
|
||||
|
||||
@@ -96,7 +96,8 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
||||
return res;
|
||||
|
||||
}
|
||||
//move
|
||||
|
||||
//move
|
||||
protected BigDecimal getTotalPrepaid() {
|
||||
if (trans.getTotalPrepaidAmount() == null) {
|
||||
return new BigDecimal(0);
|
||||
@@ -207,6 +208,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
||||
|
||||
return hm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Profile getProfile() {
|
||||
return profile;
|
||||
@@ -273,6 +275,22 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected String getAllowanceChargeStr(IZUGFeRDAllowanceCharge allowance, IAbsoluteValueProvider item) {
|
||||
String percentage = "";
|
||||
String chargeIndicator = "false";
|
||||
if (allowance.getPercent() != null) {
|
||||
percentage = "<ram:CalculationPercent>" + allowance.getPercent() + "</ram:CalculationPercent>";
|
||||
percentage += "<ram:BasisAmount>" + item.getValue() + "</ram:BasisAmount>";
|
||||
}
|
||||
if (allowance.isCharge()) {
|
||||
chargeIndicator = "true";
|
||||
}
|
||||
|
||||
String allowanceChargeStr = "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>" + chargeIndicator + "</udt:Indicator></ram:ChargeIndicator>" + percentage + "<ram:ActualAmount>" + priceFormat(allowance.getTotalAmount(item)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||
return allowanceChargeStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(IExportableTransaction trans) {
|
||||
this.trans = trans;
|
||||
@@ -376,12 +394,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
||||
String allowanceChargeStr = "";
|
||||
if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) {
|
||||
for (IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) {
|
||||
allowanceChargeStr = "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>false</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>" + priceFormat(allowance.getTotalAmount(currentItem)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||
allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem);
|
||||
}
|
||||
}
|
||||
if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) {
|
||||
for (IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
|
||||
allowanceChargeStr += "<ram:AppliedTradeAllowanceCharge><ram:ChargeIndicator><udt:Indicator>true</udt:Indicator></ram:ChargeIndicator><ram:ActualAmount>" + priceFormat(charge.getTotalAmount(currentItem)) + "</ram:ActualAmount></ram:AppliedTradeAllowanceCharge>";
|
||||
allowanceChargeStr += getAllowanceChargeStr(charge, currentItem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user