Removed some redundancy
This commit is contained in:
@@ -35,13 +35,12 @@ import java.util.HashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class ZUGFeRD1PullProvider implements IXMLProvider {
|
public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider implements IXMLProvider {
|
||||||
|
|
||||||
|
|
||||||
//// MAIN CLASS
|
//// MAIN CLASS
|
||||||
|
|
||||||
protected byte[] zugferdData;
|
protected byte[] zugferdData;
|
||||||
private IExportableTransaction trans;
|
|
||||||
private String paymentTermsDescription;
|
private String paymentTermsDescription;
|
||||||
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
protected Profile profile=Profiles.getByName("COMFORT",1);
|
protected Profile profile=Profiles.getByName("COMFORT",1);
|
||||||
@@ -101,87 +100,6 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getTotalPrepaid() {
|
|
||||||
if (trans.getTotalPrepaidAmount() == null) {
|
|
||||||
return new BigDecimal(0);
|
|
||||||
} else {
|
|
||||||
return trans.getTotalPrepaidAmount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BigDecimal getTotalGross() {
|
|
||||||
|
|
||||||
BigDecimal res = getTotal();
|
|
||||||
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
|
||||||
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
|
||||||
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
|
||||||
res = res.add(amount.getCalculated());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BigDecimal getTotal() {
|
|
||||||
BigDecimal res = new BigDecimal(0);
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
|
||||||
LineCalc lc = new LineCalc(currentItem);
|
|
||||||
res = res.add(lc.getItemTotalNetAmount());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* which taxes have been used with which amounts in this transaction, empty for
|
|
||||||
* no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable to 19% VAT
|
|
||||||
* (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT) 190 Eur
|
|
||||||
*
|
|
||||||
* @return which taxes have been used with which amounts in this invoice
|
|
||||||
*/
|
|
||||||
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap() {
|
|
||||||
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
|
||||||
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
|
||||||
LineCalc lc = new LineCalc(currentItem);
|
|
||||||
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
|
|
||||||
trans.getDocumentCode());
|
|
||||||
VATAmount current = hm.get(percent);
|
|
||||||
if (current == null) {
|
|
||||||
hm.put(percent, itemVATAmount);
|
|
||||||
} else {
|
|
||||||
hm.put(percent, current.add(itemVATAmount));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hm;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getTradePartyAsXML(IZUGFeRDExportableTradeParty contact) {
|
|
||||||
String xml = " <ram:Name>" + XMLTools.encodeXML(contact.getName()) + "</ram:Name>\n" //$NON-NLS-2$
|
|
||||||
// + " <DefinedTradeContact>\n"
|
|
||||||
// + " <PersonName>xxx</PersonName>\n"
|
|
||||||
// + " </DefinedTradeContact>\n"
|
|
||||||
+ " <ram:PostalTradeAddress>\n"
|
|
||||||
+ " <ram:PostcodeCode>" + XMLTools.encodeXML(contact.getZIP())
|
|
||||||
+ "</ram:PostcodeCode>\n"
|
|
||||||
+ " <ram:LineOne>" + XMLTools.encodeXML(contact.getStreet())
|
|
||||||
+ "</ram:LineOne>\n";
|
|
||||||
if (contact.getAdditionalAddress() != null) {
|
|
||||||
xml += " <ram:LineTwo>" + XMLTools.encodeXML(contact.getAdditionalAddress())
|
|
||||||
+ "</ram:LineTwo>\n";
|
|
||||||
}
|
|
||||||
xml += " <ram:CityName>" + XMLTools.encodeXML(contact.getLocation())
|
|
||||||
+ "</ram:CityName>\n"
|
|
||||||
+ " <ram:CountryID>" + XMLTools.encodeXML(contact.getCountry())
|
|
||||||
+ "</ram:CountryID>\n"
|
|
||||||
+ " </ram:PostalTradeAddress>\n";
|
|
||||||
if (contact.getVATID() != null) {
|
|
||||||
xml += " <ram:SpecifiedTaxRegistration>\n"
|
|
||||||
+ " <ram:ID schemeID=\"VA\">" + XMLTools.encodeXML(contact.getVATID())
|
|
||||||
+ "</ram:ID>\n"
|
|
||||||
+ " </ram:SpecifiedTaxRegistration>\n";
|
|
||||||
}
|
|
||||||
return xml;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateXML(IExportableTransaction trans) {
|
public void generateXML(IExportableTransaction trans) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
//// MAIN CLASS
|
//// MAIN CLASS
|
||||||
protected SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
protected SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
protected byte[] zugferdData;
|
protected byte[] zugferdData;
|
||||||
private IExportableTransaction trans;
|
protected IExportableTransaction trans;
|
||||||
private String paymentTermsDescription;
|
private String paymentTermsDescription;
|
||||||
protected Profile profile = Profiles.getByName("EN16931");
|
protected Profile profile = Profiles.getByName("EN16931");
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
|
|
||||||
}
|
}
|
||||||
//move
|
//move
|
||||||
private BigDecimal getTotalPrepaid() {
|
protected BigDecimal getTotalPrepaid() {
|
||||||
if (trans.getTotalPrepaidAmount() == null) {
|
if (trans.getTotalPrepaidAmount() == null) {
|
||||||
return new BigDecimal(0);
|
return new BigDecimal(0);
|
||||||
} else {
|
} else {
|
||||||
@@ -105,7 +105,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getTotalGross() {
|
protected BigDecimal getTotalGross() {
|
||||||
|
|
||||||
BigDecimal res = getTaxBasis();
|
BigDecimal res = getTaxBasis();
|
||||||
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
||||||
@@ -116,7 +116,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getCharges() {
|
protected BigDecimal getCharges() {
|
||||||
BigDecimal res = new BigDecimal(0);
|
BigDecimal res = new BigDecimal(0);
|
||||||
IZUGFeRDAllowanceCharge[] charges = trans.getZFCharges();
|
IZUGFeRDAllowanceCharge[] charges = trans.getZFCharges();
|
||||||
if ((charges != null) && (charges.length > 0)) {
|
if ((charges != null) && (charges.length > 0)) {
|
||||||
@@ -127,7 +127,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getAllowances() {
|
protected BigDecimal getAllowances() {
|
||||||
BigDecimal res = new BigDecimal(0);
|
BigDecimal res = new BigDecimal(0);
|
||||||
IZUGFeRDAllowanceCharge[] allowances = trans.getZFAllowances();
|
IZUGFeRDAllowanceCharge[] allowances = trans.getZFAllowances();
|
||||||
if ((allowances != null) && (allowances.length > 0)) {
|
if ((allowances != null) && (allowances.length > 0)) {
|
||||||
@@ -138,7 +138,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getTotal() {
|
protected BigDecimal getTotal() {
|
||||||
BigDecimal res = new BigDecimal(0);
|
BigDecimal res = new BigDecimal(0);
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
LineCalc lc = new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
@@ -147,7 +147,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getTaxBasis() {
|
protected BigDecimal getTaxBasis() {
|
||||||
BigDecimal res = getTotal().add(getCharges()).subtract(getAllowances());
|
BigDecimal res = getTotal().add(getCharges()).subtract(getAllowances());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IAbsoluteValueProvide
|
|||||||
*
|
*
|
||||||
* @return which taxes have been used with which amounts in this invoice
|
* @return which taxes have been used with which amounts in this invoice
|
||||||
*/
|
*/
|
||||||
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap() {
|
protected HashMap<BigDecimal, VATAmount> getVATPercentAmountMap() {
|
||||||
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user