Merge pull request #292 from StefanSchmaltz/master
Vielen lieben Dank, sieht sehr gut aus, über Details müssen wir noch reden (bspw `<CrossIndustryDocument` ohne namespace prefix )
This commit is contained in:
@@ -20,15 +20,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.mustangproject;
|
package org.mustangproject;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
|
||||||
import org.mustangproject.ZUGFeRD.*;
|
|
||||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.mustangproject.ZUGFeRD.IExportableTransaction;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTradeParty;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDPaymentTerms;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlement;
|
||||||
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* An invoice, with fluent setters
|
* An invoice, with fluent setters
|
||||||
* @see IExportableTransaction if you want to implement an interface instead
|
* @see IExportableTransaction if you want to implement an interface instead
|
||||||
@@ -39,6 +45,8 @@ public class Invoice implements IExportableTransaction {
|
|||||||
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, invoiceReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
|
protected String documentName = null, documentCode = null, number = null, ownOrganisationFullPlaintextInfo = null, referenceNumber = null, shipToOrganisationID = null, shipToOrganisationName = null, shipToStreet = null, shipToZIP = null, shipToLocation = null, shipToCountry = null, buyerOrderReferencedDocumentID = null, invoiceReferencedDocumentID = null, buyerOrderReferencedDocumentIssueDateTime = null, ownForeignOrganisationID = null, ownOrganisationName = null, currency = null, paymentTermDescription = null;
|
||||||
protected Date issueDate = null, dueDate = null, deliveryDate = null;
|
protected Date issueDate = null, dueDate = null, deliveryDate = null;
|
||||||
protected BigDecimal totalPrepaidAmount = null;
|
protected BigDecimal totalPrepaidAmount = null;
|
||||||
|
protected BigDecimal grandTotalAmount = null;
|
||||||
|
protected BigDecimal duePayableAmount = null;
|
||||||
protected TradeParty sender = null, recipient = null, deliveryAddress = null;
|
protected TradeParty sender = null, recipient = null, deliveryAddress = null;
|
||||||
@JsonDeserialize(contentAs=Item.class)
|
@JsonDeserialize(contentAs=Item.class)
|
||||||
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
|
protected ArrayList<IZUGFeRDExportableItem> ZFItems = null;
|
||||||
@@ -433,6 +441,24 @@ public class Invoice implements IExportableTransaction {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getGrandTotalAmount() {
|
||||||
|
return grandTotalAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Invoice setGrandTotalAmount(BigDecimal grandTotalAmount) {
|
||||||
|
this.grandTotalAmount = grandTotalAmount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getDuePayableAmount() {
|
||||||
|
return duePayableAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Invoice setDuePayableAmount(BigDecimal duePayableAmount) {
|
||||||
|
this.duePayableAmount = duePayableAmount;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDExportableTradeParty getSender() {
|
public IZUGFeRDExportableTradeParty getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
@@ -445,6 +471,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
* @param ownContact the sender contact
|
* @param ownContact the sender contact
|
||||||
* @return fluent setter
|
* @return fluent setter
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public Invoice setOwnContact(Contact ownContact) {
|
public Invoice setOwnContact(Contact ownContact) {
|
||||||
this.sender.setContact(ownContact);
|
this.sender.setContact(ownContact);
|
||||||
return this;
|
return this;
|
||||||
@@ -689,4 +716,5 @@ public class Invoice implements IExportableTransaction {
|
|||||||
this.specifiedProcuringProjectName = specifiedProcuringProjectName;
|
this.specifiedProcuringProjectName = specifiedProcuringProjectName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,16 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
|
||||||
import org.mustangproject.ZUGFeRD.*;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTradeParty;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDLegalOrganisation;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlement;
|
||||||
|
import org.mustangproject.ZUGFeRD.IZUGFeRDTradeSettlementDebit;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* A organisation, i.e. usually a company
|
* A organisation, i.e. usually a company
|
||||||
*/
|
*/
|
||||||
@@ -136,11 +141,17 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
if (taxChilds.item(taxChildIndex).getLocalName() != null) {
|
if (taxChilds.item(taxChildIndex).getLocalName() != null) {
|
||||||
if ((taxChilds.item(taxChildIndex).getLocalName().equals("ID"))) {
|
if ((taxChilds.item(taxChildIndex).getLocalName().equals("ID"))) {
|
||||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("VA")) {
|
Node firstChild = taxChilds.item(taxChildIndex).getFirstChild();
|
||||||
setVATID(taxChilds.item(taxChildIndex).getFirstChild().getNodeValue());
|
if (firstChild != null)
|
||||||
}
|
{
|
||||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("FC")) {
|
if (taxChilds.item(taxChildIndex).getAttributes()
|
||||||
setTaxID(taxChilds.item(taxChildIndex).getFirstChild().getNodeValue());
|
.getNamedItem("schemeID").getNodeValue().equals("VA")) {
|
||||||
|
setVATID(firstChild.getNodeValue());
|
||||||
|
}
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes()
|
||||||
|
.getNamedItem("schemeID").getNodeValue().equals("FC")) {
|
||||||
|
setTaxID(firstChild.getNodeValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*
|
*
|
||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustangproject's ZUGFeRD implementation
|
* Mustangproject's ZUGFeRD implementation
|
||||||
* Neccessary interface for ZUGFeRD exporter
|
* Neccessary interface for ZUGFeRD exporter
|
||||||
@@ -26,7 +27,6 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -34,11 +34,12 @@ import org.mustangproject.FileAttachment;
|
|||||||
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
import org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* the interface of an transaction, e.g. an invoice, you want to create xml (potentially to be added to a PDF)
|
* the interface of an transaction, e.g. an invoice, you want to create xml
|
||||||
* for
|
* (potentially to be added to a PDF) for
|
||||||
|
*
|
||||||
* @see org.mustangproject.Invoice
|
* @see org.mustangproject.Invoice
|
||||||
*/
|
*/
|
||||||
public interface IExportableTransaction {
|
public interface IExportableTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name
|
* appears in /rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:Name
|
||||||
@@ -49,7 +50,6 @@ public interface IExportableTransaction {
|
|||||||
return "RECHNUNG";
|
return "RECHNUNG";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -59,7 +59,6 @@ public interface IExportableTransaction {
|
|||||||
return DocumentCodeTypeConstants.INVOICE;
|
return DocumentCodeTypeConstants.INVOICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number, typically invoice number of the invoice
|
* Number, typically invoice number of the invoice
|
||||||
*
|
*
|
||||||
@@ -69,7 +68,6 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the date when the invoice was created
|
* the date when the invoice was created
|
||||||
*
|
*
|
||||||
@@ -79,19 +77,20 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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.
|
||||||
* <p>
|
* <p>
|
||||||
* Lieferant GmbH Lieferantenstraße 20 80333 München Deutschland Geschäftsführer: Hans Muster Handelsregisternummer: H A 123
|
* Lieferant GmbH 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
|
||||||
*/
|
*/
|
||||||
default String getOwnOrganisationFullPlaintextInfo() {
|
default String getOwnOrganisationFullPlaintextInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* when the invoice is to be paid
|
* when the invoice is to be paid
|
||||||
*
|
*
|
||||||
@@ -105,7 +104,6 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the sender of the invoice
|
* the sender of the invoice
|
||||||
*
|
*
|
||||||
@@ -115,10 +113,8 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* subject of the document e.g. invoice and order
|
* subject of the document e.g. invoice and order number as human readable text
|
||||||
* number as human readable text
|
|
||||||
*
|
*
|
||||||
* @return string with document subject
|
* @return string with document subject
|
||||||
*/
|
*/
|
||||||
@@ -130,20 +126,16 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default IZUGFeRDAllowanceCharge[] getZFCharges() {
|
default IZUGFeRDAllowanceCharge[] getZFCharges() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
default IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
default IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IZUGFeRDExportableItem[] getZFItems();
|
IZUGFeRDExportableItem[] getZFItems();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the recipient
|
* the recipient
|
||||||
*
|
*
|
||||||
@@ -151,9 +143,9 @@ public interface IExportableTransaction {
|
|||||||
*/
|
*/
|
||||||
IZUGFeRDExportableTradeParty getRecipient();
|
IZUGFeRDExportableTradeParty getRecipient();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the creditors payment informations
|
* the creditors payment informations
|
||||||
|
*
|
||||||
* @deprecated use getTradeSettlement
|
* @deprecated use getTradeSettlement
|
||||||
* @return an array of IZUGFeRDTradeSettlementPayment
|
* @return an array of IZUGFeRDTradeSettlementPayment
|
||||||
*/
|
*/
|
||||||
@@ -161,6 +153,7 @@ public interface IExportableTransaction {
|
|||||||
default IZUGFeRDTradeSettlementPayment[] getTradeSettlementPayment() {
|
default IZUGFeRDTradeSettlementPayment[] getTradeSettlementPayment() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the payment information for any payment means
|
* the payment information for any payment means
|
||||||
*
|
*
|
||||||
@@ -170,35 +163,32 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
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
|
||||||
*/
|
*/
|
||||||
default String getOwnTaxID() {
|
default String getOwnTaxID() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getTaxID();
|
return getSender().getTaxID();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
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
|
||||||
*/
|
*/
|
||||||
default String getOwnVATID() {
|
default String getOwnVATID() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getVATID();
|
return getSender().getVATID();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* supplier identification assigned by the costumer
|
* supplier identification assigned by the costumer
|
||||||
*
|
*
|
||||||
@@ -208,42 +198,39 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own name
|
* own name
|
||||||
*
|
*
|
||||||
* @return the sender's organisation name
|
* @return the sender's organisation name
|
||||||
*/
|
*/
|
||||||
default String getOwnOrganisationName() {
|
default String getOwnOrganisationName() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getName();
|
return getSender().getName();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own street address
|
* own street address
|
||||||
*
|
*
|
||||||
* @return sender street address
|
* @return sender street address
|
||||||
*/
|
*/
|
||||||
default String getOwnStreet() {
|
default String getOwnStreet() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getStreet();
|
return getSender().getStreet();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own street postal code
|
* own street postal code
|
||||||
*
|
*
|
||||||
* @return sender postal code
|
* @return sender postal code
|
||||||
*/
|
*/
|
||||||
default String getOwnZIP() {
|
default String getOwnZIP() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getZIP();
|
return getSender().getZIP();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -251,14 +238,13 @@ public interface IExportableTransaction {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own city
|
* own city
|
||||||
*
|
*
|
||||||
* @return the invoice sender's city
|
* @return the invoice sender's city
|
||||||
*/
|
*/
|
||||||
default String getOwnLocation() {
|
default String getOwnLocation() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getLocation();
|
return getSender().getLocation();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -266,14 +252,13 @@ public interface IExportableTransaction {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
default String getOwnCountry() {
|
default String getOwnCountry() {
|
||||||
if (getSender()!=null) {
|
if (getSender() != null) {
|
||||||
return getSender().getCountry();
|
return getSender().getCountry();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -281,7 +266,6 @@ public interface IExportableTransaction {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get delivery date
|
* get delivery date
|
||||||
*
|
*
|
||||||
@@ -289,7 +273,6 @@ public interface IExportableTransaction {
|
|||||||
*/
|
*/
|
||||||
Date getDeliveryDate();
|
Date getDeliveryDate();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get main invoice currency used on the invoice
|
* get main invoice currency used on the invoice
|
||||||
*
|
*
|
||||||
@@ -299,7 +282,6 @@ public interface IExportableTransaction {
|
|||||||
return "EUR";
|
return "EUR";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get payment term descriptional text e.g. Bis zum 22.10.2015 ohne Abzug
|
* get payment term descriptional text e.g. Bis zum 22.10.2015 ohne Abzug
|
||||||
*
|
*
|
||||||
@@ -329,7 +311,8 @@ public interface IExportableTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get reference document number typically used for Invoice Corrections Will be added as IncludedNote in comfort profile
|
* get reference document number 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
|
||||||
*/
|
*/
|
||||||
@@ -337,9 +320,9 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consignee identification (identification of the organisation the goods are shipped to [assigned by the costumer])
|
* consignee identification (identification of the organisation the goods are
|
||||||
|
* shipped to [assigned by the costumer])
|
||||||
*
|
*
|
||||||
* @return the sender's identification
|
* @return the sender's identification
|
||||||
*/
|
*/
|
||||||
@@ -347,7 +330,6 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consignee name (name of the organisation the goods are shipped to)
|
* consignee name (name of the organisation the goods are shipped to)
|
||||||
*
|
*
|
||||||
@@ -357,9 +339,9 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consignee street address (street of the organisation the goods are shipped to)
|
* consignee street address (street of the organisation the goods are shipped
|
||||||
|
* to)
|
||||||
*
|
*
|
||||||
* @return consignee street address
|
* @return consignee street address
|
||||||
*/
|
*/
|
||||||
@@ -367,9 +349,9 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consignee street postal code (postal code of the organisation the goods are shipped to)
|
* consignee street postal code (postal code of the organisation the goods are
|
||||||
|
* shipped to)
|
||||||
*
|
*
|
||||||
* @return consignee postal code
|
* @return consignee postal code
|
||||||
*/
|
*/
|
||||||
@@ -377,7 +359,6 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consignee city (city of the organisation the goods are shipped to)
|
* consignee city (city of the organisation the goods are shipped to)
|
||||||
*
|
*
|
||||||
@@ -387,9 +368,9 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consignee two digit country code (country code of the organisation the goods are shipped to)
|
* consignee two digit country code (country code of the organisation the goods
|
||||||
|
* are shipped to)
|
||||||
*
|
*
|
||||||
* @return the consignee's two character country iso code
|
* @return the consignee's two character country iso code
|
||||||
*/
|
*/
|
||||||
@@ -397,17 +378,19 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the ID of the SellerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement/ApplicableHeaderTradeAgreement
|
* get the ID of the SellerOrderReferencedDocument, which sits in the
|
||||||
|
* ApplicableSupplyChainTradeAgreement/ApplicableHeaderTradeAgreement
|
||||||
*
|
*
|
||||||
* @return the ID of the document
|
* @return the ID of the document
|
||||||
*/
|
*/
|
||||||
default String getSellerOrderReferencedDocumentID() {
|
default String getSellerOrderReferencedDocumentID() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the ID of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement
|
* get the ID of the BuyerOrderReferencedDocument, which sits in the
|
||||||
|
* ApplicableSupplyChainTradeAgreement
|
||||||
*
|
*
|
||||||
* @return the ID of the document
|
* @return the ID of the document
|
||||||
*/
|
*/
|
||||||
@@ -416,7 +399,8 @@ public interface IExportableTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the ID of the preceding invoice, which is e.g. to be corrected if this is a correction
|
* get the ID of the preceding invoice, which is e.g. to be corrected if this is
|
||||||
|
* a correction
|
||||||
*
|
*
|
||||||
* @return the ID of the document
|
* @return the ID of the document
|
||||||
*/
|
*/
|
||||||
@@ -424,9 +408,13 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
default Date getInvoiceReferencedIssueDate(){return null;}
|
default Date getInvoiceReferencedIssueDate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the issue timestamp of the BuyerOrderReferencedDocument, which sits in the ApplicableSupplyChainTradeAgreement
|
* get the issue timestamp of the BuyerOrderReferencedDocument, which sits in
|
||||||
|
* the ApplicableSupplyChainTradeAgreement
|
||||||
*
|
*
|
||||||
* @return the IssueDateTime in format CCYY-MM-DDTHH:MM:SS
|
* @return the IssueDateTime in format CCYY-MM-DDTHH:MM:SS
|
||||||
*/
|
*/
|
||||||
@@ -434,19 +422,21 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the TotalPrepaidAmount located in SpecifiedTradeSettlementMonetarySummation (v1) or SpecifiedTradeSettlementHeaderMonetarySummation (v2)
|
* get the TotalPrepaidAmount located in
|
||||||
|
* SpecifiedTradeSettlementMonetarySummation (v1) or
|
||||||
|
* SpecifiedTradeSettlementHeaderMonetarySummation (v2)
|
||||||
*
|
*
|
||||||
* @return the total sum (incl. VAT) of prepayments, i.e. the difference between GrandTotalAmount and DuePayableAmount
|
* @return the total sum (incl. VAT) of prepayments, i.e. the difference between
|
||||||
|
* GrandTotalAmount and DuePayableAmount
|
||||||
*/
|
*/
|
||||||
default BigDecimal getTotalPrepaidAmount() {
|
default BigDecimal getTotalPrepaidAmount() {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* delivery address, i.e. ram:ShipToTradeParty (only supported for zf2)
|
* delivery address, i.e. ram:ShipToTradeParty (only supported for zf2)
|
||||||
|
*
|
||||||
* @return the IZUGFeRDExportableTradeParty delivery address
|
* @return the IZUGFeRDExportableTradeParty delivery address
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -454,9 +444,10 @@ public interface IExportableTransaction {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* specifies the document level delivery period, will be included in a BillingSpecifiedPeriod element
|
* specifies the document level delivery period, will be included in a
|
||||||
|
* BillingSpecifiedPeriod element
|
||||||
|
*
|
||||||
* @return the beginning of the delivery period
|
* @return the beginning of the delivery period
|
||||||
*/
|
*/
|
||||||
default Date getDetailedDeliveryPeriodFrom() {
|
default Date getDetailedDeliveryPeriodFrom() {
|
||||||
@@ -464,7 +455,9 @@ public interface IExportableTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* specifies the document level delivery period, will be included in a BillingSpecifiedPeriod element
|
* specifies the document level delivery period, will be included in a
|
||||||
|
* BillingSpecifiedPeriod element
|
||||||
|
*
|
||||||
* @return the end of the delivery period
|
* @return the end of the delivery period
|
||||||
*/
|
*/
|
||||||
default Date getDetailedDeliveryPeriodTo() {
|
default Date getDetailedDeliveryPeriodTo() {
|
||||||
@@ -472,8 +465,9 @@ public interface IExportableTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get additional referenced documents acccording to BG-24 XRechnung (Rechnungsbegruendende Unterlagen),
|
* get additional referenced documents acccording to BG-24 XRechnung
|
||||||
* i.e. ram:ApplicableHeaderTradeAgreement/ram:AdditionalReferencedDocument
|
* (Rechnungsbegruendende Unterlagen), i.e.
|
||||||
|
* ram:ApplicableHeaderTradeAgreement/ram:AdditionalReferencedDocument
|
||||||
*
|
*
|
||||||
* @return a array of objects from class FileAttachment
|
* @return a array of objects from class FileAttachment
|
||||||
*/
|
*/
|
||||||
@@ -484,19 +478,23 @@ public interface IExportableTransaction {
|
|||||||
default String getDespatchAdviceReferencedDocumentID() {
|
default String getDespatchAdviceReferencedDocumentID() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* additional text description
|
* additional text description
|
||||||
* @return an array of strings of document wide "includedNotes" (descriptive text values)
|
*
|
||||||
|
* @return an array of strings of document wide "includedNotes" (descriptive
|
||||||
|
* text values)
|
||||||
*/
|
*/
|
||||||
default String[] getNotes() {
|
default String[] getNotes() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getSpecifiedProcuringProjectName(){
|
default String getSpecifiedProcuringProjectName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getSpecifiedProcuringProjectID(){
|
default String getSpecifiedProcuringProjectID() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import java.math.BigDecimal;
|
|||||||
* @see TransactionCalculator
|
* @see TransactionCalculator
|
||||||
*/
|
*/
|
||||||
public class LineCalculator {
|
public class LineCalculator {
|
||||||
private BigDecimal price;
|
private final BigDecimal price;
|
||||||
private BigDecimal priceGross;
|
private final BigDecimal priceGross;
|
||||||
private BigDecimal itemTotalNetAmount;
|
private final BigDecimal itemTotalNetAmount;
|
||||||
private BigDecimal itemTotalVATAmount;
|
private final BigDecimal itemTotalVATAmount;
|
||||||
private BigDecimal allowance = BigDecimal.ZERO;
|
private BigDecimal allowance = BigDecimal.ZERO;
|
||||||
private BigDecimal charge = BigDecimal.ZERO;
|
private BigDecimal charge = BigDecimal.ZERO;
|
||||||
private BigDecimal allowanceItemTotal = BigDecimal.ZERO;
|
private BigDecimal allowanceItemTotal = BigDecimal.ZERO;
|
||||||
@@ -33,7 +33,10 @@ public class LineCalculator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(BigDecimal.valueOf(100));
|
BigDecimal vatPercent = currentItem.getProduct().getVATPercent();
|
||||||
|
if (vatPercent == null)
|
||||||
|
vatPercent = BigDecimal.ZERO;
|
||||||
|
BigDecimal multiplicator = vatPercent.divide(BigDecimal.valueOf(100));
|
||||||
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
priceGross = currentItem.getPrice(); // see https://github.com/ZUGFeRD/mustangproject/issues/159
|
||||||
price = priceGross.subtract(allowance).add(charge);
|
price = priceGross.subtract(allowance).add(charge);
|
||||||
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
itemTotalNetAmount = currentItem.getQuantity().multiply(getPrice()).divide(currentItem.getBasisQuantity())
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import java.util.HashMap;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* The Transactioncalculator e.g. adds the line totals and applies VAT on whole invoices
|
* The Transactioncalculator e.g. adds the line totals and applies VAT on whole
|
||||||
|
* invoices
|
||||||
|
*
|
||||||
* @see LineCalculator
|
* @see LineCalculator
|
||||||
*/
|
*/
|
||||||
public class TransactionCalculator implements IAbsoluteValueProvider {
|
public class TransactionCalculator implements IAbsoluteValueProvider {
|
||||||
@@ -23,7 +25,9 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* if something had already been paid in advance, this will get it from the transaction
|
* if something had already been paid in advance, this will get it from the
|
||||||
|
* transaction
|
||||||
|
*
|
||||||
* @return prepaid amount
|
* @return prepaid amount
|
||||||
*/
|
*/
|
||||||
protected BigDecimal getTotalPrepaid() {
|
protected BigDecimal getTotalPrepaid() {
|
||||||
@@ -35,20 +39,21 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* the invoice total with VAT, corrected by prepaid amount, allowances and charges
|
* the invoice total with VAT, corrected by prepaid amount, allowances and
|
||||||
|
* charges
|
||||||
|
*
|
||||||
* @return the invoice total including taxes
|
* @return the invoice total including taxes
|
||||||
*/
|
*/
|
||||||
public BigDecimal getGrandTotal() {
|
public BigDecimal getGrandTotal() {
|
||||||
|
|
||||||
final BigDecimal res = getTaxBasis();
|
final BigDecimal res = getTaxBasis();
|
||||||
return getVATPercentAmountMap().values().stream()
|
return getVATPercentAmountMap().values().stream().map(VATAmount::getCalculated)
|
||||||
.map(VATAmount::getCalculated)
|
.map(p -> p.setScale(2, RoundingMode.HALF_UP)).reduce(BigDecimal.ZERO, BigDecimal::add).add(res);
|
||||||
.map(p -> p.setScale(2, RoundingMode.HALF_UP))
|
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add).add(res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* returns total of charges for this tax rate
|
* returns total of charges for this tax rate
|
||||||
|
*
|
||||||
* @param percent a specific rate, or null for any rate
|
* @param percent a specific rate, or null for any rate
|
||||||
* @return the total amount
|
* @return the total amount
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +75,9 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* returns a (potentially concatenated) string of charge reasons, or "Charges" if none are defined
|
* returns a (potentially concatenated) string of charge reasons, or "Charges"
|
||||||
|
* if none are defined
|
||||||
|
*
|
||||||
* @param percent a specific rate, or null for any rate
|
* @param percent a specific rate, or null for any rate
|
||||||
* @return the space separated String
|
* @return the space separated String
|
||||||
*/
|
*/
|
||||||
@@ -98,7 +105,9 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* returns a (potentially concatenated) string of allowance reasons, or "Allowances", if none are defined
|
* returns a (potentially concatenated) string of allowance reasons, or
|
||||||
|
* "Allowances", if none are defined
|
||||||
|
*
|
||||||
* @param percent a specific rate, or null for any rate
|
* @param percent a specific rate, or null for any rate
|
||||||
* @return the space separated String
|
* @return the space separated String
|
||||||
*/
|
*/
|
||||||
@@ -111,9 +120,9 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* returns total of allowances for this tax rate
|
* returns total of allowances for this tax rate
|
||||||
|
*
|
||||||
* @param percent a specific rate, or null for any rate
|
* @param percent a specific rate, or null for any rate
|
||||||
* @return the total amount
|
* @return the total amount
|
||||||
*/
|
*/
|
||||||
@@ -123,24 +132,27 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* returns the total net value of all items, without document level charges/allowances
|
* returns the total net value of all items, without document level
|
||||||
|
* charges/allowances
|
||||||
|
*
|
||||||
* @return item sum
|
* @return item sum
|
||||||
*/
|
*/
|
||||||
protected BigDecimal getTotal() {
|
protected BigDecimal getTotal() {
|
||||||
BigDecimal dec = Stream.of(trans.getZFItems())
|
BigDecimal dec = Stream.of(trans.getZFItems()).map(LineCalculator::new)
|
||||||
.map(LineCalculator::new)
|
.map(LineCalculator::getItemTotalNetAmount).reduce(ZERO, BigDecimal::add);
|
||||||
.map(LineCalculator::getItemTotalNetAmount)
|
|
||||||
.reduce(ZERO, BigDecimal::add);
|
|
||||||
return dec;
|
return dec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* returns the total net value of the invoice, including charges/allowances on document
|
* returns the total net value of the invoice, including charges/allowances on
|
||||||
* level
|
* document level
|
||||||
|
*
|
||||||
* @return item sum +- charges/allowances
|
* @return item sum +- charges/allowances
|
||||||
*/
|
*/
|
||||||
protected BigDecimal getTaxBasis() {
|
protected BigDecimal getTaxBasis() {
|
||||||
return getTotal().add(getChargesForPercent(null).setScale(2, RoundingMode.HALF_UP)).subtract(getAllowancesForPercent(null).setScale(2, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP);
|
return getTotal().add(getChargesForPercent(null).setScale(2, RoundingMode.HALF_UP))
|
||||||
|
.subtract(getAllowancesForPercent(null).setScale(2, RoundingMode.HALF_UP))
|
||||||
|
.setScale(2, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,55 +167,69 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
|
|||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
||||||
LineCalculator lc = new LineCalculator(currentItem);
|
if (percent != null) {
|
||||||
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
|
LineCalculator lc = new LineCalculator(currentItem);
|
||||||
currentItem.getProduct().getTaxCategoryCode());
|
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount(),
|
||||||
VATAmount current = hm.get(percent.stripTrailingZeros());
|
currentItem.getProduct().getTaxCategoryCode());
|
||||||
if (current == null) {
|
VATAmount current = hm.get(percent.stripTrailingZeros());
|
||||||
hm.put(percent.stripTrailingZeros(), itemVATAmount);
|
if (current == null) {
|
||||||
} else {
|
hm.put(percent.stripTrailingZeros(), itemVATAmount);
|
||||||
hm.put(percent.stripTrailingZeros(), current.add(itemVATAmount));
|
} else {
|
||||||
|
hm.put(percent.stripTrailingZeros(), current.add(itemVATAmount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IZUGFeRDAllowanceCharge[] charges = trans.getZFCharges();
|
IZUGFeRDAllowanceCharge[] charges = trans.getZFCharges();
|
||||||
if ((charges != null) && (charges.length > 0)) {
|
if ((charges != null) && (charges.length > 0)) {
|
||||||
for (IZUGFeRDAllowanceCharge currentCharge : charges) {
|
for (IZUGFeRDAllowanceCharge currentCharge : charges) {
|
||||||
VATAmount theAmount = hm.get(currentCharge.getTaxPercent().stripTrailingZeros());
|
BigDecimal taxPercent = currentCharge.getTaxPercent();
|
||||||
if (theAmount == null) {
|
if (taxPercent != null) {
|
||||||
theAmount = new VATAmount(BigDecimal.ZERO, BigDecimal.ZERO,
|
VATAmount theAmount = hm.get(taxPercent.stripTrailingZeros());
|
||||||
currentCharge.getCategoryCode() != null ? currentCharge.getCategoryCode() : "S");
|
if (theAmount == null) {
|
||||||
|
theAmount = new VATAmount(BigDecimal.ZERO, BigDecimal.ZERO,
|
||||||
|
currentCharge.getCategoryCode() != null ? currentCharge.getCategoryCode() : "S");
|
||||||
|
}
|
||||||
|
theAmount.setBasis(theAmount.getBasis().add(currentCharge.getTotalAmount(this)));
|
||||||
|
BigDecimal factor = taxPercent.divide(new BigDecimal(100));
|
||||||
|
theAmount.setCalculated(theAmount.getBasis().multiply(factor));
|
||||||
|
hm.put(taxPercent.stripTrailingZeros(), theAmount);
|
||||||
}
|
}
|
||||||
theAmount.setBasis(theAmount.getBasis().add(currentCharge.getTotalAmount(this)));
|
|
||||||
BigDecimal factor = currentCharge.getTaxPercent().divide(new BigDecimal(100));
|
|
||||||
theAmount.setCalculated(theAmount.getBasis().multiply(factor));
|
|
||||||
hm.put(currentCharge.getTaxPercent().stripTrailingZeros(), theAmount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IZUGFeRDAllowanceCharge[] allowances = trans.getZFAllowances();
|
IZUGFeRDAllowanceCharge[] allowances = trans.getZFAllowances();
|
||||||
if ((allowances != null) && (allowances.length > 0)) {
|
if ((allowances != null) && (allowances.length > 0)) {
|
||||||
for (IZUGFeRDAllowanceCharge currentAllowance : allowances) {
|
for (IZUGFeRDAllowanceCharge currentAllowance : allowances) {
|
||||||
VATAmount theAmount = hm.get(currentAllowance.getTaxPercent().stripTrailingZeros());
|
BigDecimal taxPercent = currentAllowance.getTaxPercent();
|
||||||
if (theAmount == null) {
|
if (taxPercent != null) {
|
||||||
theAmount = new VATAmount(BigDecimal.ZERO, BigDecimal.ZERO,
|
VATAmount theAmount = hm.get(taxPercent.stripTrailingZeros());
|
||||||
currentAllowance.getCategoryCode() != null ? currentAllowance.getCategoryCode() : "S");
|
if (theAmount == null) {
|
||||||
}
|
theAmount = new VATAmount(BigDecimal.ZERO, BigDecimal.ZERO,
|
||||||
theAmount.setBasis(theAmount.getBasis().subtract(currentAllowance.getTotalAmount(this)));
|
currentAllowance.getCategoryCode() != null ? currentAllowance.getCategoryCode() : "S");
|
||||||
BigDecimal factor = currentAllowance.getTaxPercent().divide(new BigDecimal(100));
|
}
|
||||||
theAmount.setCalculated(theAmount.getBasis().multiply(factor));
|
theAmount.setBasis(theAmount.getBasis().subtract(currentAllowance.getTotalAmount(this)));
|
||||||
|
BigDecimal factor = taxPercent.divide(new BigDecimal(100));
|
||||||
|
theAmount.setCalculated(theAmount.getBasis().multiply(factor));
|
||||||
|
|
||||||
hm.put(currentAllowance.getTaxPercent().stripTrailingZeros(), theAmount);
|
hm.put(taxPercent.stripTrailingZeros(), theAmount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hm;
|
return hm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getValue() {
|
public BigDecimal getValue() {
|
||||||
return getTotal();
|
return getTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getChargeTotal() {
|
||||||
|
return getChargesForPercent(null).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getAllowanceTotal() {
|
||||||
|
return getAllowancesForPercent(null).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,16 +310,19 @@ public class ZUGFeRD1PullProvider extends ZUGFeRD2PullProvider implements IXMLPr
|
|||||||
xml += "<ram:SpecifiedTradeSettlementMonetarySummation>"
|
xml += "<ram:SpecifiedTradeSettlementMonetarySummation>"
|
||||||
+ "<ram:LineTotalAmount currencyID=\"" + trans.getCurrency() + "\">" + currencyFormat(calc.getTotal()) + "</ram:LineTotalAmount>"
|
+ "<ram:LineTotalAmount currencyID=\"" + trans.getCurrency() + "\">" + currencyFormat(calc.getTotal()) + "</ram:LineTotalAmount>"
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
+ "<ram:ChargeTotalAmount currencyID=\"" + trans.getCurrency() + "\">0.00</ram:ChargeTotalAmount>" // currencyID=\"EUR\"
|
+ "<ram:ChargeTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
||||||
+ "<ram:AllowanceTotalAmount currencyID=\"" + trans.getCurrency() + "\">0.00</ram:AllowanceTotalAmount>" //
|
+ currencyFormat(calc.getChargeTotal()) + "</ram:ChargeTotalAmount>" // currencyID=\"EUR\"
|
||||||
|
+ "<ram:AllowanceTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
||||||
|
+ currencyFormat(calc.getAllowanceTotal()) + "</ram:AllowanceTotalAmount>" //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>"
|
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>"
|
||||||
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>"
|
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>"
|
||||||
+ "<ram:TaxBasisTotalAmount currencyID=\"" + trans.getCurrency() + "\">" + currencyFormat(calc.getTotal()) + "</ram:TaxBasisTotalAmount>"
|
+ "<ram:TaxBasisTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
||||||
|
+ currencyFormat(calc.getTaxBasis()) + "</ram:TaxBasisTotalAmount>"
|
||||||
// //
|
// //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
+ "<ram:TaxTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
+ "<ram:TaxTotalAmount currencyID=\"" + trans.getCurrency() + "\">"
|
||||||
+ currencyFormat(calc.getGrandTotal().subtract(calc.getTotal())) + "</ram:TaxTotalAmount>"
|
+ currencyFormat(calc.getGrandTotal().subtract(calc.getTaxBasis())) + "</ram:TaxTotalAmount>"
|
||||||
+ "<ram:GrandTotalAmount currencyID=\"" + trans.getCurrency() + "\">" + currencyFormat(calc.getGrandTotal()) + "</ram:GrandTotalAmount>"
|
+ "<ram:GrandTotalAmount currencyID=\"" + trans.getCurrency() + "\">" + currencyFormat(calc.getGrandTotal()) + "</ram:GrandTotalAmount>"
|
||||||
// //
|
// //
|
||||||
// currencyID=\"EUR\"
|
// currencyID=\"EUR\"
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class ZUGFeRDImporter {
|
|||||||
/**
|
/**
|
||||||
* map filenames of additional XML files to their contents
|
* map filenames of additional XML files to their contents
|
||||||
*/
|
*/
|
||||||
private HashMap<String, byte[]> additionalXMLs = new HashMap<>();
|
private final HashMap<String, byte[]> additionalXMLs = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* Raw XML form of the extracted data - may be directly obtained.
|
* Raw XML form of the extracted data - may be directly obtained.
|
||||||
*/
|
*/
|
||||||
@@ -76,6 +76,7 @@ public class ZUGFeRDImporter {
|
|||||||
* parsed Document
|
* parsed Document
|
||||||
*/
|
*/
|
||||||
private Document document;
|
private Document document;
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
|
||||||
protected ZUGFeRDImporter() {
|
protected ZUGFeRDImporter() {
|
||||||
@@ -193,6 +194,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
public void setRawXML(byte[] rawXML) throws IOException {
|
public void setRawXML(byte[] rawXML) throws IOException {
|
||||||
this.rawXML = rawXML;
|
this.rawXML = rawXML;
|
||||||
|
this.version = null;
|
||||||
try {
|
try {
|
||||||
setDocument();
|
setDocument();
|
||||||
} catch (ParserConfigurationException | SAXException e) {
|
} catch (ParserConfigurationException | SAXException e) {
|
||||||
@@ -656,13 +658,16 @@ public class ZUGFeRDImporter {
|
|||||||
if (!containsMeta) {
|
if (!containsMeta) {
|
||||||
throw new Exception("Not yet parsed");
|
throw new Exception("Not yet parsed");
|
||||||
}
|
}
|
||||||
if (getUTF8().contains("<rsm:CrossIndustryDocument")) {
|
String head = getUTF8();
|
||||||
|
if (head.contains("<rsm:CrossIndustryDocument")) {
|
||||||
return EStandard.zugferd;
|
return EStandard.zugferd;
|
||||||
} else if (getUTF8().contains("<rsm:CrossIndustryInvoice")) {
|
} else if (head.contains("<CrossIndustryDocument")) {
|
||||||
|
return EStandard.zugferd;
|
||||||
|
} else if (head.contains("<urn:rsm:CrossIndustryInvoice") || head.contains("<rsm:CrossIndustryInvoice")) {
|
||||||
return EStandard.facturx;
|
return EStandard.facturx;
|
||||||
} else if (getUTF8().contains("<SCRDMCCBDACIDAMessageStructure")) {
|
} else if (head.contains("<SCRDMCCBDACIDAMessageStructure")) {
|
||||||
return EStandard.despatchadvice;
|
return EStandard.despatchadvice;
|
||||||
} else if (getUTF8().contains("<rsm:SCRDMCCBDACIOMessageStructure")) {
|
} else if (head.contains("<rsm:SCRDMCCBDACIOMessageStructure")) {
|
||||||
return EStandard.orderx;
|
return EStandard.orderx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,12 +678,21 @@ public class ZUGFeRDImporter {
|
|||||||
if (!containsMeta) {
|
if (!containsMeta) {
|
||||||
throw new Exception("Not yet parsed");
|
throw new Exception("Not yet parsed");
|
||||||
}
|
}
|
||||||
if (getUTF8().contains("<rsm:CrossIndustryDocument")||getUTF8().contains("<SCRDMCCBDACIDAMessageStructure")||getUTF8().contains("<rsm:SCRDMCCBDACIOMessageStructure")) {
|
if (version != null)
|
||||||
return 1;
|
return version;
|
||||||
} else if (getUTF8().contains("<rsm:CrossIndustryInvoice")) {
|
|
||||||
return 2;
|
String head = getUTF8();
|
||||||
|
if (head.contains("<rsm:CrossIndustryDocument") //
|
||||||
|
|| head.contains("<CrossIndustryDocument") //
|
||||||
|
|| head.contains("<SCRDMCCBDACIDAMessageStructure") //
|
||||||
|
|| head.contains("<rsm:SCRDMCCBDACIOMessageStructure")) { //
|
||||||
|
version = 1;
|
||||||
|
} else if (head.contains("<rsm:CrossIndustryInvoice")) {
|
||||||
|
version = 2;
|
||||||
}
|
}
|
||||||
throw new Exception("ZUGFeRD version could not be determined");
|
else
|
||||||
|
throw new Exception("ZUGFeRD version could not be determined");
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
|
|
||||||
import org.mustangproject.*;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
import javax.xml.xpath.*;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@@ -17,6 +9,27 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.xml.xpath.XPath;
|
||||||
|
import javax.xml.xpath.XPathConstants;
|
||||||
|
import javax.xml.xpath.XPathExpression;
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
|
import org.mustangproject.Allowance;
|
||||||
|
import org.mustangproject.Charge;
|
||||||
|
import org.mustangproject.EStandard;
|
||||||
|
import org.mustangproject.Invoice;
|
||||||
|
import org.mustangproject.Item;
|
||||||
|
import org.mustangproject.Product;
|
||||||
|
import org.mustangproject.ReferencedDocument;
|
||||||
|
import org.mustangproject.SchemedID;
|
||||||
|
import org.mustangproject.TradeParty;
|
||||||
|
import org.mustangproject.XMLTools;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ZUGFeRDInvoiceImporter.class.getCanonicalName()); // log
|
private static final Logger LOGGER = LoggerFactory.getLogger(ZUGFeRDInvoiceImporter.class.getCanonicalName()); // log
|
||||||
private boolean recalcPrice = false;
|
private boolean recalcPrice = false;
|
||||||
@@ -41,31 +54,29 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
|
|
||||||
/***
|
/***
|
||||||
* This will parse a XML into a invoice object
|
* This will parse a XML into a invoice object
|
||||||
|
*
|
||||||
* @return the parsed invoice object
|
* @return the parsed invoice object
|
||||||
*/
|
*/
|
||||||
public Invoice extractInvoice() throws XPathExpressionException, ParseException {
|
public Invoice extractInvoice() throws XPathExpressionException, ParseException {
|
||||||
|
|
||||||
String number = "";
|
String number = "";
|
||||||
/*
|
/*
|
||||||
* dummywerte sind derzeit noch setDueDate setIssueDate setDeliveryDate setSender setRecipient setnumber
|
* dummywerte sind derzeit noch setDueDate setIssueDate setDeliveryDate
|
||||||
* bspw. due date //ExchangedDocument//IssueDateTime//DateTimeString : due date optional
|
* setSender setRecipient setnumber bspw. due date
|
||||||
|
* //ExchangedDocument//IssueDateTime//DateTimeString : due date optional
|
||||||
*/
|
*/
|
||||||
XPathFactory xpathFact = XPathFactory.newInstance();
|
XPathFactory xpathFact = XPathFactory.newInstance();
|
||||||
XPath xpath = xpathFact.newXPath();
|
XPath xpath = xpathFact.newXPath();
|
||||||
Invoice zpp = null;
|
Invoice zpp = null;
|
||||||
XPathExpression xpr = xpath.compile(
|
XPathExpression xpr = xpath.compile("//*[local-name()=\"SellerTradeParty\"]");
|
||||||
"//*[local-name()=\"SellerTradeParty\"]");
|
|
||||||
NodeList SellerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList SellerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
xpr = xpath.compile(
|
xpr = xpath.compile("//*[local-name()=\"BuyerTradeParty\"]");
|
||||||
"//*[local-name()=\"BuyerTradeParty\"]");
|
|
||||||
NodeList BuyerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList BuyerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
xpr = xpath.compile(
|
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]");
|
||||||
"//*[local-name()=\"ExchangedDocument\"]");
|
|
||||||
NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
xpr = xpath.compile(
|
xpr = xpath.compile("//*[local-name()=\"GrandTotalAmount\"]");
|
||||||
"//*[local-name()=\"GrandTotalAmount\"]");
|
|
||||||
BigDecimal expectedGrandTotal = null;
|
BigDecimal expectedGrandTotal = null;
|
||||||
NodeList totalNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList totalNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
if (totalNodes.getLength() > 0) {
|
if (totalNodes.getLength() > 0) {
|
||||||
@@ -77,42 +88,57 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
Date deliveryDate = null;
|
Date deliveryDate = null;
|
||||||
for (int i = 0; i < ExchangedDocumentNodes.getLength(); i++) {
|
for (int i = 0; i < ExchangedDocumentNodes.getLength(); i++) {
|
||||||
|
|
||||||
//nodes.item(i).getTextContent())) {
|
// nodes.item(i).getTextContent())) {
|
||||||
Node exchangedDocumentNode = ExchangedDocumentNodes.item(i);
|
Node exchangedDocumentNode = ExchangedDocumentNodes.item(i);
|
||||||
NodeList exchangedDocumentChilds = exchangedDocumentNode.getChildNodes();
|
NodeList exchangedDocumentChilds = exchangedDocumentNode.getChildNodes();
|
||||||
for (int documentChildIndex = 0; documentChildIndex < exchangedDocumentChilds.getLength(); documentChildIndex++) {
|
for (int documentChildIndex = 0; documentChildIndex < exchangedDocumentChilds
|
||||||
if ((exchangedDocumentChilds.item(documentChildIndex).getLocalName() != null) && (exchangedDocumentChilds.item(documentChildIndex).getLocalName().equals("ID"))) {
|
.getLength(); documentChildIndex++) {
|
||||||
number = exchangedDocumentChilds.item(documentChildIndex).getTextContent();
|
Node item = exchangedDocumentChilds.item(documentChildIndex);
|
||||||
|
if ((item.getLocalName() != null) && (item.getLocalName().equals("ID"))) {
|
||||||
|
number = item.getTextContent();
|
||||||
}
|
}
|
||||||
if ((exchangedDocumentChilds.item(documentChildIndex).getLocalName() != null) && (exchangedDocumentChilds.item(documentChildIndex).getLocalName().equals("IssueDateTime"))) {
|
if ((item.getLocalName() != null) && (item.getLocalName().equals("IssueDateTime"))) {
|
||||||
NodeList issueDateTimeChilds = exchangedDocumentChilds.item(documentChildIndex).getChildNodes();
|
NodeList issueDateTimeChilds = item.getChildNodes();
|
||||||
for (int issueDateChildIndex = 0; issueDateChildIndex < issueDateTimeChilds.getLength(); issueDateChildIndex++) {
|
for (int issueDateChildIndex = 0; issueDateChildIndex < issueDateTimeChilds
|
||||||
if ((issueDateTimeChilds.item(issueDateChildIndex).getLocalName() != null) && (issueDateTimeChilds.item(issueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
.getLength(); issueDateChildIndex++) {
|
||||||
issueDate = new SimpleDateFormat("yyyyMMdd").parse(issueDateTimeChilds.item(issueDateChildIndex).getTextContent());
|
if ((issueDateTimeChilds.item(issueDateChildIndex).getLocalName() != null)
|
||||||
|
&& (issueDateTimeChilds.item(issueDateChildIndex).getLocalName()
|
||||||
|
.equals("DateTimeString"))) {
|
||||||
|
issueDate = new SimpleDateFormat("yyyyMMdd")
|
||||||
|
.parse(issueDateTimeChilds.item(issueDateChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeDelivery\"]");
|
||||||
xpr = xpath.compile(
|
|
||||||
"//*[local-name()=\"ApplicableHeaderTradeDelivery\"]");
|
|
||||||
NodeList headerTradeDeliveryNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList headerTradeDeliveryNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
for (int i = 0; i < headerTradeDeliveryNodes.getLength(); i++) {
|
for (int i = 0; i < headerTradeDeliveryNodes.getLength(); i++) {
|
||||||
//nodes.item(i).getTextContent())) {
|
// nodes.item(i).getTextContent())) {
|
||||||
Node headerTradeDeliveryNode = headerTradeDeliveryNodes.item(i);
|
Node headerTradeDeliveryNode = headerTradeDeliveryNodes.item(i);
|
||||||
NodeList headerTradeDeliveryChilds = headerTradeDeliveryNode.getChildNodes();
|
NodeList headerTradeDeliveryChilds = headerTradeDeliveryNode.getChildNodes();
|
||||||
for (int deliveryChildIndex = 0; deliveryChildIndex < headerTradeDeliveryChilds.getLength(); deliveryChildIndex++) {
|
for (int deliveryChildIndex = 0; deliveryChildIndex < headerTradeDeliveryChilds
|
||||||
if ((headerTradeDeliveryChilds.item(deliveryChildIndex).getLocalName() != null) && (headerTradeDeliveryChilds.item(deliveryChildIndex).getLocalName().equals("ActualDeliverySupplyChainEvent"))) {
|
.getLength(); deliveryChildIndex++) {
|
||||||
|
if ((headerTradeDeliveryChilds.item(deliveryChildIndex).getLocalName() != null)
|
||||||
|
&& (headerTradeDeliveryChilds.item(deliveryChildIndex).getLocalName()
|
||||||
|
.equals("ActualDeliverySupplyChainEvent"))) {
|
||||||
NodeList actualDeliveryChilds = headerTradeDeliveryChilds.item(deliveryChildIndex).getChildNodes();
|
NodeList actualDeliveryChilds = headerTradeDeliveryChilds.item(deliveryChildIndex).getChildNodes();
|
||||||
for (int actualDeliveryChildIndex = 0; actualDeliveryChildIndex < actualDeliveryChilds.getLength(); actualDeliveryChildIndex++) {
|
for (int actualDeliveryChildIndex = 0; actualDeliveryChildIndex < actualDeliveryChilds
|
||||||
if ((actualDeliveryChilds.item(actualDeliveryChildIndex).getLocalName() != null) && (actualDeliveryChilds.item(actualDeliveryChildIndex).getLocalName().equals("OccurrenceDateTime"))) {
|
.getLength(); actualDeliveryChildIndex++) {
|
||||||
NodeList occurenceChilds = actualDeliveryChilds.item(actualDeliveryChildIndex).getChildNodes();
|
if ((actualDeliveryChilds.item(actualDeliveryChildIndex).getLocalName() != null)
|
||||||
for (int occurenceChildIndex = 0; occurenceChildIndex < occurenceChilds.getLength(); occurenceChildIndex++) {
|
&& (actualDeliveryChilds.item(actualDeliveryChildIndex).getLocalName()
|
||||||
if ((occurenceChilds.item(occurenceChildIndex).getLocalName() != null) && (occurenceChilds.item(occurenceChildIndex).getLocalName().equals("DateTimeString"))) {
|
.equals("OccurrenceDateTime"))) {
|
||||||
deliveryDate = new SimpleDateFormat("yyyyMMdd").parse(occurenceChilds.item(occurenceChildIndex).getTextContent());
|
NodeList occurenceChilds = actualDeliveryChilds.item(actualDeliveryChildIndex)
|
||||||
|
.getChildNodes();
|
||||||
|
for (int occurenceChildIndex = 0; occurenceChildIndex < occurenceChilds
|
||||||
|
.getLength(); occurenceChildIndex++) {
|
||||||
|
if ((occurenceChilds.item(occurenceChildIndex).getLocalName() != null)
|
||||||
|
&& (occurenceChilds.item(occurenceChildIndex).getLocalName()
|
||||||
|
.equals("DateTimeString"))) {
|
||||||
|
deliveryDate = new SimpleDateFormat("yyyyMMdd")
|
||||||
|
.parse(occurenceChilds.item(occurenceChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,24 +147,30 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]");
|
||||||
xpr = xpath.compile(
|
|
||||||
"//*[local-name()=\"ApplicableHeaderTradeSettlement\"]");
|
|
||||||
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
||||||
//nodes.item(i).getTextContent())) {
|
// nodes.item(i).getTextContent())) {
|
||||||
Node headerTradeSettlementNode = headerTradeSettlementNodes.item(i);
|
Node headerTradeSettlementNode = headerTradeSettlementNodes.item(i);
|
||||||
NodeList headerTradeSettlementChilds = headerTradeSettlementNode.getChildNodes();
|
NodeList headerTradeSettlementChilds = headerTradeSettlementNode.getChildNodes();
|
||||||
for (int settlementChildIndex = 0; settlementChildIndex < headerTradeSettlementChilds.getLength(); settlementChildIndex++) {
|
for (int settlementChildIndex = 0; settlementChildIndex < headerTradeSettlementChilds
|
||||||
if ((headerTradeSettlementChilds.item(settlementChildIndex).getLocalName() != null) && (headerTradeSettlementChilds.item(settlementChildIndex).getLocalName().equals("SpecifiedTradePaymentTerms"))) {
|
.getLength(); settlementChildIndex++) {
|
||||||
|
if ((headerTradeSettlementChilds.item(settlementChildIndex).getLocalName() != null)
|
||||||
|
&& (headerTradeSettlementChilds.item(settlementChildIndex).getLocalName()
|
||||||
|
.equals("SpecifiedTradePaymentTerms"))) {
|
||||||
NodeList paymentTermChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes();
|
NodeList paymentTermChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes();
|
||||||
for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds.getLength(); paymentTermChildIndex++) {
|
for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds
|
||||||
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("DueDateDateTime"))) {
|
.getLength(); paymentTermChildIndex++) {
|
||||||
|
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds
|
||||||
|
.item(paymentTermChildIndex).getLocalName().equals("DueDateDateTime"))) {
|
||||||
NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes();
|
NodeList dueDateChilds = paymentTermChilds.item(paymentTermChildIndex).getChildNodes();
|
||||||
for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds.getLength(); dueDateChildIndex++) {
|
for (int dueDateChildIndex = 0; dueDateChildIndex < dueDateChilds
|
||||||
if ((dueDateChilds.item(dueDateChildIndex).getLocalName() != null) && (dueDateChilds.item(dueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
.getLength(); dueDateChildIndex++) {
|
||||||
dueDate = new SimpleDateFormat("yyyyMMdd").parse(dueDateChilds.item(dueDateChildIndex).getTextContent());
|
if ((dueDateChilds.item(dueDateChildIndex).getLocalName() != null) && (dueDateChilds
|
||||||
|
.item(dueDateChildIndex).getLocalName().equals("DateTimeString"))) {
|
||||||
|
dueDate = new SimpleDateFormat("yyyyMMdd")
|
||||||
|
.parse(dueDateChilds.item(dueDateChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,11 +179,11 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zpp = new Invoice().setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate).setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number);
|
zpp = new Invoice().setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate)
|
||||||
|
.setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number);
|
||||||
//.addItem(new Item(new Product("Testprodukt","","C62",BigDecimal.ZERO),amount,new BigDecimal(1.0)))
|
//.addItem(new Item(new Product("Testprodukt","","C62",BigDecimal.ZERO),amount,new BigDecimal(1.0)))
|
||||||
zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]"));
|
zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]"));
|
||||||
xpr = xpath.compile(
|
xpr = xpath.compile("//*[local-name()=\"IncludedSupplyChainTradeLineItem\"]");
|
||||||
"//*[local-name()=\"IncludedSupplyChainTradeLineItem\"]");
|
|
||||||
NodeList nodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList nodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
if (nodes.getLength() == 0) {
|
if (nodes.getLength() == 0) {
|
||||||
@@ -163,39 +195,45 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
String description = "";
|
String description = "";
|
||||||
SchemedID gid = null;
|
SchemedID gid = null;
|
||||||
String quantity = "0";
|
String quantity = "0";
|
||||||
String vatPercent = "0";
|
String vatPercent = null;
|
||||||
String lineTotal = "0";
|
String lineTotal = "0";
|
||||||
String unitCode = "0";
|
String unitCode = "0";
|
||||||
|
|
||||||
ArrayList<ReferencedDocument> rdocs = null;
|
ArrayList<ReferencedDocument> rdocs = null;
|
||||||
|
|
||||||
//nodes.item(i).getTextContent())) {
|
// nodes.item(i).getTextContent())) {
|
||||||
Node currentItemNode = nodes.item(i);
|
Node currentItemNode = nodes.item(i);
|
||||||
NodeList itemChilds = currentItemNode.getChildNodes();
|
NodeList itemChilds = currentItemNode.getChildNodes();
|
||||||
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
||||||
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeAgreement"))) {
|
String lineTrade = itemChilds.item(itemChildIndex).getLocalName();
|
||||||
|
if ((lineTrade != null) && (lineTrade.equals("SpecifiedLineTradeAgreement")
|
||||||
|
|| lineTrade.equals("SpecifiedSupplyChainTradeAgreement"))) {
|
||||||
NodeList tradeLineChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList tradeLineChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
for (int tradeLineChildIndex = 0; tradeLineChildIndex < tradeLineChilds.getLength(); tradeLineChildIndex++) {
|
for (int tradeLineChildIndex = 0; tradeLineChildIndex < tradeLineChilds
|
||||||
|
.getLength(); tradeLineChildIndex++) {
|
||||||
|
|
||||||
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("AdditionalReferencedDocument")) {
|
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && tradeLineChilds
|
||||||
|
.item(tradeLineChildIndex).getLocalName().equals("AdditionalReferencedDocument")) {
|
||||||
String IssuerAssignedID = "";
|
String IssuerAssignedID = "";
|
||||||
String TypeCode = "";
|
String TypeCode = "";
|
||||||
String ReferenceTypeCode = "";
|
String ReferenceTypeCode = "";
|
||||||
|
|
||||||
NodeList refDocChilds = tradeLineChilds.item(tradeLineChildIndex).getChildNodes();
|
NodeList refDocChilds = tradeLineChilds.item(tradeLineChildIndex).getChildNodes();
|
||||||
for (int refDocIndex = 0; refDocIndex < refDocChilds.getLength(); refDocIndex++) {
|
for (int refDocIndex = 0; refDocIndex < refDocChilds.getLength(); refDocIndex++) {
|
||||||
if ((refDocChilds.item(refDocIndex).getLocalName() != null) && (refDocChilds.item(refDocIndex).getLocalName().equals("IssuerAssignedID"))) {
|
String localName = refDocChilds.item(refDocIndex).getLocalName();
|
||||||
|
if ((localName != null) && (localName.equals("IssuerAssignedID"))) {
|
||||||
IssuerAssignedID = refDocChilds.item(refDocIndex).getTextContent();
|
IssuerAssignedID = refDocChilds.item(refDocIndex).getTextContent();
|
||||||
}
|
}
|
||||||
if ((refDocChilds.item(refDocIndex).getLocalName() != null) && (refDocChilds.item(refDocIndex).getLocalName().equals("TypeCode"))) {
|
if ((localName != null) && (localName.equals("TypeCode"))) {
|
||||||
TypeCode = refDocChilds.item(refDocIndex).getTextContent();
|
TypeCode = refDocChilds.item(refDocIndex).getTextContent();
|
||||||
}
|
}
|
||||||
if ((refDocChilds.item(refDocIndex).getLocalName() != null) && (refDocChilds.item(refDocIndex).getLocalName().equals("ReferenceTypeCode"))) {
|
if ((localName != null) && (localName.equals("ReferenceTypeCode"))) {
|
||||||
ReferenceTypeCode = refDocChilds.item(refDocIndex).getTextContent();
|
ReferenceTypeCode = refDocChilds.item(refDocIndex).getTextContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferencedDocument rd = new ReferencedDocument(IssuerAssignedID, TypeCode, ReferenceTypeCode);
|
ReferencedDocument rd = new ReferencedDocument(IssuerAssignedID, TypeCode,
|
||||||
|
ReferenceTypeCode);
|
||||||
if (rdocs == null) {
|
if (rdocs == null) {
|
||||||
rdocs = new ArrayList<ReferencedDocument>();
|
rdocs = new ArrayList<ReferencedDocument>();
|
||||||
}
|
}
|
||||||
@@ -203,59 +241,87 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("NetPriceProductTradePrice")) {
|
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && tradeLineChilds
|
||||||
|
.item(tradeLineChildIndex).getLocalName().equals("NetPriceProductTradePrice")) {
|
||||||
NodeList netChilds = tradeLineChilds.item(tradeLineChildIndex).getChildNodes();
|
NodeList netChilds = tradeLineChilds.item(tradeLineChildIndex).getChildNodes();
|
||||||
for (int netIndex = 0; netIndex < netChilds.getLength(); netIndex++) {
|
for (int netIndex = 0; netIndex < netChilds.getLength(); netIndex++) {
|
||||||
if ((netChilds.item(netIndex).getLocalName() != null) && (netChilds.item(netIndex).getLocalName().equals("ChargeAmount"))) {
|
if ((netChilds.item(netIndex).getLocalName() != null)
|
||||||
price = netChilds.item(netIndex).getTextContent();//ChargeAmount
|
&& (netChilds.item(netIndex).getLocalName().equals("ChargeAmount"))) {
|
||||||
|
price = netChilds.item(netIndex).getTextContent();// ChargeAmount
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeDelivery"))) {
|
if ((lineTrade != null) && (lineTrade.equals("SpecifiedLineTradeDelivery")
|
||||||
|
|| lineTrade.equals("SpecifiedSupplyChainTradeDelivery"))) {
|
||||||
NodeList tradeLineChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList tradeLineChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
for (int tradeLineChildIndex = 0; tradeLineChildIndex < tradeLineChilds.getLength(); tradeLineChildIndex++) {
|
for (int tradeLineChildIndex = 0; tradeLineChildIndex < tradeLineChilds
|
||||||
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && (tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("BilledQuantity") || tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("RequestedQuantity") || tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("DespatchedQuantity"))) {
|
.getLength(); tradeLineChildIndex++) {
|
||||||
//RequestedQuantity is for Order-X, BilledQuantity for FX and ZF
|
String tradeName = tradeLineChilds.item(tradeLineChildIndex).getLocalName();
|
||||||
|
if ((tradeName != null)
|
||||||
|
&& (tradeName.equals("BilledQuantity") || tradeName.equals("RequestedQuantity")
|
||||||
|
|| tradeName.equals("DespatchedQuantity"))) {
|
||||||
|
// RequestedQuantity is for Order-X, BilledQuantity for FX and ZF
|
||||||
quantity = tradeLineChilds.item(tradeLineChildIndex).getTextContent();
|
quantity = tradeLineChilds.item(tradeLineChildIndex).getTextContent();
|
||||||
unitCode = tradeLineChilds.item(tradeLineChildIndex).getAttributes().getNamedItem("unitCode").getNodeValue();
|
unitCode = tradeLineChilds.item(tradeLineChildIndex).getAttributes()
|
||||||
|
.getNamedItem("unitCode").getNodeValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedTradeProduct"))) {
|
if ((lineTrade != null) && (lineTrade.equals("SpecifiedTradeProduct"))) {
|
||||||
NodeList tradeProductChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList tradeProductChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
for (int tradeProductChildIndex = 0; tradeProductChildIndex < tradeProductChilds.getLength(); tradeProductChildIndex++) {
|
for (int tradeProductChildIndex = 0; tradeProductChildIndex < tradeProductChilds
|
||||||
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null) && (tradeProductChilds.item(tradeProductChildIndex).getLocalName().equals("Name"))) {
|
.getLength(); tradeProductChildIndex++) {
|
||||||
|
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null)
|
||||||
|
&& (tradeProductChilds.item(tradeProductChildIndex).getLocalName()
|
||||||
|
.equals("Name"))) {
|
||||||
name = tradeProductChilds.item(tradeProductChildIndex).getTextContent();
|
name = tradeProductChilds.item(tradeProductChildIndex).getTextContent();
|
||||||
}
|
}
|
||||||
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null) && (tradeProductChilds.item(tradeProductChildIndex).getLocalName().equals("GlobalID"))) {
|
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null)
|
||||||
if (tradeProductChilds.item(tradeProductChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
&& (tradeProductChilds.item(tradeProductChildIndex).getLocalName()
|
||||||
gid = new SchemedID().setScheme(tradeProductChilds.item(tradeProductChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(tradeProductChilds.item(tradeProductChildIndex).getTextContent());
|
.equals("GlobalID"))) {
|
||||||
|
if (tradeProductChilds.item(tradeProductChildIndex).getAttributes()
|
||||||
|
.getNamedItem("schemeID") != null) {
|
||||||
|
gid = new SchemedID()
|
||||||
|
.setScheme(tradeProductChilds.item(tradeProductChildIndex).getAttributes()
|
||||||
|
.getNamedItem("schemeID").getNodeValue())
|
||||||
|
.setId(tradeProductChilds.item(tradeProductChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeSettlement"))) {
|
if ((lineTrade != null) && (lineTrade.equals("SpecifiedLineTradeSettlement")
|
||||||
|
|| lineTrade.equals("SpecifiedSupplyChainTradeSettlement"))) {
|
||||||
NodeList tradeSettlementChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList tradeSettlementChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
for (int tradeSettlementChildIndex = 0; tradeSettlementChildIndex < tradeSettlementChilds.getLength(); tradeSettlementChildIndex++) {
|
for (int tradeSettlementChildIndex = 0; tradeSettlementChildIndex < tradeSettlementChilds
|
||||||
|
.getLength(); tradeSettlementChildIndex++) {
|
||||||
|
|
||||||
if (tradeSettlementChilds.item(tradeSettlementChildIndex).getLocalName() != null) {
|
String tradeSettlementName = tradeSettlementChilds.item(tradeSettlementChildIndex)
|
||||||
if (tradeSettlementChilds.item(tradeSettlementChildIndex).getLocalName().equals("ApplicableTradeTax")) {
|
.getLocalName();
|
||||||
NodeList taxChilds = tradeSettlementChilds.item(tradeSettlementChildIndex).getChildNodes();
|
if (tradeSettlementName != null) {
|
||||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
if (tradeSettlementName.equals("ApplicableTradeTax")) {
|
||||||
if ((taxChilds.item(taxChildIndex).getLocalName() != null) && (taxChilds.item(taxChildIndex).getLocalName().equals("RateApplicablePercent"))) {
|
NodeList taxChilds = tradeSettlementChilds.item(tradeSettlementChildIndex)
|
||||||
|
.getChildNodes();
|
||||||
|
for (int taxChildIndex = 0; taxChildIndex < taxChilds
|
||||||
|
.getLength(); taxChildIndex++) {
|
||||||
|
String taxChildName = taxChilds.item(taxChildIndex).getLocalName();
|
||||||
|
if ((taxChildName != null) && (taxChildName.equals("RateApplicablePercent")
|
||||||
|
|| taxChildName.equals("ApplicablePercent"))) {
|
||||||
vatPercent = taxChilds.item(taxChildIndex).getTextContent();
|
vatPercent = taxChilds.item(taxChildIndex).getTextContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tradeSettlementChilds.item(tradeSettlementChildIndex).getLocalName().equals("SpecifiedTradeSettlementLineMonetarySummation")) {
|
if (tradeSettlementName.equals("SpecifiedTradeSettlementLineMonetarySummation")) {
|
||||||
NodeList totalChilds = tradeSettlementChilds.item(tradeSettlementChildIndex).getChildNodes();
|
NodeList totalChilds = tradeSettlementChilds.item(tradeSettlementChildIndex)
|
||||||
for (int totalChildIndex = 0; totalChildIndex < totalChilds.getLength(); totalChildIndex++) {
|
.getChildNodes();
|
||||||
if ((totalChilds.item(totalChildIndex).getLocalName() != null) && (totalChilds.item(totalChildIndex).getLocalName().equals("LineTotalAmount"))) {
|
for (int totalChildIndex = 0; totalChildIndex < totalChilds
|
||||||
|
.getLength(); totalChildIndex++) {
|
||||||
|
if ((totalChilds.item(totalChildIndex).getLocalName() != null) && (totalChilds
|
||||||
|
.item(totalChildIndex).getLocalName().equals("LineTotalAmount"))) {
|
||||||
lineTotal = totalChilds.item(totalChildIndex).getTextContent();
|
lineTotal = totalChilds.item(totalChildIndex).getTextContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +335,8 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
if ((recalcPrice) && (!qty.equals(BigDecimal.ZERO))) {
|
if ((recalcPrice) && (!qty.equals(BigDecimal.ZERO))) {
|
||||||
prc = new BigDecimal(lineTotal.trim()).divide(qty, 4, RoundingMode.HALF_UP);
|
prc = new BigDecimal(lineTotal.trim()).divide(qty, 4, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
Product p = new Product(name, description, unitCode, new BigDecimal(vatPercent.trim()));
|
Product p = new Product(name, description, unitCode,
|
||||||
|
vatPercent == null ? null : new BigDecimal(vatPercent.trim()));
|
||||||
if (gid != null) {
|
if (gid != null) {
|
||||||
p.addGlobalID(gid);
|
p.addGlobalID(gid);
|
||||||
}
|
}
|
||||||
@@ -281,14 +348,13 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
zpp.addItem(it);
|
zpp.addItem(it);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// item level charges+allowances are not yet handled but a lower item price will be read,
|
// item level charges+allowances are not yet handled but a lower item price will
|
||||||
|
// be read,
|
||||||
// so the invoice remains arithmetically correct
|
// so the invoice remains arithmetically correct
|
||||||
// -> parse document level charges+allowances
|
// -> parse document level charges+allowances
|
||||||
xpr = xpath.compile(
|
xpr = xpath.compile("//*[local-name()=\"SpecifiedTradeAllowanceCharge\"]");
|
||||||
"//*[local-name()=\"SpecifiedTradeAllowanceCharge\"]");
|
|
||||||
NodeList chargeNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList chargeNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
for (int i = 0; i < chargeNodes.getLength(); i++) {
|
for (int i = 0; i < chargeNodes.getLength(); i++) {
|
||||||
NodeList chargeNodeChilds = chargeNodes.item(i).getChildNodes();
|
NodeList chargeNodeChilds = chargeNodes.item(i).getChildNodes();
|
||||||
@@ -297,23 +363,30 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
String reason = null;
|
String reason = null;
|
||||||
String taxPercent = null;
|
String taxPercent = null;
|
||||||
for (int chargeChildIndex = 0; chargeChildIndex < chargeNodeChilds.getLength(); chargeChildIndex++) {
|
for (int chargeChildIndex = 0; chargeChildIndex < chargeNodeChilds.getLength(); chargeChildIndex++) {
|
||||||
if (chargeNodeChilds.item(chargeChildIndex).getLocalName() != null) {
|
String chargeChildName = chargeNodeChilds.item(chargeChildIndex).getLocalName();
|
||||||
|
if (chargeChildName != null) {
|
||||||
|
|
||||||
if (chargeNodeChilds.item(chargeChildIndex).getLocalName().equals("ChargeIndicator")) {
|
if (chargeChildName.equals("ChargeIndicator")) {
|
||||||
NodeList indicatorChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
NodeList indicatorChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||||
for (int indicatorChildIndex = 0; indicatorChildIndex < indicatorChilds.getLength(); indicatorChildIndex++) {
|
for (int indicatorChildIndex = 0; indicatorChildIndex < indicatorChilds
|
||||||
if ((indicatorChilds.item(indicatorChildIndex).getLocalName() != null) && (indicatorChilds.item(indicatorChildIndex).getLocalName().equals("Indicator"))) {
|
.getLength(); indicatorChildIndex++) {
|
||||||
isCharge = indicatorChilds.item(indicatorChildIndex).getTextContent().equalsIgnoreCase("true");
|
if ((indicatorChilds.item(indicatorChildIndex).getLocalName() != null)
|
||||||
|
&& (indicatorChilds.item(indicatorChildIndex).getLocalName()
|
||||||
|
.equals("Indicator"))) {
|
||||||
|
isCharge = indicatorChilds.item(indicatorChildIndex).getTextContent()
|
||||||
|
.equalsIgnoreCase("true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (chargeNodeChilds.item(chargeChildIndex).getLocalName().equals("ActualAmount")) {
|
} else if (chargeChildName.equals("ActualAmount")) {
|
||||||
chargeAmount = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
chargeAmount = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
||||||
} else if (chargeNodeChilds.item(chargeChildIndex).getLocalName().equals("Reason")) {
|
} else if (chargeChildName.equals("Reason")) {
|
||||||
reason = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
reason = chargeNodeChilds.item(chargeChildIndex).getTextContent();
|
||||||
} else if (chargeNodeChilds.item(chargeChildIndex).getLocalName().equals("CategoryTradeTax")) {
|
} else if (chargeChildName.equals("CategoryTradeTax")) {
|
||||||
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
||||||
if ((taxChilds.item(taxChildIndex).getLocalName() != null) && (taxChilds.item(taxChildIndex).getLocalName().equals("RateApplicablePercent"))) {
|
String taxItemName = taxChilds.item(taxChildIndex).getLocalName();
|
||||||
|
if ((taxItemName != null) && (taxItemName.equals("RateApplicablePercent")
|
||||||
|
|| taxItemName.equals("ApplicablePercent"))) {
|
||||||
taxPercent = taxChilds.item(taxChildIndex).getTextContent();
|
taxPercent = taxChilds.item(taxChildIndex).getTextContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +394,6 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isCharge) {
|
if (isCharge) {
|
||||||
Charge c = new Charge(new BigDecimal(chargeAmount));
|
Charge c = new Charge(new BigDecimal(chargeAmount));
|
||||||
if (reason != null) {
|
if (reason != null) {
|
||||||
@@ -347,6 +419,9 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
|
|
||||||
TransactionCalculator tc = new TransactionCalculator(zpp);
|
TransactionCalculator tc = new TransactionCalculator(zpp);
|
||||||
String expectedStringTotalGross = tc.getGrandTotal().toPlainString();
|
String expectedStringTotalGross = tc.getGrandTotal().toPlainString();
|
||||||
|
zpp.setGrandTotalAmount(tc.getGrandTotal());
|
||||||
|
zpp.setTotalPrepaidAmount(tc.getTotalPrepaid());
|
||||||
|
zpp.setDuePayableAmount(tc.getGrandTotal().add(tc.getTotalPrepaid().negate()));
|
||||||
EStandard whichType;
|
EStandard whichType;
|
||||||
try {
|
try {
|
||||||
whichType = getStandard();
|
whichType = getStandard();
|
||||||
@@ -355,13 +430,15 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((whichType != EStandard.despatchadvice) && ((!expectedStringTotalGross.equals(XMLTools.nDigitFormat(expectedGrandTotal, 2))) && (!ignoreCalculationErrors))) {
|
if ((whichType != EStandard.despatchadvice)
|
||||||
throw new ParseException("Could not reproduce the invoice, this could mean that it could not be read properly", 0);
|
&& ((!expectedStringTotalGross.equals(XMLTools.nDigitFormat(expectedGrandTotal, 2)))
|
||||||
|
&& (!ignoreCalculationErrors))) {
|
||||||
|
throw new ParseException(
|
||||||
|
"Could not reproduce the invoice, this could mean that it could not be read properly", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return zpp;
|
return zpp;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doRecalculateItemPricesFromLineTotals() {
|
public void doRecalculateItemPricesFromLineTotals() {
|
||||||
|
|||||||
Reference in New Issue
Block a user