closes #917
This commit is contained in:
@@ -39,9 +39,8 @@ public class Allowance extends Charge {
|
||||
return totalAmount;
|
||||
} else if (percent!=null) {
|
||||
BigDecimal singlePrice=currentItem.getValue().multiply(BigDecimal.ONE.subtract(getPercent().divide(new BigDecimal(100))));
|
||||
// BigDecimal singlePrice=currentItem.getValue().multiply(BigDecimal.ONE.subtract(getPercent().divide(new BigDecimal(100))));
|
||||
BigDecimal singlePriceDiff=currentItem.getValue().subtract(singlePrice);
|
||||
return singlePriceDiff;
|
||||
return singlePriceDiff.multiply(currentItem.getQuantity());
|
||||
} else {
|
||||
throw new RuntimeException("percent must be set");
|
||||
}
|
||||
|
||||
@@ -145,9 +145,10 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
||||
if(totalAmount != null) {
|
||||
return totalAmount;
|
||||
} else if (percent!=null) {
|
||||
BigDecimal factor=getPercent().divide(new BigDecimal(100), 18, RoundingMode.HALF_UP);
|
||||
BigDecimal singlePrice=currentItem.getValue().multiply(factor);
|
||||
return singlePrice;
|
||||
BigDecimal singlePrice=currentItem.getValue().multiply(BigDecimal.ONE.subtract(getPercent().divide(new BigDecimal(100), 18, RoundingMode.HALF_UP)));
|
||||
BigDecimal singlePriceDiff=currentItem.getValue().subtract(singlePrice);
|
||||
return singlePriceDiff.multiply(currentItem.getQuantity());
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("percent must be set");
|
||||
}
|
||||
|
||||
@@ -203,9 +203,6 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
}
|
||||
if (amountString != null) {
|
||||
izac.setTotalAmount(new BigDecimal(amountString));
|
||||
if (percentString != null && (!percentString.equals("0"))) {
|
||||
izac.setTotalAmount(new BigDecimal(amountString).divide(getQuantity()));
|
||||
}
|
||||
}
|
||||
if (basisAmountString != null) {
|
||||
izac.setBasisAmount(new BigDecimal(basisAmountString));
|
||||
|
||||
@@ -24,4 +24,7 @@ public interface IAbsoluteValueProvider {
|
||||
|
||||
public BigDecimal getValue();
|
||||
|
||||
default BigDecimal getQuantity() {
|
||||
return BigDecimal.ONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,26 +24,17 @@ public class LineCalculator {
|
||||
|
||||
if (currentItem.getItemAllowances() != null) {
|
||||
for (IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) {
|
||||
BigDecimal factor=BigDecimal.ONE;
|
||||
BigDecimal singleAllowance=allowance.getTotalAmount(currentItem);
|
||||
addItemAllowance(singleAllowance);
|
||||
|
||||
if ((allowance.getPercent()!=null)&&(allowance.getPercent().compareTo(BigDecimal.ZERO)!=0)) {
|
||||
factor=currentItem.getQuantity();
|
||||
}
|
||||
addAllowanceItemTotal(singleAllowance.multiply(factor));
|
||||
addAllowanceItemTotal(singleAllowance);
|
||||
|
||||
}
|
||||
}
|
||||
if (currentItem.getItemCharges() != null) {
|
||||
for (IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
|
||||
BigDecimal factor=BigDecimal.ONE;
|
||||
BigDecimal singleCharge=charge.getTotalAmount(currentItem);
|
||||
addItemCharge(singleCharge);
|
||||
if ((charge.getPercent()!=null)&&(charge.getPercent().compareTo(BigDecimal.ZERO)!=0)) {
|
||||
factor=currentItem.getQuantity();
|
||||
}
|
||||
subtractAllowanceItemTotal(singleCharge.multiply(factor));
|
||||
subtractAllowanceItemTotal(singleCharge);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user