first implementation of header allowances

This commit is contained in:
AlexanderSchmidt
2015-11-10 13:57:27 +01:00
parent 88ca559899
commit 74b08e0a2f
3 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2015 AlexanderSchmidt.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mustangproject.ZUGFeRD;
import java.math.BigDecimal;
/**
*
* @author AlexanderSchmidt
*/
public interface IZUGFeRDAllowanceCharge {
BigDecimal getAmount();
String getReason();
BigDecimal getTaxPercent();
}

View File

@@ -46,6 +46,10 @@ public interface IZUGFeRDExportableTransaction {
*/ */
Date getDueDate(); Date getDueDate();
IZUGFeRDAllowanceCharge[] getZFAllowances();
IZUGFeRDAllowanceCharge[] getZFCharges();
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
IZUGFeRDExportableItem[] getZFItems(); IZUGFeRDExportableItem[] getZFItems();
/*** /***

View File

@@ -476,6 +476,7 @@ public class ZUGFeRDExporter {
tradeSettlement.getSpecifiedTradeSettlementPaymentMeans().add(this.getPaymentData()); tradeSettlement.getSpecifiedTradeSettlementPaymentMeans().add(this.getPaymentData());
tradeSettlement.getApplicableTradeTax().addAll(this.getTradeTax()); tradeSettlement.getApplicableTradeTax().addAll(this.getTradeTax());
tradeSettlement.getSpecifiedTradePaymentTerms().addAll(this.getPaymentTerms()); tradeSettlement.getSpecifiedTradePaymentTerms().addAll(this.getPaymentTerms());
tradeSettlement.getSpecifiedTradeAllowanceCharge().addAll(this.getHeaderAllowances());
tradeSettlement.setSpecifiedTradeSettlementMonetarySummation(this.getMonetarySummation()); tradeSettlement.setSpecifiedTradeSettlementMonetarySummation(this.getMonetarySummation());
return tradeSettlement; return tradeSettlement;
@@ -545,6 +546,43 @@ public class ZUGFeRDExporter {
return tradeTaxTypes; return tradeTaxTypes;
} }
private Collection<TradeAllowanceChargeType> getHeaderAllowances() {
List<TradeAllowanceChargeType> headerAllowances = new ArrayList<TradeAllowanceChargeType>();
for (IZUGFeRDAllowanceCharge iAllowance : trans.getZFAllowances()) {
TradeAllowanceChargeType allowance = xmlFactory.createTradeAllowanceChargeType();
IndicatorType chargeIndicator = xmlFactory.createIndicatorType();
chargeIndicator.setIndicator(false);
allowance.setChargeIndicator(chargeIndicator);
TextType reason = xmlFactory.createTextType();
reason.setValue(iAllowance.getReason());
allowance.setReason(reason);
TradeTaxType tradeTax = xmlFactory.createTradeTaxType();
PercentType vatPercent = xmlFactory.createPercentType();
vatPercent.setValue(iAllowance.getTaxPercent());
tradeTax.setApplicablePercent(vatPercent);
TaxCategoryCodeType taxType = xmlFactory.createTaxCategoryCodeType();
taxType.setValue(TaxCategoryCodeType.STANDARDRATE);
tradeTax.setCategoryCode(taxType);
TaxTypeCodeType taxCode = xmlFactory.createTaxTypeCodeType();
taxCode.setValue(TaxTypeCodeType.SALESTAX);
tradeTax.setTypeCode(taxCode);
allowance.getCategoryTradeTax().add(tradeTax);
headerAllowances.add(allowance);
}
return headerAllowances;
}
private Collection<TradePaymentTermsType> getPaymentTerms() { private Collection<TradePaymentTermsType> getPaymentTerms() {
List<TradePaymentTermsType> paymentTerms = new ArrayList<TradePaymentTermsType>(); List<TradePaymentTermsType> paymentTerms = new ArrayList<TradePaymentTermsType>();