Merge branch 'master' into master
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -40,7 +40,7 @@
|
|||||||
<github.global.server>github</github.global.server>
|
<github.global.server>github</github.global.server>
|
||||||
<additionalparam>-Xdoclint:none</additionalparam>
|
<additionalparam>-Xdoclint:none</additionalparam>
|
||||||
<!-- Skip error check for javadoc -->
|
<!-- Skip error check for javadoc -->
|
||||||
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
|
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
@@ -134,8 +134,8 @@
|
|||||||
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
|
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
|
||||||
mvn clean compile assembly:single -->
|
mvn clean compile assembly:single -->
|
||||||
<!-- or whatever version you use -->
|
<!-- or whatever version you use -->
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|||||||
@@ -15,16 +15,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author AlexanderSchmidt
|
* @author AlexanderSchmidt
|
||||||
*/
|
*/
|
||||||
public interface IZUGFeRDAllowanceCharge {
|
public interface IZUGFeRDAllowanceCharge {
|
||||||
|
|
||||||
BigDecimal getTotalAmount();
|
BigDecimal getTotalAmount();
|
||||||
|
|
||||||
String getReason();
|
String getReason();
|
||||||
|
|
||||||
BigDecimal getTaxPercent();
|
BigDecimal getTaxPercent();
|
||||||
|
|
||||||
|
default String getCategoryCode() {
|
||||||
|
return TaxCategoryCodeTypeConstants.STANDARDRATE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public interface IZUGFeRDExportableItem {
|
public interface IZUGFeRDExportableItem {
|
||||||
@@ -51,5 +53,8 @@ public interface IZUGFeRDExportableItem {
|
|||||||
*/
|
*/
|
||||||
BigDecimal getQuantity();
|
BigDecimal getQuantity();
|
||||||
|
|
||||||
|
default String getCategoryCode() {
|
||||||
|
return TaxCategoryCodeTypeConstants.STANDARDRATE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,21 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public interface IZUGFeRDExportableTransaction {
|
public interface IZUGFeRDExportableTransaction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return Code of Document
|
||||||
|
*/
|
||||||
|
default String getDocumentCode() {
|
||||||
|
return DocumentCodeTypeConstants.INVOICE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number, typically invoice number of the invoice
|
* Number, typically invoice number of the invoice
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,14 +31,17 @@ import java.math.BigDecimal;
|
|||||||
*/
|
*/
|
||||||
public class VATAmount {
|
public class VATAmount {
|
||||||
|
|
||||||
public VATAmount(BigDecimal basis, BigDecimal calculated) {
|
public VATAmount(BigDecimal basis, BigDecimal calculated, String documentCode) {
|
||||||
super();
|
super();
|
||||||
this.basis = basis;
|
this.basis = basis;
|
||||||
this.calculated = calculated;
|
this.calculated = calculated;
|
||||||
|
this.documentCode = documentCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal basis, calculated;
|
BigDecimal basis, calculated;
|
||||||
|
|
||||||
|
String documentCode;
|
||||||
|
|
||||||
public BigDecimal getBasis() {
|
public BigDecimal getBasis() {
|
||||||
return basis;
|
return basis;
|
||||||
}
|
}
|
||||||
@@ -55,12 +58,20 @@ public class VATAmount {
|
|||||||
this.calculated = calculated;
|
this.calculated = calculated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDocumentCode() {
|
||||||
|
return documentCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDocumentCode(String documentCode) {
|
||||||
|
this.documentCode = documentCode;
|
||||||
|
}
|
||||||
|
|
||||||
public VATAmount add(VATAmount v) {
|
public VATAmount add(VATAmount v) {
|
||||||
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()));
|
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()), this.documentCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VATAmount subtract(VATAmount v) {
|
public VATAmount subtract(VATAmount v) {
|
||||||
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()));
|
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()), this.documentCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,8 +134,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
||||||
res = res.add(amount.getCalculated());
|
res = res.add(amount.getCalculated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,16 +160,14 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
||||||
LineCalc lc = new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount());
|
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(), trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
} else {
|
} else {
|
||||||
hm.put(percent, current.add(itemVATAmount));
|
hm.put(percent, current.add(itemVATAmount));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hm;
|
return hm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,6 +209,13 @@ public class ZUGFeRDImporter {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the document code
|
||||||
|
*/
|
||||||
|
public String getDocumentCode() {
|
||||||
|
return extractString("//HeaderExchangedDocument/TypeCode");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the sender's bank's BLZ code
|
* @return the sender's bank's BLZ code
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
document.setIssueDateTime(issueDateTime);
|
document.setIssueDateTime(issueDateTime);
|
||||||
|
|
||||||
DocumentCodeType documentCodeType = xmlFactory.createDocumentCodeType();
|
DocumentCodeType documentCodeType = xmlFactory.createDocumentCodeType();
|
||||||
documentCodeType.setValue(DocumentCodeTypeConstants.INVOICE);
|
documentCodeType.setValue(trans.getDocumentCode());
|
||||||
document.setTypeCode(documentCodeType);
|
document.setTypeCode(documentCodeType);
|
||||||
|
|
||||||
TextType name = xmlFactory.createTextType();
|
TextType name = xmlFactory.createTextType();
|
||||||
@@ -166,7 +166,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
document.getIncludedNote().add(regularInfo);
|
document.getIncludedNote().add(regularInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans.getReferenceNumber() != null && !new String().equals(trans.getReferenceNumber())) {
|
if (trans.getReferenceNumber() != null && !"".equals(trans.getReferenceNumber())) {
|
||||||
NoteType referenceInfo = xmlFactory.createNoteType();
|
NoteType referenceInfo = xmlFactory.createNoteType();
|
||||||
TextType referenceInfoContent = xmlFactory.createTextType();
|
TextType referenceInfoContent = xmlFactory.createTextType();
|
||||||
referenceInfoContent.setValue("Ursprungsbeleg: " + trans.getReferenceNumber());
|
referenceInfoContent.setValue("Ursprungsbeleg: " + trans.getReferenceNumber());
|
||||||
@@ -410,8 +410,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
private Collection<TradeTaxType> getTradeTax() {
|
private Collection<TradeTaxType> getTradeTax() {
|
||||||
List<TradeTaxType> tradeTaxTypes = new ArrayList<>();
|
List<TradeTaxType> tradeTaxTypes = new ArrayList<>();
|
||||||
|
|
||||||
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = this
|
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = this.getVATPercentAmountMap();
|
||||||
.getVATPercentAmountMap();
|
|
||||||
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
||||||
|
|
||||||
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
||||||
@@ -419,9 +418,9 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
taxTypeCode.setValue(TaxTypeCodeTypeConstants.SALESTAX);
|
taxTypeCode.setValue(TaxTypeCodeTypeConstants.SALESTAX);
|
||||||
tradeTax.setTypeCode(taxTypeCode);
|
tradeTax.setTypeCode(taxTypeCode);
|
||||||
|
|
||||||
TaxCategoryCodeType taxCategoryCode = xmlFactory
|
TaxCategoryCodeType taxCategoryCode = xmlFactory.createTaxCategoryCodeType();
|
||||||
.createTaxCategoryCodeType();
|
VATAmount vatAmount = VATPercentAmountMap.get(currentTaxPercent);
|
||||||
taxCategoryCode.setValue(TaxCategoryCodeTypeConstants.STANDARDRATE);
|
taxCategoryCode.setValue(vatAmount.getDocumentCode());
|
||||||
tradeTax.setCategoryCode(taxCategoryCode);
|
tradeTax.setCategoryCode(taxCategoryCode);
|
||||||
|
|
||||||
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
||||||
@@ -432,8 +431,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
|
|
||||||
AmountType calculatedTaxAmount = xmlFactory.createAmountType();
|
AmountType calculatedTaxAmount = xmlFactory.createAmountType();
|
||||||
calculatedTaxAmount.setCurrencyID(currency);
|
calculatedTaxAmount.setCurrencyID(currency);
|
||||||
calculatedTaxAmount
|
calculatedTaxAmount.setValue(currencyFormat(amount.getCalculated()));
|
||||||
.setValue(currencyFormat(amount.getCalculated()));
|
|
||||||
tradeTax.getCalculatedAmount().add(calculatedTaxAmount);
|
tradeTax.getCalculatedAmount().add(calculatedTaxAmount);
|
||||||
|
|
||||||
AmountType basisTaxAmount = xmlFactory.createAmountType();
|
AmountType basisTaxAmount = xmlFactory.createAmountType();
|
||||||
@@ -453,9 +451,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
|
|
||||||
for (IZUGFeRDAllowanceCharge iAllowance : trans.getZFAllowances()) {
|
for (IZUGFeRDAllowanceCharge iAllowance : trans.getZFAllowances()) {
|
||||||
|
|
||||||
TradeAllowanceChargeType allowance = xmlFactory
|
TradeAllowanceChargeType allowance = xmlFactory.createTradeAllowanceChargeType();
|
||||||
.createTradeAllowanceChargeType();
|
|
||||||
|
|
||||||
IndicatorType chargeIndicator = xmlFactory.createIndicatorType();
|
IndicatorType chargeIndicator = xmlFactory.createIndicatorType();
|
||||||
chargeIndicator.setIndicator(false);
|
chargeIndicator.setIndicator(false);
|
||||||
allowance.setChargeIndicator(chargeIndicator);
|
allowance.setChargeIndicator(chargeIndicator);
|
||||||
@@ -470,7 +466,6 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
allowance.setReason(reason);
|
allowance.setReason(reason);
|
||||||
|
|
||||||
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
||||||
|
|
||||||
PercentType vatPercent = xmlFactory.createPercentType();
|
PercentType vatPercent = xmlFactory.createPercentType();
|
||||||
vatPercent.setValue(currencyFormat(iAllowance.getTaxPercent()));
|
vatPercent.setValue(currencyFormat(iAllowance.getTaxPercent()));
|
||||||
tradeTax.setApplicablePercent(vatPercent);
|
tradeTax.setApplicablePercent(vatPercent);
|
||||||
@@ -482,9 +477,8 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
* basisAmount.setValue(amount.getBasis());
|
* basisAmount.setValue(amount.getBasis());
|
||||||
* allowance.setBasisAmount(basisAmount);
|
* allowance.setBasisAmount(basisAmount);
|
||||||
*/
|
*/
|
||||||
TaxCategoryCodeType taxType = xmlFactory
|
TaxCategoryCodeType taxType = xmlFactory.createTaxCategoryCodeType();
|
||||||
.createTaxCategoryCodeType();
|
taxType.setValue(iAllowance.getCategoryCode());
|
||||||
taxType.setValue(TaxCategoryCodeTypeConstants.STANDARDRATE);
|
|
||||||
tradeTax.setCategoryCode(taxType);
|
tradeTax.setCategoryCode(taxType);
|
||||||
|
|
||||||
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
||||||
@@ -493,7 +487,6 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
|
|
||||||
allowance.getCategoryTradeTax().add(tradeTax);
|
allowance.getCategoryTradeTax().add(tradeTax);
|
||||||
headerAllowances.add(allowance);
|
headerAllowances.add(allowance);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return headerAllowances;
|
return headerAllowances;
|
||||||
@@ -505,9 +498,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
|
|
||||||
for (IZUGFeRDAllowanceCharge iCharge : trans.getZFCharges()) {
|
for (IZUGFeRDAllowanceCharge iCharge : trans.getZFCharges()) {
|
||||||
|
|
||||||
TradeAllowanceChargeType charge = xmlFactory
|
TradeAllowanceChargeType charge = xmlFactory.createTradeAllowanceChargeType();
|
||||||
.createTradeAllowanceChargeType();
|
|
||||||
|
|
||||||
IndicatorType chargeIndicator = xmlFactory.createIndicatorType();
|
IndicatorType chargeIndicator = xmlFactory.createIndicatorType();
|
||||||
chargeIndicator.setIndicator(true);
|
chargeIndicator.setIndicator(true);
|
||||||
charge.setChargeIndicator(chargeIndicator);
|
charge.setChargeIndicator(chargeIndicator);
|
||||||
@@ -522,7 +513,6 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
charge.setReason(reason);
|
charge.setReason(reason);
|
||||||
|
|
||||||
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
||||||
|
|
||||||
PercentType vatPercent = xmlFactory.createPercentType();
|
PercentType vatPercent = xmlFactory.createPercentType();
|
||||||
vatPercent.setValue(currencyFormat(iCharge.getTaxPercent()));
|
vatPercent.setValue(currencyFormat(iCharge.getTaxPercent()));
|
||||||
tradeTax.setApplicablePercent(vatPercent);
|
tradeTax.setApplicablePercent(vatPercent);
|
||||||
@@ -534,9 +524,8 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
* basisAmount.setValue(amount.getBasis());
|
* basisAmount.setValue(amount.getBasis());
|
||||||
* allowance.setBasisAmount(basisAmount);
|
* allowance.setBasisAmount(basisAmount);
|
||||||
*/
|
*/
|
||||||
TaxCategoryCodeType taxType = xmlFactory
|
TaxCategoryCodeType taxType = xmlFactory.createTaxCategoryCodeType();
|
||||||
.createTaxCategoryCodeType();
|
taxType.setValue(iCharge.getCategoryCode());
|
||||||
taxType.setValue(TaxCategoryCodeTypeConstants.STANDARDRATE);
|
|
||||||
tradeTax.setCategoryCode(taxType);
|
tradeTax.setCategoryCode(taxType);
|
||||||
|
|
||||||
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
||||||
@@ -555,16 +544,13 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
private Collection<LogisticsServiceChargeType> getHeaderLogisticsServiceCharges() {
|
private Collection<LogisticsServiceChargeType> getHeaderLogisticsServiceCharges() {
|
||||||
List<LogisticsServiceChargeType> headerServiceCharge = new ArrayList<>();
|
List<LogisticsServiceChargeType> headerServiceCharge = new ArrayList<>();
|
||||||
|
|
||||||
for (IZUGFeRDAllowanceCharge iServiceCharge : trans
|
for (IZUGFeRDAllowanceCharge iServiceCharge : trans.getZFLogisticsServiceCharges()) {
|
||||||
.getZFLogisticsServiceCharges()) {
|
|
||||||
|
|
||||||
LogisticsServiceChargeType serviceCharge = xmlFactory
|
LogisticsServiceChargeType serviceCharge = xmlFactory.createLogisticsServiceChargeType();
|
||||||
.createLogisticsServiceChargeType();
|
|
||||||
|
|
||||||
AmountType actualAmount = xmlFactory.createAmountType();
|
AmountType actualAmount = xmlFactory.createAmountType();
|
||||||
actualAmount.setCurrencyID(currency);
|
actualAmount.setCurrencyID(currency);
|
||||||
actualAmount.setValue(currencyFormat(iServiceCharge
|
actualAmount.setValue(currencyFormat(iServiceCharge.getTotalAmount()));
|
||||||
.getTotalAmount()));
|
|
||||||
serviceCharge.getAppliedAmount().add(actualAmount);
|
serviceCharge.getAppliedAmount().add(actualAmount);
|
||||||
|
|
||||||
TextType reason = xmlFactory.createTextType();
|
TextType reason = xmlFactory.createTextType();
|
||||||
@@ -584,9 +570,8 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
* basisAmount.setValue(amount.getBasis());
|
* basisAmount.setValue(amount.getBasis());
|
||||||
* allowance.setBasisAmount(basisAmount);
|
* allowance.setBasisAmount(basisAmount);
|
||||||
*/
|
*/
|
||||||
TaxCategoryCodeType taxType = xmlFactory
|
TaxCategoryCodeType taxType = xmlFactory.createTaxCategoryCodeType();
|
||||||
.createTaxCategoryCodeType();
|
taxType.setValue(iServiceCharge.getCategoryCode());
|
||||||
taxType.setValue(TaxCategoryCodeTypeConstants.STANDARDRATE);
|
|
||||||
tradeTax.setCategoryCode(taxType);
|
tradeTax.setCategoryCode(taxType);
|
||||||
|
|
||||||
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
||||||
@@ -812,9 +797,8 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
.createSupplyChainTradeSettlementType();
|
.createSupplyChainTradeSettlementType();
|
||||||
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
|
||||||
|
|
||||||
TaxCategoryCodeType taxCategoryCode = xmlFactory
|
TaxCategoryCodeType taxCategoryCode = xmlFactory.createTaxCategoryCodeType();
|
||||||
.createTaxCategoryCodeType();
|
taxCategoryCode.setValue(currentItem.getCategoryCode());
|
||||||
taxCategoryCode.setValue(TaxCategoryCodeTypeConstants.STANDARDRATE);
|
|
||||||
tradeTax.setCategoryCode(taxCategoryCode);
|
tradeTax.setCategoryCode(taxCategoryCode);
|
||||||
|
|
||||||
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
|
||||||
@@ -932,15 +916,13 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap(
|
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap(Boolean itemOnly) {
|
||||||
Boolean itemOnly) {
|
|
||||||
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
||||||
LineCalc lc = new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(),
|
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(), trans.getDocumentCode());
|
||||||
lc.getItemTotalVATAmount());
|
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
@@ -952,13 +934,12 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return hm;
|
return hm;
|
||||||
}
|
}
|
||||||
if (trans.getZFAllowances() != null) {
|
if (trans.getZFAllowances() != null) {
|
||||||
for (IZUGFeRDAllowanceCharge headerAllowance : trans
|
for (IZUGFeRDAllowanceCharge headerAllowance : trans.getZFAllowances()) {
|
||||||
.getZFAllowances()) {
|
|
||||||
BigDecimal percent = headerAllowance.getTaxPercent();
|
BigDecimal percent = headerAllowance.getTaxPercent();
|
||||||
VATAmount itemVATAmount = new VATAmount(
|
VATAmount itemVATAmount = new VATAmount(
|
||||||
headerAllowance.getTotalAmount(), headerAllowance
|
headerAllowance.getTotalAmount(), headerAllowance
|
||||||
.getTotalAmount().multiply(percent)
|
.getTotalAmount().multiply(percent)
|
||||||
.divide(new BigDecimal(100)));
|
.divide(new BigDecimal(100)), trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
@@ -975,7 +956,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
VATAmount itemVATAmount = new VATAmount(
|
VATAmount itemVATAmount = new VATAmount(
|
||||||
logisticsServiceCharge.getTotalAmount(),
|
logisticsServiceCharge.getTotalAmount(),
|
||||||
logisticsServiceCharge.getTotalAmount()
|
logisticsServiceCharge.getTotalAmount()
|
||||||
.multiply(percent).divide(new BigDecimal(100)));
|
.multiply(percent).divide(new BigDecimal(100)), trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
@@ -990,7 +971,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
BigDecimal percent = charge.getTaxPercent();
|
BigDecimal percent = charge.getTaxPercent();
|
||||||
VATAmount itemVATAmount = new VATAmount(
|
VATAmount itemVATAmount = new VATAmount(
|
||||||
charge.getTotalAmount(), charge.getTotalAmount()
|
charge.getTotalAmount(), charge.getTotalAmount()
|
||||||
.multiply(percent).divide(new BigDecimal(100)));
|
.multiply(percent).divide(new BigDecimal(100)), trans.getDocumentCode());
|
||||||
VATAmount current = hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
@@ -1115,9 +1096,8 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
// Set total net amount
|
// Set total net amount
|
||||||
totalNetAmount = res;
|
totalNetAmount = res;
|
||||||
|
|
||||||
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
HashMap<BigDecimal, VATAmount> vatAmountHashMap = getVATPercentAmountMap();
|
||||||
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
for (VATAmount amount : vatAmountHashMap.values()) {
|
||||||
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
|
||||||
res = res.add(amount.getCalculated());
|
res = res.add(amount.getCalculated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp
|
|||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
assertEquals(zi.getDueDate(), "20170530");
|
assertEquals(zi.getDueDate(), "20170530");
|
||||||
assertEquals(zi.getForeignReference(), getNumber());
|
assertEquals(zi.getForeignReference(), getNumber());
|
||||||
|
assertEquals(zi.getDocumentCode(), "380");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -350,32 +350,13 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream);
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream);
|
||||||
|
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
String amount = null;
|
assertEquals(zi.getAmount(), "571.04");
|
||||||
String blz = null;
|
assertEquals(zi.getBLZ(), getOwnBLZ());
|
||||||
String bic = null;
|
assertEquals(zi.getBIC(), getOwnBIC());
|
||||||
String iban = null;
|
assertEquals(zi.getIBAN(), getOwnIBAN());
|
||||||
String kto = null;
|
assertEquals(zi.getKTO(), getOwnKto());
|
||||||
String holder = null;
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
String ref = null;
|
assertEquals(zi.getForeignReference(), "RE-20170509/505");
|
||||||
|
|
||||||
if (zi.canParse()) {
|
|
||||||
amount = zi.getAmount();
|
|
||||||
blz = zi.getBLZ();
|
|
||||||
bic = zi.getBIC();
|
|
||||||
iban = zi.getIBAN();
|
|
||||||
kto = zi.getKTO();
|
|
||||||
holder = zi.getHolder();
|
|
||||||
ref = zi.getForeignReference();
|
|
||||||
}
|
|
||||||
// this resembles the data written in MustangReaderWriterCustomXMLTest
|
|
||||||
assertEquals(amount, "571.04");
|
|
||||||
assertEquals(blz, "41441604");
|
|
||||||
assertEquals(bic, "COBADEFFXXX");
|
|
||||||
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
|
||||||
assertEquals(kto, "44421800");
|
|
||||||
assertEquals(holder, "Bei Spiel GmbH");
|
|
||||||
assertEquals(ref, "RE-20170509/505");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testForeignImport() throws IOException {
|
public void testForeignImport() throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user