added a test, working on percents

This commit is contained in:
jstaerk
2025-05-06 13:32:34 +02:00
parent 9e77433a13
commit cbcdaaec0e
3 changed files with 47 additions and 3 deletions

View File

@@ -124,7 +124,9 @@ public class Charge implements IZUGFeRDAllowanceCharge {
if(totalAmount != null) {
return totalAmount;
} else if (percent!=null) {
return currentItem.getValue().multiply(getPercent().divide(new BigDecimal(100)));
BigDecimal singlePrice=currentItem.getValue().divide(BigDecimal.ONE.add(getPercent().divide(new BigDecimal(100))));
BigDecimal singlePriceDiff=currentItem.getValue().subtract(singlePrice);
return singlePriceDiff;
} else {
throw new RuntimeException("percent must be set");
}

View File

@@ -20,12 +20,14 @@ public class LineCalculator {
if (currentItem.getItemAllowances() != null && currentItem.getItemAllowances().length > 0) {
for (IZUGFeRDAllowanceCharge allowance : currentItem.getItemAllowances()) {
addAllowance(allowance.getTotalAmount(currentItem));
BigDecimal singleAllowance=allowance.getTotalAmount(currentItem);
addAllowance(singleAllowance.multiply(currentItem.getQuantity()));
}
}
if (currentItem.getItemCharges() != null && currentItem.getItemCharges().length > 0) {
for (IZUGFeRDAllowanceCharge charge : currentItem.getItemCharges()) {
addCharge(charge.getTotalAmount(currentItem));
BigDecimal singleCharge=charge.getTotalAmount(currentItem);
addCharge(singleCharge.multiply(currentItem.getQuantity()));
}
}
if (currentItem.getItemTotalAllowances() != null && currentItem.getItemTotalAllowances().length > 0) {