-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on cash discount abstraction (XR and reading is still missing)
- Loading branch information
Showing
9 changed files
with
314 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
library/src/main/java/org/mustangproject/CashDiscount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.