Relative charges/allowances on document level

This commit is contained in:
Jochen Stärk
2020-10-08 14:51:33 +02:00
parent 66fd7b4316
commit 44c6509504
11 changed files with 131 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
package org.mustangproject;
import org.mustangproject.ZUGFeRD.IAbsoluteValueProvider;
import org.mustangproject.ZUGFeRD.IExportableTransaction;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
@@ -55,27 +56,16 @@ public class Charge implements IZUGFeRDAllowanceCharge {
@Override
public BigDecimal getTotalAmount(IZUGFeRDExportableItem currentItem) {
public BigDecimal getTotalAmount(IAbsoluteValueProvider currentItem) {
if (totalAmount!=null) {
return totalAmount;
} else if (percent!=null) {
return currentItem.getPrice().multiply(getPercent().divide(new BigDecimal(100)));
return currentItem.getValue().multiply(getPercent().divide(new BigDecimal(100)));
} else {
throw new RuntimeException("Either totalAmount or percent must be set");
}
}
@Override
public BigDecimal getTotalAmount(IExportableTransaction currentTrans) {
// if (totalAmount!=null) {
return totalAmount;
// } else //if (percent!=null) {
// to be implemented return currentItem.get().multiply(getPercent().divide(new BigDecimal(100)));
//} else {
// throw new RuntimeException("Either totalAmount or percent must be set");
// }
}
public BigDecimal getPercent() {
return percent;