allow custom ram:reasons (previously ignored)

This commit is contained in:
jstaerk
2020-11-05 10:42:50 +01:00
parent b80432903c
commit 0f98ecb8f0
6 changed files with 56 additions and 8 deletions

View File

@@ -51,6 +51,54 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
return res;
}
/***
* returns a (potentially concatenated) string of charge reasons, or "Charges" if none are defined
* @param percent a specific rate, or null for any rate
* @return the space separated String
*/
protected String getChargeReasonForPercent(BigDecimal percent) {
String res = " ";
IZUGFeRDAllowanceCharge[] charges = trans.getZFCharges();
if ((charges != null) && (charges.length > 0)) {
for (IZUGFeRDAllowanceCharge currentCharge : charges) {
if ((percent==null)||(currentCharge.getTaxPercent().equals(percent))) {
if (currentCharge.getReason()!=null) {
res = res+currentCharge.getReason()+" ";
}
}
}
}
res=res.substring(0,res.length()-1);
if (res.equals("")) {
res="Charges";
}
return res;
}
/***
* returns a (potentially concatenated) string of allowance reasons, or "Allowances", if none are defined
* @param percent a specific rate, or null for any rate
* @return the space separated String
*/
protected String getAllowanceReasonForPercent(BigDecimal percent) {
String res = " ";
IZUGFeRDAllowanceCharge[] allowances = trans.getZFAllowances();
if ((allowances != null) && (allowances.length > 0)) {
for (IZUGFeRDAllowanceCharge currentAllowance : allowances) {
if ((percent==null)||(currentAllowance.getTaxPercent().equals(percent))) {
if (currentAllowance.getReason()!=null) {
res = res+currentAllowance.getReason()+" ";
}
}
}
}
res=res.substring(0,res.length()-1);
if (res.equals("")) {
res="Allowances";
}
return res;
}
/***
* returns total of allowances for this tax rate

View File

@@ -15,7 +15,7 @@ import java.io.*;
public class XMLUpgrader {
static final ClassLoader CLASS_LOADER = XMLUpgrader.class.getClassLoader();
private static final String RESOURCE_PATH = ""; //$NON-NLS-1$
private static final String RESOURCE_PATH = "";
private TransformerFactory mFactory = null;
private Templates mXsltTemplate = null;

View File

@@ -454,7 +454,7 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider implements IXMLPr
}
} catch (UnsupportedEncodingException e) {
Logger.getLogger(ZUGFeRD1PullProvider.class.getName()).log(Level.SEVERE, null, e);
} // $NON-NLS-1$
}
}
@Override

View File

@@ -500,7 +500,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
" <udt:Indicator>true</udt:Indicator>\n" +
" </ram:ChargeIndicator>\n" +
" <ram:ActualAmount>" + currencyFormat(calc.getChargesForPercent(currentTaxPercent)) + "</ram:ActualAmount>\n" +
" <ram:Reason>Charge</ram:Reason>\n" +
" <ram:Reason>"+XMLTools.encodeXML(calc.getChargeReasonForPercent(currentTaxPercent))+"</ram:Reason>\n" +
" <ram:CategoryTradeTax>\n" +
" <ram:TypeCode>VAT</ram:TypeCode>\n" +
" <ram:CategoryCode>S</ram:CategoryCode>\n" +
@@ -521,7 +521,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
" <udt:Indicator>false</udt:Indicator>\n" +
" </ram:ChargeIndicator>\n" +
" <ram:ActualAmount>" + currencyFormat(calc.getAllowancesForPercent(currentTaxPercent)) + "</ram:ActualAmount>\n" +
" <ram:Reason>Allowance</ram:Reason>\n" +
" <ram:Reason>"+XMLTools.encodeXML(calc.getAllowanceReasonForPercent(currentTaxPercent))+"</ram:Reason>\n" +
" <ram:CategoryTradeTax>\n" +
" <ram:TypeCode>VAT</ram:TypeCode>\n" +
" <ram:CategoryCode>S</ram:CategoryCode>\n" +
@@ -604,7 +604,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
} catch (UnsupportedEncodingException e) {
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e);
} // $NON-NLS-1$
}
}
@Override

View File

@@ -490,7 +490,7 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
pdf.setProducer(fullProducer);
if (ensurePDFisUpgraded) {
try {
pdfaid.setConformance(conformanceLevel.getLetter());// $NON-NLS-1$
pdfaid.setConformance(conformanceLevel.getLetter());
} catch (BadFieldValueException ex) {
// This should be impossible, because it would occur only if an illegal
// conformance level is supplied,