- make document charges and allowances serializable

This commit is contained in:
jstaerk
2024-10-22 15:43:01 +02:00
parent 10ccc69b9d
commit 28114e9a6b
9 changed files with 158 additions and 29 deletions

View File

@@ -1,5 +1,7 @@
package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigDecimal;
/***
@@ -28,6 +30,7 @@ public class Allowance extends Charge {
* @return false since its not supposed to be calculated negatively
*/
@Override
@JsonIgnore
public boolean isCharge() {
return false;
}

View File

@@ -1,5 +1,6 @@
package org.mustangproject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.mustangproject.ZUGFeRD.IAbsoluteValueProvider;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
@@ -151,6 +152,7 @@ public class Charge implements IZUGFeRDAllowanceCharge {
* @return true since it is supposed to be calculated negatively
*/
@Override
@JsonIgnore
public boolean isCharge() {
return true;
}

View File

@@ -522,6 +522,20 @@ public class Invoice implements IExportableTransaction {
}
}
/***
* this is wrong and only used from jackson
* @param iza
* @return
*/
public Invoice setZFAllowances(Allowance[] iza) {
Allowances=new ArrayList<>();
for (IZUGFeRDAllowanceCharge cz:iza) {
Allowances.add(cz);
}
return this;
}
@Override
public IZUGFeRDAllowanceCharge[] getZFCharges() {
@@ -532,6 +546,18 @@ public class Invoice implements IExportableTransaction {
}
}
/***
* this is wrong and only used from jackson
* @param iza
* @return
*/
public Invoice setZFCharges(Charge[] iza) {
Charges=new ArrayList<>();
for (IZUGFeRDAllowanceCharge cz:iza) {
Charges.add(cz);
}
return this;
}
@Override
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {

View File

@@ -34,9 +34,13 @@ public class LineCalculator {
}
}
BigDecimal vatPercent = currentItem.getProduct().getVATPercent();
if (vatPercent == null)
BigDecimal vatPercent = null;
if (currentItem.getProduct()!=null) {
vatPercent = currentItem.getProduct().getVATPercent();
}
if (vatPercent == null) {
vatPercent = BigDecimal.ZERO;
}
BigDecimal multiplicator = vatPercent.divide(BigDecimal.valueOf(100));
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
price = priceGross.subtract(allowance).add(charge);