- make Line Calculation, e.g. total line net amount, accessible via JSON using getCalculation

This commit is contained in:
jstaerk
2025-09-30 19:44:02 +02:00
parent cae963a1ca
commit ec5bbfdc5c
12 changed files with 179 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import org.mustangproject.ZUGFeRD.IReferencedDocument;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
import org.mustangproject.ZUGFeRD.LineCalculator;
import org.mustangproject.util.NodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

View File

@@ -79,7 +79,7 @@ public class DAPullProvider extends ZUGFeRD2PullProvider {
if (currentItem.getProduct().getTaxExemptionReason() != null) {
// exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
}
final LineCalculator lc = new LineCalculator(currentItem);
final LineCalculator lc = currentItem.getCalculation();
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"
+ "<ram:LineID>" + lineID + "</ram:LineID>"

View File

@@ -205,4 +205,6 @@ public interface IZUGFeRDExportableItem extends IAbsoluteValueProvider{
default String getAccountingReference() {
return null;
}
default LineCalculator getCalculation() {return new LineCalculator(this); };
}

View File

@@ -107,7 +107,7 @@ public class OXPullProvider extends ZUGFeRD2PullProvider {
// exemptionReason = "<ram:ExemptionReason>" + XMLTools.encodeXML(currentItem.getProduct().getTaxExemptionReason()) + "</ram:ExemptionReason>";
}
final LineCalculator lc = new LineCalculator(currentItem);
final LineCalculator lc = currentItem.getCalculation();
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"
+ "<ram:LineID>" + lineID + "</ram:LineID>"

View File

@@ -195,7 +195,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
percent = currentItem.getProduct().getVATPercent();
}
if (percent != null) {
LineCalculator lc = new LineCalculator(currentItem);
LineCalculator lc = currentItem.getCalculation();
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
currentItem.getProduct().getTaxCategoryCode(), vatDueDateTypeCode);
String reasonText = currentItem.getProduct().getTaxExemptionReason();
@@ -265,7 +265,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
}
if (percent != null)
{
final LineCalculator lc = new LineCalculator(currentItem);
final LineCalculator lc = currentItem.getCalculation();
final VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
currentItem.getProduct().getTaxCategoryCode(), vatDueDateTypeCode, percent);
final String reasonText = currentItem.getProduct().getTaxExemptionReason();

View File

@@ -344,7 +344,7 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider {
}
final LineCalculator lc = new LineCalculator(currentItem);
final LineCalculator lc = currentItem.getCalculation();
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"
+ "<ram:LineID>" + lineID + "</ram:LineID>"

View File

@@ -415,7 +415,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
if (currentItem.getId() != null) {
lineIDStr = currentItem.getId();
}
final LineCalculator lc = new LineCalculator(currentItem);
final LineCalculator lc = currentItem.getCalculation();
if ((getProfile() != Profiles.getByName("Minimum")) && (getProfile() != Profiles.getByName("BasicWL"))) {
xml += "<ram:IncludedSupplyChainTradeLineItem>" +
"<ram:AssociatedDocumentLineDocument>"

View File

@@ -1146,7 +1146,7 @@ public class ZUGFeRDInvoiceImporter {
try {
moreDetails = " with tax basis " + tc.getTaxBasis() + " and with positions " + tc.getTotal() + " = "
+ Stream.of(tc.trans.getZFItems())
.map(item -> new LineCalculator(item).getItemTotalNetAmount().toPlainString())
.map(item -> item.getCalculation().getItemTotalNetAmount().toPlainString())
.collect(Collectors.joining(" + "));
} catch (Exception ignored) {
}