Skip to content

Commit

Permalink
working on cash discount abstraction (XR and reading is still missing)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaerk committed May 9, 2024
1 parent e8bbc6c commit 757910f
Show file tree
Hide file tree
Showing 9 changed files with 314 additions and 218 deletions.
2 changes: 2 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- UBL importer to also parse contacts
- https://github.com/ZUGFeRD/mustangproject/pull/369
- upgrade ph-schematron from 6.3.3 to 8
- support inputstreams https://github.com/ZUGFeRD/mustangproject/pull/379
- #314 ZUGFeRDInvoiceImporter additional constructur

2.10.0
=======
Expand Down
14 changes: 13 additions & 1 deletion doc/development_documentation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

## General approach
## Typical process

1. build

Expand Down Expand Up @@ -29,6 +29,18 @@ If you do a pull request, please do a feature branch, e.g. if you are working on
Most of mustang is a library, adding (autmated junit) test cases is often not only the most sustainable but also the fastest way to see if new/changed functionality works. If something is changed so that old test cases break on purpose please do not just remove them but take the time to fix the test cases


## Typical workflow

If e.g. new elements or attributes are added, they are often added
* in the object so that a developer can use them
* in the interface so that a old fashioned developer could use them as well
* in the pullprovider so that it actually finds it's way into the XML
* in at least one test, after the test has been run this should at least once be
* validated. If that works one can start implementing the
* reading part (along with tests), then it needs to be
* documented e.g. on the homepage and
* communicated, at the very least by mentioning it in the history.md

## Architecture

Mustang contains a library to read/write e-invoices,
Expand Down
50 changes: 50 additions & 0 deletions library/src/main/java/org/mustangproject/CashDiscount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.mustangproject;

import org.mustangproject.ZUGFeRD.IZUGFeRDCashDiscount;

import java.math.BigDecimal;

public class CashDiscount implements IZUGFeRDCashDiscount {

protected BigDecimal percent;
protected Integer days=null;

/***
* Create a cash discount (skonto) with the specified height in the specified period.
* Should someone add more period types than just "days" there
* is be space for a (optional) third parameter
*
* @param percent max 3 decimals "behind the dot", more precision is currently ignored
* @param days
*/
public CashDiscount(BigDecimal percent, int days) {
this.percent = percent;
this.days = days;
}

/***
* @return this particular cash discount as cross industry invoice XML
*/
public String getAsCII() {
return "<ram:SpecifiedTradePaymentTerms>"+
"<ram:Description>Cash Discount</ram:Description>"+
" <ram:ApplicableTradePaymentDiscountTerms>"+
" <ram:BasisPeriodMeasure unitCode=\"DAY\">"+days+"</ram:BasisPeriodMeasure>"+
" <ram:CalculationPercent>"+XMLTools.nDigitFormat(percent,3)+"</ram:CalculationPercent>"+
" </ram:ApplicableTradePaymentDiscountTerms>"+
"</ram:SpecifiedTradePaymentTerms>";
}

/***
* since EN16931 voted not to have (or even allow) cash discounts in their core invoice the german
* XRechnung CIUS defined it's own proprietary format for a freetext field
* @return this particular cash discount in proprietary xrechnung format
*/
public String getAsXRechnung() {
return "#SKONTO#TAGE="+days+"#PROZENT="+XMLTools.nDigitFormat(percent,3)+"#\n";
}




}
Loading

0 comments on commit 757910f

Please sign in to comment.