distinguish in writing between item and product discounts/charges
This commit is contained in:
@@ -295,6 +295,16 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public IZUGFeRDAllowanceCharge[] getAllowances() {
|
||||
IZUGFeRDAllowanceCharge[] izac=new IZUGFeRDAllowanceCharge[Allowances.size()];
|
||||
return Allowances.toArray(izac);
|
||||
}
|
||||
|
||||
@Override public IZUGFeRDAllowanceCharge[] getCharges() {
|
||||
IZUGFeRDAllowanceCharge[] izac=new IZUGFeRDAllowanceCharge[Charges.size()];
|
||||
return Charges.toArray(izac);
|
||||
}
|
||||
|
||||
/***
|
||||
* BT 132 (issue https://github.com/ZUGFeRD/mustangproject/issues/247)
|
||||
* @return the line ID of the order (BT132)
|
||||
@@ -468,6 +478,7 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
* @return fluent setter
|
||||
*/
|
||||
public Item addAllowance(IZUGFeRDAllowanceCharge izac) {
|
||||
|
||||
Allowances.add(izac);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class LineCalculator {
|
||||
if ((allowance.getPercent()!=null)&&(allowance.getPercent().compareTo(BigDecimal.ZERO)!=0)) {
|
||||
factor=currentItem.getQuantity();
|
||||
}
|
||||
addLineAllowance(singleAllowance.multiply(factor));
|
||||
addAllowanceItemTotal(singleAllowance.multiply(factor));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class LineCalculator {
|
||||
if ((charge.getPercent()!=null)&&(charge.getPercent().compareTo(BigDecimal.ZERO)!=0)) {
|
||||
factor=currentItem.getQuantity();
|
||||
}
|
||||
addLineCharge(singleCharge.multiply(factor));
|
||||
subtractAllowanceItemTotal(singleCharge.multiply(factor));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class LineCalculator {
|
||||
|
||||
price=currentItem.getPrice();
|
||||
priceGross=price;
|
||||
price=price.subtract(itemAllowance).add(itemCharge);
|
||||
// price=price.subtract(itemAllowance).add(itemCharge);
|
||||
// BigDecimal delta=charge.subtract(allowanceItemTotal).subtract(allowance);
|
||||
// delta=delta.divide(currentItem.getQuantity(), 18, RoundingMode.HALF_UP);
|
||||
|
||||
@@ -91,8 +91,8 @@ public class LineCalculator {
|
||||
BigDecimal basisQuantity = currentItem.getBasisQuantity().compareTo(BigDecimal.ZERO) == 0
|
||||
? BigDecimal.ONE.setScale(4)
|
||||
: currentItem.getBasisQuantity();
|
||||
itemTotalNetAmount = quantity.multiply(priceGross).divide(basisQuantity, 18, RoundingMode.HALF_UP)
|
||||
.add(lineCharge).subtract(lineAllowance).setScale(2, RoundingMode.HALF_UP);
|
||||
itemTotalNetAmount = quantity.multiply(price).divide(basisQuantity, 18, RoundingMode.HALF_UP)
|
||||
.add(lineCharge).subtract(lineAllowance).subtract(allowanceItemTotal).setScale(2, RoundingMode.HALF_UP);
|
||||
itemTotalVATAmount = itemTotalNetAmount.multiply(multiplicator);
|
||||
}
|
||||
|
||||
@@ -135,5 +135,8 @@ public class LineCalculator {
|
||||
public void addAllowanceItemTotal(BigDecimal b) {
|
||||
allowanceItemTotal = allowanceItemTotal.add(b);
|
||||
}
|
||||
public void subtractAllowanceItemTotal(BigDecimal b) {
|
||||
allowanceItemTotal = allowanceItemTotal.subtract(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -432,24 +432,29 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ XMLTools.encodeXML(currentItem.getProduct().getBuyerAssignedID()) + "</ram:BuyerAssignedID>";
|
||||
}
|
||||
String allowanceChargeStr = "";
|
||||
if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) {
|
||||
for (final IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) {
|
||||
if (currentItem.getProduct().getAllowances() != null && currentItem.getProduct().getAllowances().length > 0) {
|
||||
for (final IZUGFeRDAllowanceCharge allowance : currentItem.getProduct().getAllowances()) {
|
||||
allowanceChargeStr += getAllowanceChargeStr(allowance, currentItem);
|
||||
}
|
||||
}
|
||||
if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) {
|
||||
for (final IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
|
||||
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.getItemTotalAllowances() != null && currentItem.getItemTotalAllowances().length > 0) {
|
||||
for (final IZUGFeRDAllowanceCharge itemTotalAllowance : currentItem.getItemTotalAllowances()) {
|
||||
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 += "<ram:Name>" + XMLTools.encodeXML(currentItem.getProduct().getName()) + "</ram:Name>";
|
||||
if (currentItem.getProduct().getDescription() != null && currentItem.getProduct().getDescription().length() > 0) {
|
||||
@@ -540,6 +545,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
+ "<ram:RateApplicablePercent>"
|
||||
+ vatFormat(currentItem.getProduct().getVATPercent()) + "</ram:RateApplicablePercent>"
|
||||
+ "</ram:ApplicableTradeTax>";
|
||||
// item charges/allowances
|
||||
if (!itemTotalAllowanceChargeStr.isEmpty()) {
|
||||
xml += "<ram:SpecifiedTradeAllowanceCharge>"+ itemTotalAllowanceChargeStr +"</ram:SpecifiedTradeAllowanceCharge>";
|
||||
}
|
||||
|
||||
if ((currentItem.getDetailedDeliveryPeriodFrom() != null) || (currentItem.getDetailedDeliveryPeriodTo() != null)) {
|
||||
xml += "<ram:BillingSpecifiedPeriod>";
|
||||
if (currentItem.getDetailedDeliveryPeriodFrom() != null) {
|
||||
@@ -551,7 +561,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||
xml += "</ram:BillingSpecifiedPeriod>";
|
||||
}
|
||||
|
||||
xml += itemTotalAllowanceChargeStr;
|
||||
|
||||
xml += "<ram:SpecifiedTradeSettlementLineMonetarySummation>"
|
||||
+ "<ram:LineTotalAmount>" + currencyFormat(lc.getItemTotalNetAmount())
|
||||
|
||||
Reference in New Issue
Block a user