corrected calculation
This commit is contained in:
@@ -3,8 +3,10 @@ package org.mustangproject;
|
|||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import org.mustangproject.ZUGFeRD.IAbsoluteValueProvider;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* (absolute) allowances on item and document level
|
* (absolute) allowances on item and document level
|
||||||
@@ -29,6 +31,22 @@ public class Allowance extends Charge {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal getTotalAmount(IAbsoluteValueProvider currentItem) {
|
||||||
|
if(totalAmount != null) {
|
||||||
|
return totalAmount;
|
||||||
|
} else if (percent!=null) {
|
||||||
|
BigDecimal singlePrice=currentItem.getValue().divide(BigDecimal.ONE.add(getPercent().divide(new BigDecimal(100))), 18, RoundingMode.HALF_UP);
|
||||||
|
// BigDecimal singlePrice=currentItem.getValue().multiply(BigDecimal.ONE.subtract(getPercent().divide(new BigDecimal(100))));
|
||||||
|
BigDecimal singlePriceDiff=currentItem.getValue().subtract(singlePrice);
|
||||||
|
return singlePriceDiff;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("percent must be set");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Always to return false for IZUGFeRDAllowanceCharge
|
* Always to return false for IZUGFeRDAllowanceCharge
|
||||||
* @return false since its not supposed to be calculated negatively
|
* @return false since its not supposed to be calculated negatively
|
||||||
|
|||||||
@@ -145,9 +145,9 @@ public class Charge implements IZUGFeRDAllowanceCharge {
|
|||||||
if(totalAmount != null) {
|
if(totalAmount != null) {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
} else if (percent!=null) {
|
} else if (percent!=null) {
|
||||||
// BigDecimal singlePrice=currentItem.getValue().divide(BigDecimal.ONE.add(getPercent().divide(new BigDecimal(100))), 18, RoundingMode.HALF_UP);
|
BigDecimal singlePrice=currentItem.getValue().divide(BigDecimal.ONE.add(getPercent().divide(new BigDecimal(100))), 18, RoundingMode.HALF_UP);
|
||||||
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);
|
BigDecimal singlePriceDiff=currentItem.getValue().add(singlePrice);
|
||||||
return singlePriceDiff;
|
return singlePriceDiff;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("percent must be set");
|
throw new RuntimeException("percent must be set");
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class LineCalculator {
|
|||||||
: currentItem.getBasisQuantity();
|
: currentItem.getBasisQuantity();
|
||||||
itemTotalNetAmount = quantity.multiply(price).divide(basisQuantity, 18, RoundingMode.HALF_UP)
|
itemTotalNetAmount = quantity.multiply(price).divide(basisQuantity, 18, RoundingMode.HALF_UP)
|
||||||
.add(lineCharge).subtract(lineAllowance).subtract(allowanceItemTotal).setScale(2, RoundingMode.HALF_UP);
|
.add(lineCharge).subtract(lineAllowance).subtract(allowanceItemTotal).setScale(2, RoundingMode.HALF_UP);
|
||||||
itemTotalVATAmount = itemTotalNetAmount.multiply(multiplicator);
|
itemTotalVATAmount = itemTotalNetAmount.multiply(multiplicator).setScale(2, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getPrice() {
|
public BigDecimal getPrice() {
|
||||||
|
|||||||
Reference in New Issue
Block a user