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; 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 * returns total of allowances for this tax rate

View File

@@ -15,7 +15,7 @@ import java.io.*;
public class XMLUpgrader { public class XMLUpgrader {
static final ClassLoader CLASS_LOADER = XMLUpgrader.class.getClassLoader(); 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 TransformerFactory mFactory = null;
private Templates mXsltTemplate = null; private Templates mXsltTemplate = null;

View File

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

View File

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

View File

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

View File

@@ -257,8 +257,8 @@ public class ZF2PushTest extends TestCase {
.load(SOURCE_PDF)) { .load(SOURCE_PDF)) {
ze.setTransaction(new Invoice().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(16)), price, new BigDecimal(1.0)).addNote("item level 1/1")) ze.setTransaction(new Invoice().setCurrency("CHF").addNote("document level 1/2").addNote("document level 2/2").setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addTaxID(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(16)), price, new BigDecimal(1.0)).addNote("item level 1/1"))
.addCharge(new Charge(new BigDecimal(0.5)).setTaxPercent(new BigDecimal(16))) .addCharge(new Charge(new BigDecimal(0.5)).setReason("quick delivery charge").setTaxPercent(new BigDecimal(16)))
.addAllowance(new Allowance(new BigDecimal(0.2)).setTaxPercent(new BigDecimal(16))) .addAllowance(new Allowance(new BigDecimal(0.2)).setReason("discount").setTaxPercent(new BigDecimal(16)))
); );
String theXML = new String(ze.getProvider().getXML()); String theXML = new String(ze.getProvider().getXML());