diff --git a/History.md b/History.md index acad4361..44209a82 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +#820/801/815 +#822 +#843 +add getCalculation on calculatedInvoice +Transactioncalculator getTaxDetails to include correct percentage, calculated amounts + 2.16.5 ======= 2025-05-22 diff --git a/doc/development_documentation.md b/doc/development_documentation.md index dbdc8ed4..c08c457c 100644 --- a/doc/development_documentation.md +++ b/doc/development_documentation.md @@ -184,11 +184,11 @@ maybe not yet even existing new release version: ``` cd validator/target -mvn install:install-file -Dfile=validator-2.12.0-SNAPSHOT-shaded.jar -Dclassifier=shaded -DgroupId=org.mustangproject -DartifactId=validator -Dversion=2.12.0 -Dpackaging=jar -DgeneratePom=true +mvn install:install-file -Dfile=validator-2.17.0-SNAPSHOT-shaded.jar -Dclassifier=shaded -DgroupId="org.mustangproject" -DartifactId=validator -Dversion="2.17.0" -Dpackaging=jar -DgeneratePom=true ``` In gradle you can use something like ``` -implementation files('libs/validator-2.12.0-shaded.jar') +implementation files('libs/validator-2.17.0-shaded.jar') ``` diff --git a/library/src/main/java/org/mustangproject/CalculatedInvoice.java b/library/src/main/java/org/mustangproject/CalculatedInvoice.java index 194441b1..f993db83 100644 --- a/library/src/main/java/org/mustangproject/CalculatedInvoice.java +++ b/library/src/main/java/org/mustangproject/CalculatedInvoice.java @@ -19,9 +19,10 @@ public class CalculatedInvoice extends Invoice implements Serializable { protected BigDecimal duePayable=null; protected BigDecimal grandTotal=null; protected BigDecimal taxBasis=null; + protected TransactionCalculator tc=null; public void calculate() { - TransactionCalculator tc=new TransactionCalculator(this); + tc=new TransactionCalculator(this); grandTotal=tc.getGrandTotal(); lineTotalAmount=tc.getValue(); duePayable=tc.getDuePayable(); @@ -33,6 +34,13 @@ public class CalculatedInvoice extends Invoice implements Serializable { } return grandTotal; } + + + /*** + * usually one would use calculate, use only if the invoice is parsed + * @param grand the gross total + * @return fluent setter + */ public CalculatedInvoice setGrandTotal(BigDecimal grand) { grandTotal=grand; return this; @@ -43,6 +51,13 @@ public class CalculatedInvoice extends Invoice implements Serializable { } return taxBasis; } + + + /*** + * usually one would use calculate, use only if the invoice is parsed + * @param basis taxable net total + * @return fluent setter + */ public CalculatedInvoice setTaxBasis(BigDecimal basis) { taxBasis=basis; return this; @@ -54,6 +69,13 @@ public class CalculatedInvoice extends Invoice implements Serializable { } return duePayable; } + + + /*** + * usually one would use calculate, use only if the invoice is parsed + * @param due the gross total minus prepaid + * @return fluent setter + */ public CalculatedInvoice setDuePayable(BigDecimal due) { duePayable=due; return this; @@ -65,9 +87,24 @@ public class CalculatedInvoice extends Invoice implements Serializable { } return lineTotalAmount; } + + /*** + * usually one would use calculate, use only if the invoice is parsed + * @param total the net total + * @return fluent setter + */ public CalculatedInvoice setLineTotalAmount(BigDecimal total) { lineTotalAmount=total; return this; } + /** + * this can be used to additionally e.g. access the VAT amounts + * @return a updated transactioncalulator + */ + public TransactionCalculator getCalculation() { + calculate(); + return tc; + } + } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/TransactionCalculator.java b/library/src/main/java/org/mustangproject/ZUGFeRD/TransactionCalculator.java index b8844b63..4f95773c 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/TransactionCalculator.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/TransactionCalculator.java @@ -79,7 +79,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider { entry.getValue().getBasis(), entry.getValue().getCalculated(), entry.getValue().getCategoryCode() - ).setCalculated(entry.getKey()) + ).setApplicablePercent(entry.getKey()) ) .collect(Collectors.toSet()); } @@ -187,9 +187,8 @@ public class TransactionCalculator implements IAbsoluteValueProvider { for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) { BigDecimal percent = null; - if (currentItem.getProduct()!=null) - { - percent=currentItem.getProduct().getVATPercent(); + if (currentItem.getProduct() != null) { + percent = currentItem.getProduct().getVATPercent(); } if (percent != null) { LineCalculator lc = new LineCalculator(currentItem);