Merge pull request #83 from CSSAG/master
Interface Methodes to default; Seller- / BuyerTradeParty: ID added; removed unnessesary this/typecast code
This commit is contained in:
@@ -19,9 +19,7 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustangproject's ZUGFeRD implementation
|
* Mustangproject's ZUGFeRD implementation Neccessary interface for ZUGFeRD exporter Licensed under the APLv2
|
||||||
* Neccessary interface for ZUGFeRD exporter
|
|
||||||
* Licensed under the APLv2
|
|
||||||
*
|
*
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* @version 1.2.0
|
* @version 1.2.0
|
||||||
@@ -31,6 +29,16 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
|
|
||||||
public interface IZUGFeRDExportableContact {
|
public interface IZUGFeRDExportableContact {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* customer identification assigned by the seller
|
||||||
|
*
|
||||||
|
* @return customer identification
|
||||||
|
*/
|
||||||
|
default String getID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First and last name of the recipient
|
* First and last name of the recipient
|
||||||
*
|
*
|
||||||
@@ -38,6 +46,7 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postal code of the recipient
|
* Postal code of the recipient
|
||||||
*
|
*
|
||||||
@@ -45,6 +54,7 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*/
|
*/
|
||||||
String getZIP();
|
String getZIP();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
* VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
||||||
*
|
*
|
||||||
@@ -52,6 +62,7 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*/
|
*/
|
||||||
String getVATID();
|
String getVATID();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* two-letter country code of the contact
|
* two-letter country code of the contact
|
||||||
*
|
*
|
||||||
@@ -59,6 +70,7 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*/
|
*/
|
||||||
String getCountry();
|
String getCountry();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the city of the contact
|
* Returns the city of the contact
|
||||||
*
|
*
|
||||||
@@ -66,6 +78,7 @@ public interface IZUGFeRDExportableContact {
|
|||||||
*/
|
*/
|
||||||
String getLocation();
|
String getLocation();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the street address (street+number) of the contact
|
* Returns the street address (street+number) of the contact
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -47,46 +47,55 @@ public interface IZUGFeRDExportableTransaction {
|
|||||||
*
|
*
|
||||||
* @return invoice number
|
* @return invoice number
|
||||||
*/
|
*/
|
||||||
String getNumber();
|
default String getNumber() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the date when the invoice was created
|
* the date when the invoice was created
|
||||||
*
|
*
|
||||||
* @return when the invoice was created
|
* @return when the invoice was created
|
||||||
*/
|
*/
|
||||||
Date getIssueDate();
|
default Date getIssueDate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this should be the full sender institution name, details, manager and tax registration.
|
* this should be the full sender institution name, details, manager and tax registration. It is one of the few functions which may return null. e.g.
|
||||||
* It is one of the few functions which may return null.
|
|
||||||
* e.g.
|
|
||||||
* <p/>
|
* <p/>
|
||||||
* Lieferant GmbH
|
* Lieferant GmbH Lieferantenstraße 20 80333 München Deutschland Geschäftsführer: Hans Muster Handelsregisternummer: H A 123
|
||||||
* Lieferantenstraße 20
|
|
||||||
* 80333 München
|
|
||||||
* Deutschland
|
|
||||||
* Geschäftsführer: Hans Muster
|
|
||||||
* Handelsregisternummer: H A 123
|
|
||||||
*
|
*
|
||||||
* @return null or full sender institution name, details, manager and tax registration
|
* @return null or full sender institution name, details, manager and tax registration
|
||||||
*/
|
*/
|
||||||
String getOwnOrganisationFullPlaintextInfo();
|
default String getOwnOrganisationFullPlaintextInfo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* when the invoice is to be paid
|
* when the invoice is to be paid
|
||||||
*
|
*
|
||||||
* @return when the invoice is to be paid
|
* @return when the invoice is to be paid
|
||||||
*/
|
*/
|
||||||
Date getDueDate();
|
default Date getDueDate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
IZUGFeRDAllowanceCharge[] getZFAllowances();
|
IZUGFeRDAllowanceCharge[] getZFAllowances();
|
||||||
|
|
||||||
|
|
||||||
IZUGFeRDAllowanceCharge[] getZFCharges();
|
IZUGFeRDAllowanceCharge[] getZFCharges();
|
||||||
|
|
||||||
|
|
||||||
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
|
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
|
||||||
|
|
||||||
|
|
||||||
IZUGFeRDExportableItem[] getZFItems();
|
IZUGFeRDExportableItem[] getZFItems();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the recipient
|
* the recipient
|
||||||
*
|
*
|
||||||
@@ -94,89 +103,136 @@ public interface IZUGFeRDExportableTransaction {
|
|||||||
*/
|
*/
|
||||||
IZUGFeRDExportableContact getRecipient();
|
IZUGFeRDExportableContact getRecipient();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BIC of the sender
|
* BIC of the sender
|
||||||
*
|
*
|
||||||
* @return the BIC code of the recipient sender's bank
|
* @return the BIC code of the recipient sender's bank
|
||||||
*/
|
*/
|
||||||
String getOwnBIC();
|
default String getOwnBIC() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BLZ of the sender
|
* BLZ of the sender
|
||||||
*
|
*
|
||||||
* @return the BLZ code of the recipient sender's bank
|
* @return the BLZ code of the recipient sender's bank
|
||||||
*/
|
*/
|
||||||
String getOwnBLZ();
|
default String getOwnBLZ() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bank name of the sender
|
* Bank name of the sender
|
||||||
*
|
*
|
||||||
* @return the name of the sender's bank
|
* @return the name of the sender's bank
|
||||||
*/
|
*/
|
||||||
String getOwnBankName();
|
default String getOwnBankName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IBAN of the sender
|
* IBAN of the sender
|
||||||
*
|
*
|
||||||
* @return the IBAN of the invoice sender's bank account
|
* @return the IBAN of the invoice sender's bank account
|
||||||
*/
|
*/
|
||||||
String getOwnIBAN();
|
default String getOwnIBAN() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IBAN of the sender
|
* IBAN of the sender
|
||||||
*
|
*
|
||||||
* @return the Account Number of the invoice sender's bank account
|
* @return the Account Number of the invoice sender's bank account
|
||||||
*/
|
*/
|
||||||
String getOwnKto();
|
default String getOwnKto() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tax ID (not VAT ID) of the sender
|
* Tax ID (not VAT ID) of the sender
|
||||||
*
|
*
|
||||||
* @return Tax ID (not VAT ID) of the sender
|
* @return Tax ID (not VAT ID) of the sender
|
||||||
*/
|
*/
|
||||||
String getOwnTaxID();
|
default String getOwnTaxID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
* VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
||||||
*
|
*
|
||||||
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
||||||
*/
|
*/
|
||||||
String getOwnVATID();
|
default String getOwnVATID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* supplier identification assigned by the costumer
|
||||||
|
*
|
||||||
|
* @return the sender's identification
|
||||||
|
*/
|
||||||
|
default String getOwnForeignOrganisationID() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own name
|
* own name
|
||||||
*
|
*
|
||||||
* @return the sender's organisation name
|
* @return the sender's organisation name
|
||||||
*/
|
*/
|
||||||
String getOwnOrganisationName();
|
default String getOwnOrganisationName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own street address
|
* own street address
|
||||||
*
|
*
|
||||||
* @return sender street address
|
* @return sender street address
|
||||||
*/
|
*/
|
||||||
String getOwnStreet();
|
default String getOwnStreet() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own street postal code
|
* own street postal code
|
||||||
*
|
*
|
||||||
* @return sender postal code
|
* @return sender postal code
|
||||||
*/
|
*/
|
||||||
String getOwnZIP();
|
default String getOwnZIP() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own city
|
* own city
|
||||||
*
|
*
|
||||||
* @return the invoice sender's city
|
* @return the invoice sender's city
|
||||||
*/
|
*/
|
||||||
String getOwnLocation();
|
default String getOwnLocation() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own two digit country code
|
* own two digit country code
|
||||||
*
|
*
|
||||||
* @return the invoice senders two character country iso code
|
* @return the invoice senders two character country iso code
|
||||||
*/
|
*/
|
||||||
String getOwnCountry();
|
default String getOwnCountry() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get delivery date
|
* get delivery date
|
||||||
@@ -185,35 +241,44 @@ public interface IZUGFeRDExportableTransaction {
|
|||||||
*/
|
*/
|
||||||
Date getDeliveryDate();
|
Date getDeliveryDate();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get main invoice currency used on the invoice
|
* get main invoice currency used on the invoice
|
||||||
*
|
*
|
||||||
* @return three character currency of this invoice
|
* @return three character currency of this invoice
|
||||||
*/
|
*/
|
||||||
String getCurrency();
|
default String getCurrency() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get payment information text. e.g. Bank transfer
|
* get payment information text. e.g. Bank transfer
|
||||||
*
|
*
|
||||||
* @return payment information text
|
* @return payment information text
|
||||||
*/
|
*/
|
||||||
String getOwnPaymentInfoText();
|
default String getOwnPaymentInfoText() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get payment term descriptional text
|
* get payment term descriptional text e.g. Bis zum 22.10.2015 ohne Abzug
|
||||||
* e.g. Bis zum 22.10.2015 ohne Abzug
|
|
||||||
*
|
*
|
||||||
* @return get payment terms
|
* @return get payment terms
|
||||||
*/
|
*/
|
||||||
String getPaymentTermDescription();
|
default String getPaymentTermDescription() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get reference document number
|
* get reference document number typically used for Invoice Corrections Will be added as IncludedNote in comfort profile
|
||||||
* typically used for Invoice Corrections
|
|
||||||
* Will be added as IncludedNote in comfort profile
|
|
||||||
*
|
*
|
||||||
* @return the ID of the document this document refers to
|
* @return the ID of the document this document refers to
|
||||||
*/
|
*/
|
||||||
String getReferenceNumber();
|
default String getReferenceNumber() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,65 @@
|
|||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import org.mustangproject.ZUGFeRD.model.*;
|
|
||||||
|
|
||||||
import javax.xml.bind.JAXBElement;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBElement;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.model.AmountType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.CodeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.CountryIDType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.CreditorFinancialAccountType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.CreditorFinancialInstitutionType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.CrossIndustryDocumentType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DateTimeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DateTimeTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentContextParameterType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentContextParameterTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentLineDocumentType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.ExchangedDocumentContextType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.ExchangedDocumentType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.IDType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.IndicatorType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.LogisticsServiceChargeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.NoteType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.NoteTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.ObjectFactory;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.PaymentMeansCodeTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.PercentType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.QuantityType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.SupplyChainEventType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeAgreementType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeDeliveryType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeLineItemType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeSettlementType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.SupplyChainTradeTransactionType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxRegistrationType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxRegistrationTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxTypeCodeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TaxTypeCodeTypeConstants;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TextType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradeAddressType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradeAllowanceChargeType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradePartyType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradePaymentTermsType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradePriceType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradeProductType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradeSettlementMonetarySummationType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradeSettlementPaymentMeansType;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.TradeTaxType;
|
||||||
|
|
||||||
class ZUGFeRDTransactionModelConverter {
|
class ZUGFeRDTransactionModelConverter {
|
||||||
private static final SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
private static final SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
@@ -36,10 +87,11 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
private boolean isTest;
|
private boolean isTest;
|
||||||
private String currency = "EUR";
|
private String currency = "EUR";
|
||||||
|
|
||||||
|
|
||||||
ZUGFeRDTransactionModelConverter(IZUGFeRDExportableTransaction trans) {
|
ZUGFeRDTransactionModelConverter(IZUGFeRDExportableTransaction trans) {
|
||||||
this.trans = trans;
|
this.trans = trans;
|
||||||
totals = new Totals();
|
totals = new Totals();
|
||||||
this.currency = trans.getCurrency() != null ? trans.getCurrency() : currency;
|
currency = trans.getCurrency() != null ? trans.getCurrency() : currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -47,15 +99,15 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
CrossIndustryDocumentType invoice = xmlFactory
|
CrossIndustryDocumentType invoice = xmlFactory
|
||||||
.createCrossIndustryDocumentType();
|
.createCrossIndustryDocumentType();
|
||||||
|
|
||||||
invoice.setSpecifiedExchangedDocumentContext(this.getDocumentContext());
|
invoice.setSpecifiedExchangedDocumentContext(getDocumentContext());
|
||||||
invoice.setHeaderExchangedDocument(this.getDocument());
|
invoice.setHeaderExchangedDocument(getDocument());
|
||||||
invoice.setSpecifiedSupplyChainTradeTransaction(this
|
invoice.setSpecifiedSupplyChainTradeTransaction(getTradeTransaction());
|
||||||
.getTradeTransaction());
|
|
||||||
|
|
||||||
return xmlFactory
|
return xmlFactory
|
||||||
.createCrossIndustryDocument(invoice);
|
.createCrossIndustryDocument(invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ExchangedDocumentContextType getDocumentContext() {
|
private ExchangedDocumentContextType getDocumentContext() {
|
||||||
|
|
||||||
ExchangedDocumentContextType context = xmlFactory
|
ExchangedDocumentContextType context = xmlFactory
|
||||||
@@ -75,6 +127,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ExchangedDocumentType getDocument() {
|
private ExchangedDocumentType getDocument() {
|
||||||
|
|
||||||
ExchangedDocumentType document = xmlFactory
|
ExchangedDocumentType document = xmlFactory
|
||||||
@@ -124,36 +177,44 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SupplyChainTradeTransactionType getTradeTransaction() {
|
private SupplyChainTradeTransactionType getTradeTransaction() {
|
||||||
|
|
||||||
SupplyChainTradeTransactionType transaction = xmlFactory
|
SupplyChainTradeTransactionType transaction = xmlFactory
|
||||||
.createSupplyChainTradeTransactionType();
|
.createSupplyChainTradeTransactionType();
|
||||||
transaction.getApplicableSupplyChainTradeAgreement().add(
|
transaction.getApplicableSupplyChainTradeAgreement().add(
|
||||||
this.getTradeAgreement());
|
getTradeAgreement());
|
||||||
transaction.setApplicableSupplyChainTradeDelivery(this
|
transaction.setApplicableSupplyChainTradeDelivery(getTradeDelivery());
|
||||||
.getTradeDelivery());
|
transaction.setApplicableSupplyChainTradeSettlement(getTradeSettlement());
|
||||||
transaction.setApplicableSupplyChainTradeSettlement(this
|
|
||||||
.getTradeSettlement());
|
|
||||||
transaction.getIncludedSupplyChainTradeLineItem().addAll(
|
transaction.getIncludedSupplyChainTradeLineItem().addAll(
|
||||||
this.getLineItems());
|
getLineItems());
|
||||||
|
|
||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SupplyChainTradeAgreementType getTradeAgreement() {
|
private SupplyChainTradeAgreementType getTradeAgreement() {
|
||||||
|
|
||||||
SupplyChainTradeAgreementType tradeAgreement = xmlFactory
|
SupplyChainTradeAgreementType tradeAgreement = xmlFactory
|
||||||
.createSupplyChainTradeAgreementType();
|
.createSupplyChainTradeAgreementType();
|
||||||
|
|
||||||
tradeAgreement.setBuyerTradeParty(this.getBuyer());
|
tradeAgreement.setBuyerTradeParty(getBuyer());
|
||||||
tradeAgreement.setSellerTradeParty(this.getSeller());
|
tradeAgreement.setSellerTradeParty(getSeller());
|
||||||
|
|
||||||
return tradeAgreement;
|
return tradeAgreement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TradePartyType getBuyer() {
|
private TradePartyType getBuyer() {
|
||||||
|
|
||||||
TradePartyType buyerTradeParty = xmlFactory.createTradePartyType();
|
TradePartyType buyerTradeParty = xmlFactory.createTradePartyType();
|
||||||
|
|
||||||
|
if (trans.getRecipient().getID() != null) {
|
||||||
|
IDType buyerID = xmlFactory.createIDType();
|
||||||
|
buyerID.setValue(trans.getRecipient().getID());
|
||||||
|
buyerTradeParty.getID().add(buyerID);
|
||||||
|
}
|
||||||
|
|
||||||
TextType buyerName = xmlFactory.createTextType();
|
TextType buyerName = xmlFactory.createTextType();
|
||||||
buyerName.setValue(trans.getRecipient().getName());
|
buyerName.setValue(trans.getRecipient().getName());
|
||||||
buyerTradeParty.setName(buyerName);
|
buyerTradeParty.setName(buyerName);
|
||||||
@@ -189,9 +250,17 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return buyerTradeParty;
|
return buyerTradeParty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TradePartyType getSeller() {
|
private TradePartyType getSeller() {
|
||||||
|
|
||||||
TradePartyType sellerTradeParty = xmlFactory.createTradePartyType();
|
TradePartyType sellerTradeParty = xmlFactory.createTradePartyType();
|
||||||
|
|
||||||
|
if (trans.getOwnForeignOrganisationID() != null) {
|
||||||
|
IDType sellerID = xmlFactory.createIDType();
|
||||||
|
sellerID.setValue(trans.getOwnForeignOrganisationID());
|
||||||
|
sellerTradeParty.getID().add(sellerID);
|
||||||
|
}
|
||||||
|
|
||||||
TextType sellerName = xmlFactory.createTextType();
|
TextType sellerName = xmlFactory.createTextType();
|
||||||
sellerName.setValue(trans.getOwnOrganisationName());
|
sellerName.setValue(trans.getOwnOrganisationName());
|
||||||
sellerTradeParty.setName(sellerName);
|
sellerTradeParty.setName(sellerName);
|
||||||
@@ -238,6 +307,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return sellerTradeParty;
|
return sellerTradeParty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SupplyChainTradeDeliveryType getTradeDelivery() {
|
private SupplyChainTradeDeliveryType getTradeDelivery() {
|
||||||
|
|
||||||
SupplyChainTradeDeliveryType tradeDelivery = xmlFactory
|
SupplyChainTradeDeliveryType tradeDelivery = xmlFactory
|
||||||
@@ -257,6 +327,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return tradeDelivery;
|
return tradeDelivery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SupplyChainTradeSettlementType getTradeSettlement() {
|
private SupplyChainTradeSettlementType getTradeSettlement() {
|
||||||
SupplyChainTradeSettlementType tradeSettlement = xmlFactory
|
SupplyChainTradeSettlementType tradeSettlement = xmlFactory
|
||||||
.createSupplyChainTradeSettlementType();
|
.createSupplyChainTradeSettlementType();
|
||||||
@@ -270,29 +341,29 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
tradeSettlement.setInvoiceCurrencyCode(currencyCode);
|
tradeSettlement.setInvoiceCurrencyCode(currencyCode);
|
||||||
|
|
||||||
tradeSettlement.getSpecifiedTradeSettlementPaymentMeans().add(
|
tradeSettlement.getSpecifiedTradeSettlementPaymentMeans().add(
|
||||||
this.getPaymentData());
|
getPaymentData());
|
||||||
tradeSettlement.getApplicableTradeTax().addAll(this.getTradeTax());
|
tradeSettlement.getApplicableTradeTax().addAll(getTradeTax());
|
||||||
tradeSettlement.getSpecifiedTradePaymentTerms().addAll(
|
tradeSettlement.getSpecifiedTradePaymentTerms().addAll(
|
||||||
this.getPaymentTerms());
|
getPaymentTerms());
|
||||||
if (trans.getZFAllowances() != null) {
|
if (trans.getZFAllowances() != null) {
|
||||||
tradeSettlement.getSpecifiedTradeAllowanceCharge().addAll(
|
tradeSettlement.getSpecifiedTradeAllowanceCharge().addAll(
|
||||||
this.getHeaderAllowances());
|
getHeaderAllowances());
|
||||||
}
|
}
|
||||||
if (trans.getZFLogisticsServiceCharges() != null) {
|
if (trans.getZFLogisticsServiceCharges() != null) {
|
||||||
tradeSettlement.getSpecifiedLogisticsServiceCharge().addAll(
|
tradeSettlement.getSpecifiedLogisticsServiceCharge().addAll(
|
||||||
this.getHeaderLogisticsServiceCharges());
|
getHeaderLogisticsServiceCharges());
|
||||||
}
|
}
|
||||||
if (trans.getZFCharges() != null) {
|
if (trans.getZFCharges() != null) {
|
||||||
tradeSettlement.getSpecifiedTradeAllowanceCharge().addAll(
|
tradeSettlement.getSpecifiedTradeAllowanceCharge().addAll(
|
||||||
this.getHeaderCharges());
|
getHeaderCharges());
|
||||||
}
|
}
|
||||||
|
|
||||||
tradeSettlement.setSpecifiedTradeSettlementMonetarySummation(this
|
tradeSettlement.setSpecifiedTradeSettlementMonetarySummation(getMonetarySummation());
|
||||||
.getMonetarySummation());
|
|
||||||
|
|
||||||
return tradeSettlement;
|
return tradeSettlement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TradeSettlementPaymentMeansType getPaymentData() {
|
private TradeSettlementPaymentMeansType getPaymentData() {
|
||||||
TradeSettlementPaymentMeansType paymentData = xmlFactory
|
TradeSettlementPaymentMeansType paymentData = xmlFactory
|
||||||
.createTradeSettlementPaymentMeansType();
|
.createTradeSettlementPaymentMeansType();
|
||||||
@@ -335,6 +406,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return paymentData;
|
return paymentData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<TradeTaxType> getTradeTax() {
|
private Collection<TradeTaxType> getTradeTax() {
|
||||||
List<TradeTaxType> tradeTaxTypes = new ArrayList<>();
|
List<TradeTaxType> tradeTaxTypes = new ArrayList<>();
|
||||||
|
|
||||||
@@ -373,6 +445,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return tradeTaxTypes;
|
return tradeTaxTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<TradeAllowanceChargeType> getHeaderAllowances() {
|
private Collection<TradeAllowanceChargeType> getHeaderAllowances() {
|
||||||
List<TradeAllowanceChargeType> headerAllowances = new ArrayList<>();
|
List<TradeAllowanceChargeType> headerAllowances = new ArrayList<>();
|
||||||
|
|
||||||
@@ -419,6 +492,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return headerAllowances;
|
return headerAllowances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<TradeAllowanceChargeType> getHeaderCharges() {
|
private Collection<TradeAllowanceChargeType> getHeaderCharges() {
|
||||||
List<TradeAllowanceChargeType> headerCharges = new ArrayList<>();
|
List<TradeAllowanceChargeType> headerCharges = new ArrayList<>();
|
||||||
|
|
||||||
@@ -466,6 +540,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return headerCharges;
|
return headerCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<LogisticsServiceChargeType> getHeaderLogisticsServiceCharges() {
|
private Collection<LogisticsServiceChargeType> getHeaderLogisticsServiceCharges() {
|
||||||
List<LogisticsServiceChargeType> headerServiceCharge = new ArrayList<>();
|
List<LogisticsServiceChargeType> headerServiceCharge = new ArrayList<>();
|
||||||
|
|
||||||
@@ -511,6 +586,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return headerServiceCharge;
|
return headerServiceCharge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<TradePaymentTermsType> getPaymentTerms() {
|
private Collection<TradePaymentTermsType> getPaymentTerms() {
|
||||||
List<TradePaymentTermsType> paymentTerms = new ArrayList<>();
|
List<TradePaymentTermsType> paymentTerms = new ArrayList<>();
|
||||||
|
|
||||||
@@ -538,6 +614,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return paymentTerms;
|
return paymentTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TradeSettlementMonetarySummationType getMonetarySummation() {
|
private TradeSettlementMonetarySummationType getMonetarySummation() {
|
||||||
TradeSettlementMonetarySummationType monetarySummation = xmlFactory
|
TradeSettlementMonetarySummationType monetarySummation = xmlFactory
|
||||||
.createTradeSettlementMonetarySummationType();
|
.createTradeSettlementMonetarySummationType();
|
||||||
@@ -615,6 +692,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return monetarySummation;
|
return monetarySummation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<SupplyChainTradeLineItemType> getLineItems() {
|
private Collection<SupplyChainTradeLineItemType> getLineItems() {
|
||||||
|
|
||||||
ArrayList<SupplyChainTradeLineItemType> lineItems = new ArrayList<>();
|
ArrayList<SupplyChainTradeLineItemType> lineItems = new ArrayList<>();
|
||||||
@@ -761,22 +839,27 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return lineItems;
|
return lineItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BigDecimal vatFormat(BigDecimal value) {
|
private BigDecimal vatFormat(BigDecimal value) {
|
||||||
return nDigitFormat(value, 2);
|
return nDigitFormat(value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BigDecimal currencyFormat(BigDecimal value) {
|
private BigDecimal currencyFormat(BigDecimal value) {
|
||||||
return nDigitFormat(value, 2);
|
return nDigitFormat(value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BigDecimal priceFormat(BigDecimal value) {
|
private BigDecimal priceFormat(BigDecimal value) {
|
||||||
return nDigitFormat(value, 4);
|
return nDigitFormat(value, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BigDecimal quantityFormat(BigDecimal value) {
|
private BigDecimal quantityFormat(BigDecimal value) {
|
||||||
return nDigitFormat(value, 4);
|
return nDigitFormat(value, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private BigDecimal nDigitFormat(BigDecimal value, int scale) {
|
private BigDecimal nDigitFormat(BigDecimal value, int scale) {
|
||||||
/*
|
/*
|
||||||
* I needed 123,45, locale independent.I tried
|
* I needed 123,45, locale independent.I tried
|
||||||
@@ -821,11 +904,10 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* which taxes have been used with which amounts in this transaction, empty
|
* 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
|
||||||
* for no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable to
|
* (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT) 190 Eur
|
||||||
* 19% VAT (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT)
|
|
||||||
* 190 Eur
|
|
||||||
*
|
*
|
||||||
* @return HashMap<BigDecimal, VATAmount> which taxes have been used with which amounts
|
* @return HashMap<BigDecimal, VATAmount> which taxes have been used with which amounts
|
||||||
*/
|
*/
|
||||||
@@ -833,7 +915,8 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return getVATPercentAmountMap(false);
|
return getVATPercentAmountMap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap(Boolean itemOnly) {
|
|
||||||
|
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap(Boolean itemOnly) {
|
||||||
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
HashMap<BigDecimal, VATAmount> hm = new HashMap<>();
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
@@ -901,6 +984,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
return hm;
|
return hm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZUGFeRDTransactionModelConverter withTest(boolean isTest) {
|
ZUGFeRDTransactionModelConverter withTest(boolean isTest) {
|
||||||
this.isTest = isTest;
|
this.isTest = isTest;
|
||||||
return this;
|
return this;
|
||||||
@@ -913,6 +997,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
private BigDecimal itemTotalVATAmount;
|
private BigDecimal itemTotalVATAmount;
|
||||||
private BigDecimal itemNetAmount;
|
private BigDecimal itemNetAmount;
|
||||||
|
|
||||||
|
|
||||||
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
||||||
BigDecimal totalAllowance = BigDecimal.ZERO;
|
BigDecimal totalAllowance = BigDecimal.ZERO;
|
||||||
BigDecimal totalCharge = BigDecimal.ZERO;
|
BigDecimal totalCharge = BigDecimal.ZERO;
|
||||||
@@ -955,14 +1040,17 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
BigDecimal.ROUND_HALF_UP);
|
BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getItemTotalNetAmount() {
|
public BigDecimal getItemTotalNetAmount() {
|
||||||
return itemTotalNetAmount;
|
return itemTotalNetAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getItemTotalVATAmount() {
|
public BigDecimal getItemTotalVATAmount() {
|
||||||
return itemTotalVATAmount;
|
return itemTotalVATAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getItemNetAmount() {
|
public BigDecimal getItemNetAmount() {
|
||||||
return itemNetAmount;
|
return itemNetAmount;
|
||||||
}
|
}
|
||||||
@@ -975,6 +1063,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
private BigDecimal lineTotalAmount;
|
private BigDecimal lineTotalAmount;
|
||||||
private BigDecimal totalTaxAmount;
|
private BigDecimal totalTaxAmount;
|
||||||
|
|
||||||
|
|
||||||
public Totals() {
|
public Totals() {
|
||||||
BigDecimal res = BigDecimal.ZERO;
|
BigDecimal res = BigDecimal.ZERO;
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
@@ -982,7 +1071,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
res = res.add(lc.getItemTotalNetAmount());
|
res = res.add(lc.getItemTotalNetAmount());
|
||||||
}
|
}
|
||||||
// Set line total
|
// Set line total
|
||||||
this.lineTotalAmount = res;
|
lineTotalAmount = res;
|
||||||
|
|
||||||
if (trans.getZFAllowances() != null) {
|
if (trans.getZFAllowances() != null) {
|
||||||
for (IZUGFeRDAllowanceCharge headerAllowance : trans
|
for (IZUGFeRDAllowanceCharge headerAllowance : trans
|
||||||
@@ -1005,7 +1094,7 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set total net amount
|
// Set total net amount
|
||||||
this.totalNetAmount = res;
|
totalNetAmount = res;
|
||||||
|
|
||||||
HashMap<BigDecimal, VATAmount> vatAmountHashMap = getVATPercentAmountMap();
|
HashMap<BigDecimal, VATAmount> vatAmountHashMap = getVATPercentAmountMap();
|
||||||
for (VATAmount amount : vatAmountHashMap.values()) {
|
for (VATAmount amount : vatAmountHashMap.values()) {
|
||||||
@@ -1013,22 +1102,28 @@ class ZUGFeRDTransactionModelConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set total gross amount
|
// Set total gross amount
|
||||||
this.totalGrossAmount = res;
|
totalGrossAmount = res;
|
||||||
this.totalTaxAmount = this.totalGrossAmount.subtract(this.totalNetAmount);
|
|
||||||
|
totalTaxAmount = totalGrossAmount
|
||||||
|
.subtract(totalNetAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getTotalNet() {
|
public BigDecimal getTotalNet() {
|
||||||
return totalNetAmount;
|
return totalNetAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getTotalGross() {
|
public BigDecimal getTotalGross() {
|
||||||
return totalGrossAmount;
|
return totalGrossAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getLineTotal() {
|
public BigDecimal getLineTotal() {
|
||||||
return lineTotalAmount;
|
return lineTotalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BigDecimal getTaxTotal() {
|
public BigDecimal getTaxTotal() {
|
||||||
return totalTaxAmount;
|
return totalTaxAmount;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user