move invoice item contact and product out of zugferd namespace

This commit is contained in:
Jochen Stärk
2020-07-26 11:23:51 +02:00
parent 3b706724fb
commit 67bddba154
11 changed files with 121 additions and 127 deletions

View File

@@ -1,4 +1,6 @@
package org.mustangproject.ZUGFeRD; package library.src.main.java.org.mustangproject;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
public class Contact implements IZUGFeRDExportableContact { public class Contact implements IZUGFeRDExportableContact {

View File

@@ -18,13 +18,15 @@
* <p> * <p>
* ********************************************************************** * **********************************************************************
*/ */
package org.mustangproject.ZUGFeRD; package library.src.main.java.org.mustangproject;
import org.mustangproject.ZUGFeRD.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction { public class Invoice implements IZUGFeRDExportableTransaction {
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, buyerOrderReferencedDocumentIssueDateTime = null, ownTaxID = null, ownVATID = null, ownForeignOrganisationID = null, ownOrganisationName = null, ownStreet = null, ownZIP = null, ownLocation = null, ownCountry = 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, buyerOrderReferencedDocumentIssueDateTime = null, ownTaxID = null, ownVATID = null, ownForeignOrganisationID = null, ownOrganisationName = null, ownStreet = null, ownZIP = null, ownLocation = null, ownCountry = null, currency = null, paymentTermDescription = null;
protected Date issueDate = null, dueDate = null, deliveryDate = null; protected Date issueDate = null, dueDate = null, deliveryDate = null;
@@ -37,7 +39,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
protected IZUGFeRDPaymentTerms paymentTerms = null; protected IZUGFeRDPaymentTerms paymentTerms = null;
public ZUGFeRD2PushProvider() { public Invoice() {
ZFItems = new ArrayList<IZUGFeRDExportableItem>(); ZFItems = new ArrayList<IZUGFeRDExportableItem>();
} }
@@ -46,7 +48,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return documentName; return documentName;
} }
public ZUGFeRD2PushProvider setDocumentName(String documentName) { public Invoice setDocumentName(String documentName) {
this.documentName = documentName; this.documentName = documentName;
return this; return this;
} }
@@ -56,7 +58,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return documentCode; return documentCode;
} }
public ZUGFeRD2PushProvider setDocumentCode(String documentCode) { public Invoice setDocumentCode(String documentCode) {
this.documentCode = documentCode; this.documentCode = documentCode;
return this; return this;
} }
@@ -66,7 +68,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return number; return number;
} }
public ZUGFeRD2PushProvider setNumber(String number) { public Invoice setNumber(String number) {
this.number = number; this.number = number;
return this; return this;
} }
@@ -76,7 +78,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownOrganisationFullPlaintextInfo; return ownOrganisationFullPlaintextInfo;
} }
public ZUGFeRD2PushProvider setOwnOrganisationFullPlaintextInfo(String ownOrganisationFullPlaintextInfo) { public Invoice setOwnOrganisationFullPlaintextInfo(String ownOrganisationFullPlaintextInfo) {
this.ownOrganisationFullPlaintextInfo = ownOrganisationFullPlaintextInfo; this.ownOrganisationFullPlaintextInfo = ownOrganisationFullPlaintextInfo;
return this; return this;
} }
@@ -86,7 +88,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return referenceNumber; return referenceNumber;
} }
public ZUGFeRD2PushProvider setReferenceNumber(String referenceNumber) { public Invoice setReferenceNumber(String referenceNumber) {
this.referenceNumber = referenceNumber; this.referenceNumber = referenceNumber;
return this; return this;
} }
@@ -96,7 +98,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return shipToOrganisationID; return shipToOrganisationID;
} }
public ZUGFeRD2PushProvider setShipToOrganisationID(String shipToOrganisationID) { public Invoice setShipToOrganisationID(String shipToOrganisationID) {
this.shipToOrganisationID = shipToOrganisationID; this.shipToOrganisationID = shipToOrganisationID;
return this; return this;
} }
@@ -106,7 +108,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return shipToOrganisationName; return shipToOrganisationName;
} }
public ZUGFeRD2PushProvider setShipToOrganisationName(String shipToOrganisationName) { public Invoice setShipToOrganisationName(String shipToOrganisationName) {
this.shipToOrganisationName = shipToOrganisationName; this.shipToOrganisationName = shipToOrganisationName;
return this; return this;
} }
@@ -116,7 +118,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return shipToStreet; return shipToStreet;
} }
public ZUGFeRD2PushProvider setShipToStreet(String shipToStreet) { public Invoice setShipToStreet(String shipToStreet) {
this.shipToStreet = shipToStreet; this.shipToStreet = shipToStreet;
return this; return this;
} }
@@ -126,7 +128,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return shipToZIP; return shipToZIP;
} }
public ZUGFeRD2PushProvider setShipToZIP(String shipToZIP) { public Invoice setShipToZIP(String shipToZIP) {
this.shipToZIP = shipToZIP; this.shipToZIP = shipToZIP;
return this; return this;
} }
@@ -136,7 +138,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return shipToLocation; return shipToLocation;
} }
public ZUGFeRD2PushProvider setShipToLocation(String shipToLocation) { public Invoice setShipToLocation(String shipToLocation) {
this.shipToLocation = shipToLocation; this.shipToLocation = shipToLocation;
return this; return this;
} }
@@ -146,7 +148,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return shipToCountry; return shipToCountry;
} }
public ZUGFeRD2PushProvider setShipToCountry(String shipToCountry) { public Invoice setShipToCountry(String shipToCountry) {
this.shipToCountry = shipToCountry; this.shipToCountry = shipToCountry;
return this; return this;
} }
@@ -156,7 +158,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return buyerOrderReferencedDocumentID; return buyerOrderReferencedDocumentID;
} }
public ZUGFeRD2PushProvider setBuyerOrderReferencedDocumentID(String buyerOrderReferencedDocumentID) { public Invoice setBuyerOrderReferencedDocumentID(String buyerOrderReferencedDocumentID) {
this.buyerOrderReferencedDocumentID = buyerOrderReferencedDocumentID; this.buyerOrderReferencedDocumentID = buyerOrderReferencedDocumentID;
return this; return this;
} }
@@ -166,7 +168,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return buyerOrderReferencedDocumentIssueDateTime; return buyerOrderReferencedDocumentIssueDateTime;
} }
public ZUGFeRD2PushProvider setBuyerOrderReferencedDocumentIssueDateTime(String buyerOrderReferencedDocumentIssueDateTime) { public Invoice setBuyerOrderReferencedDocumentIssueDateTime(String buyerOrderReferencedDocumentIssueDateTime) {
this.buyerOrderReferencedDocumentIssueDateTime = buyerOrderReferencedDocumentIssueDateTime; this.buyerOrderReferencedDocumentIssueDateTime = buyerOrderReferencedDocumentIssueDateTime;
return this; return this;
} }
@@ -176,7 +178,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownTaxID; return ownTaxID;
} }
public ZUGFeRD2PushProvider setOwnTaxID(String ownTaxID) { public Invoice setOwnTaxID(String ownTaxID) {
this.ownTaxID = ownTaxID; this.ownTaxID = ownTaxID;
return this; return this;
} }
@@ -186,7 +188,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownVATID; return ownVATID;
} }
public ZUGFeRD2PushProvider setOwnVATID(String ownVATID) { public Invoice setOwnVATID(String ownVATID) {
this.ownVATID = ownVATID; this.ownVATID = ownVATID;
return this; return this;
} }
@@ -196,7 +198,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownForeignOrganisationID; return ownForeignOrganisationID;
} }
public ZUGFeRD2PushProvider setOwnForeignOrganisationID(String ownForeignOrganisationID) { public Invoice setOwnForeignOrganisationID(String ownForeignOrganisationID) {
this.ownForeignOrganisationID = ownForeignOrganisationID; this.ownForeignOrganisationID = ownForeignOrganisationID;
return this; return this;
} }
@@ -206,7 +208,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownOrganisationName; return ownOrganisationName;
} }
public ZUGFeRD2PushProvider setOwnOrganisationName(String ownOrganisationName) { public Invoice setOwnOrganisationName(String ownOrganisationName) {
this.ownOrganisationName = ownOrganisationName; this.ownOrganisationName = ownOrganisationName;
return this; return this;
} }
@@ -216,7 +218,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownStreet; return ownStreet;
} }
public ZUGFeRD2PushProvider setOwnStreet(String ownStreet) { public Invoice setOwnStreet(String ownStreet) {
this.ownStreet = ownStreet; this.ownStreet = ownStreet;
return this; return this;
} }
@@ -226,7 +228,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownZIP; return ownZIP;
} }
public ZUGFeRD2PushProvider setOwnZIP(String ownZIP) { public Invoice setOwnZIP(String ownZIP) {
this.ownZIP = ownZIP; this.ownZIP = ownZIP;
return this; return this;
} }
@@ -235,7 +237,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownLocation; return ownLocation;
} }
public ZUGFeRD2PushProvider setOwnLocation(String getOwnLocation) { public Invoice setOwnLocation(String getOwnLocation) {
this.ownLocation = getOwnLocation; this.ownLocation = getOwnLocation;
return this; return this;
} }
@@ -244,7 +246,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownCountry; return ownCountry;
} }
public ZUGFeRD2PushProvider setOwnCountry(String getOwnCountry) { public Invoice setOwnCountry(String getOwnCountry) {
this.ownCountry = getOwnCountry; this.ownCountry = getOwnCountry;
return this; return this;
} }
@@ -254,7 +256,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return currency; return currency;
} }
public ZUGFeRD2PushProvider setCurrency(String currency) { public Invoice setCurrency(String currency) {
this.currency = currency; this.currency = currency;
return this; return this;
} }
@@ -264,7 +266,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return paymentTermDescription; return paymentTermDescription;
} }
public ZUGFeRD2PushProvider setPaymentTermDescription(String paymentTermDescription) { public Invoice setPaymentTermDescription(String paymentTermDescription) {
this.paymentTermDescription = paymentTermDescription; this.paymentTermDescription = paymentTermDescription;
return this; return this;
} }
@@ -274,7 +276,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return issueDate; return issueDate;
} }
public ZUGFeRD2PushProvider setIssueDate(Date issueDate) { public Invoice setIssueDate(Date issueDate) {
this.issueDate = issueDate; this.issueDate = issueDate;
return this; return this;
} }
@@ -284,7 +286,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return dueDate; return dueDate;
} }
public ZUGFeRD2PushProvider setDueDate(Date dueDate) { public Invoice setDueDate(Date dueDate) {
this.dueDate = dueDate; this.dueDate = dueDate;
return this; return this;
} }
@@ -294,7 +296,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return deliveryDate; return deliveryDate;
} }
public ZUGFeRD2PushProvider setDeliveryDate(Date deliveryDate) { public Invoice setDeliveryDate(Date deliveryDate) {
this.deliveryDate = deliveryDate; this.deliveryDate = deliveryDate;
return this; return this;
} }
@@ -304,7 +306,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return totalPrepaidAmount; return totalPrepaidAmount;
} }
public ZUGFeRD2PushProvider setTotalPrepaidAmount(BigDecimal totalPrepaidAmount) { public Invoice setTotalPrepaidAmount(BigDecimal totalPrepaidAmount) {
this.totalPrepaidAmount = totalPrepaidAmount; this.totalPrepaidAmount = totalPrepaidAmount;
return this; return this;
} }
@@ -314,7 +316,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ownContact; return ownContact;
} }
public ZUGFeRD2PushProvider setOwnContact(IZUGFeRDExportableContact ownContact) { public Invoice setOwnContact(IZUGFeRDExportableContact ownContact) {
this.ownContact = ownContact; this.ownContact = ownContact;
return this; return this;
} }
@@ -324,7 +326,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return recipient; return recipient;
} }
public ZUGFeRD2PushProvider setRecipient(IZUGFeRDExportableContact recipient) { public Invoice setRecipient(IZUGFeRDExportableContact recipient) {
this.recipient = recipient; this.recipient = recipient;
return this; return this;
} }
@@ -334,7 +336,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ZFAllowances; return ZFAllowances;
} }
public ZUGFeRD2PushProvider setZFAllowances(IZUGFeRDAllowanceCharge[] ZFAllowances) { public Invoice setZFAllowances(IZUGFeRDAllowanceCharge[] ZFAllowances) {
this.ZFAllowances = ZFAllowances; this.ZFAllowances = ZFAllowances;
return this; return this;
} }
@@ -344,7 +346,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ZFCharges; return ZFCharges;
} }
public ZUGFeRD2PushProvider setZFCharges(IZUGFeRDAllowanceCharge[] ZFCharges) { public Invoice setZFCharges(IZUGFeRDAllowanceCharge[] ZFCharges) {
this.ZFCharges = ZFCharges; this.ZFCharges = ZFCharges;
return this; return this;
} }
@@ -354,7 +356,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ZFLogisticsServiceCharges; return ZFLogisticsServiceCharges;
} }
public ZUGFeRD2PushProvider setZFLogisticsServiceCharges(IZUGFeRDAllowanceCharge[] ZFLogisticsServiceCharges) { public Invoice setZFLogisticsServiceCharges(IZUGFeRDAllowanceCharge[] ZFLogisticsServiceCharges) {
this.ZFLogisticsServiceCharges = ZFLogisticsServiceCharges; this.ZFLogisticsServiceCharges = ZFLogisticsServiceCharges;
return this; return this;
} }
@@ -363,7 +365,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return getTradeSettlement; return getTradeSettlement;
} }
public ZUGFeRD2PushProvider setGetTradeSettlement(IZUGFeRDTradeSettlement[] getTradeSettlement) { public Invoice setGetTradeSettlement(IZUGFeRDTradeSettlement[] getTradeSettlement) {
this.getTradeSettlement = getTradeSettlement; this.getTradeSettlement = getTradeSettlement;
return this; return this;
} }
@@ -373,7 +375,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return paymentTerms; return paymentTerms;
} }
public ZUGFeRD2PushProvider setPaymentTerms(IZUGFeRDPaymentTerms paymentTerms) { public Invoice setPaymentTerms(IZUGFeRDPaymentTerms paymentTerms) {
this.paymentTerms = paymentTerms; this.paymentTerms = paymentTerms;
return this; return this;
} }
@@ -383,7 +385,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return deliveryAddress; return deliveryAddress;
} }
public ZUGFeRD2PushProvider setDeliveryAddress(IZUGFeRDExportableContact deliveryAddress) { public Invoice setDeliveryAddress(IZUGFeRDExportableContact deliveryAddress) {
this.deliveryAddress = deliveryAddress; this.deliveryAddress = deliveryAddress;
return this; return this;
} }
@@ -393,7 +395,7 @@ public class ZUGFeRD2PushProvider implements IZUGFeRDExportableTransaction {
return ZFItems.toArray(new IZUGFeRDExportableItem[0]); return ZFItems.toArray(new IZUGFeRDExportableItem[0]);
} }
public ZUGFeRD2PushProvider addItem(IZUGFeRDExportableItem item) { public Invoice addItem(IZUGFeRDExportableItem item) {
ZFItems.add(item); ZFItems.add(item);
return this; return this;
} }

View File

@@ -1,8 +1,7 @@
package org.mustangproject.ZUGFeRD; package library.src.main.java.org.mustangproject;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge; import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@@ -1,4 +1,4 @@
package org.mustangproject.ZUGFeRD; package library.src.main.java.org.mustangproject;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;

View File

@@ -30,6 +30,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.*; import javax.xml.xpath.*;
import library.src.main.java.org.mustangproject.Item;
import library.src.main.java.org.mustangproject.Product;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary; import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode; import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
@@ -809,13 +811,13 @@ public class ZUGFeRDImporter {
* returns a list of LineItems * returns a list of LineItems
* @return a List of LineItem instances * @return a List of LineItem instances
*/ */
public List<Item> getLineItemList() { public List<library.src.main.java.org.mustangproject.Item> getLineItemList() {
List<Node> nodeList = getLineItemNodes(); List<Node> nodeList = getLineItemNodes();
List<Item> lineItemList = new ArrayList<>(); List<library.src.main.java.org.mustangproject.Item> lineItemList = new ArrayList<>();
for (Node n: nodeList for (Node n: nodeList
) { ) {
Item lineItem = new Item(null, null, null); library.src.main.java.org.mustangproject.Item lineItem = new Item(null, null, null);
lineItem.setProduct(new Product(null,null,null,null)); lineItem.setProduct(new Product(null,null,null,null));
NodeList nl = n.getChildNodes(); NodeList nl = n.getChildNodes();
@@ -848,16 +850,16 @@ public class ZUGFeRDImporter {
case "ram:SpecifiedTradeProduct": case "ram:SpecifiedTradeProduct":
node = getNodeByName(nn.getChildNodes(), "ram:SellerAssignedID"); node = getNodeByName(nn.getChildNodes(), "ram:SellerAssignedID");
lineItem.product.setSellerAssignedID(getNodeValue(node)); lineItem.getProduct().setSellerAssignedID(getNodeValue(node));
node = getNodeByName(nn.getChildNodes(), "ram:BuyerAssignedID"); node = getNodeByName(nn.getChildNodes(), "ram:BuyerAssignedID");
lineItem.product.setBuyerAssignedID(getNodeValue(node)); lineItem.getProduct().setBuyerAssignedID(getNodeValue(node));
node = getNodeByName(nn.getChildNodes(), "ram:Name"); node = getNodeByName(nn.getChildNodes(), "ram:Name");
lineItem.product.setName(getNodeValue(node)); lineItem.getProduct().setName(getNodeValue(node));
node = getNodeByName(nn.getChildNodes(), "ram:Description"); node = getNodeByName(nn.getChildNodes(), "ram:Description");
lineItem.product.setDescription(getNodeValue(node)); lineItem.getProduct().setDescription(getNodeValue(node));
break; break;
case "ram:SpecifiedLineTradeDelivery": case "ram:SpecifiedLineTradeDelivery":
@@ -871,7 +873,7 @@ public class ZUGFeRDImporter {
node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax"); node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax");
if (node != null) { if (node != null) {
node = getNodeByName(node.getChildNodes(), "ram:RateApplicablePercent"); node = getNodeByName(node.getChildNodes(), "ram:RateApplicablePercent");
lineItem.product.setVATPercent(tryBigDecimal(getNodeValue(node))); lineItem.getProduct().setVATPercent(tryBigDecimal(getNodeValue(node)));
} }
node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax"); node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax");
@@ -892,7 +894,7 @@ public class ZUGFeRDImporter {
node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax"); node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax");
if (node != null) { if (node != null) {
node = getNodeByName(node.getChildNodes(), "ram:ApplicablePercent"); node = getNodeByName(node.getChildNodes(), "ram:ApplicablePercent");
lineItem.product.setVATPercent(tryBigDecimal(getNodeValue(node))); lineItem.getProduct().setVATPercent(tryBigDecimal(getNodeValue(node)));
} }
node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax"); node = getNodeByName(nn.getChildNodes(), "ram:ApplicableTradeTax");

View File

@@ -1,23 +1,24 @@
package org.mustangproject.ZUGFeRD; package org.mustangproject.ZUGFeRD;
import org.w3c.dom.Document; import library.src.main.java.org.mustangproject.Contact;
import library.src.main.java.org.mustangproject.Invoice;
import library.src.main.java.org.mustangproject.Item;
import library.src.main.java.org.mustangproject.Product;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.xml.xpath.*; import javax.xml.xpath.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter { public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
public ZUGFeRDInvoiceImporter(String filename) { public ZUGFeRDInvoiceImporter(String filename) {
super(filename); super(filename);
} }
public ZUGFeRD2PushProvider extractInvoice() { public Invoice extractInvoice() {
String number="AB123"; String number="AB123";
ZUGFeRD2PushProvider zpp=new ZUGFeRD2PushProvider().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number); Invoice zpp=new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number);
//.addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0))) //.addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0)))
zpp.setOwnOrganisationName(extractString("//SellerTradeParty/Name")); zpp.setOwnOrganisationName(extractString("//SellerTradeParty/Name"));

View File

@@ -1,83 +1,80 @@
/** ********************************************************************** /**
* * *********************************************************************
* <p>
* Copyright 2019 Jochen Staerk * Copyright 2019 Jochen Staerk
* * <p>
* Use is subject to license terms. * Use is subject to license terms.
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy * use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0. * of the License at http://www.apache.org/licenses/LICENSE-2.0.
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * <p>
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* * <p>
*********************************************************************** */ * **********************************************************************
package org.mustangproject.ZUGFeRD; */
package library.src.test.java.org.mustangproject.ZUGFeRD;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Date;
import junit.framework.TestCase;
import library.src.main.java.org.mustangproject.Contact; import library.src.main.java.org.mustangproject.Contact;
import library.src.main.java.org.mustangproject.Invoice; import library.src.main.java.org.mustangproject.Invoice;
import library.src.main.java.org.mustangproject.Item; import library.src.main.java.org.mustangproject.Item;
import library.src.main.java.org.mustangproject.Product; import library.src.main.java.org.mustangproject.Product;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.mustangproject.ZUGFeRD.ZUGFeRD2PullProvider;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA3Factory;
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.xmlunit.builder.Input;
import org.xmlunit.xpath.JAXPXPathEngine;
import org.xmlunit.xpath.XPathEngine;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Date;
import static org.xmlunit.assertj.XmlAssert.assertThat;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ZF2PushTest extends TestCase { public class XRTest extends TestCase {
final String TARGET_PDF = "./target/testout-ZF2Push.pdf";
public void testPushExport() { public void testPushExport() {
// the writing part // the writing part
String orgname="Test company"; String orgname = "Test company";
String number="123"; String number = "123";
String amountStr="1.00"; String amountStr = "1.00";
BigDecimal amount=new BigDecimal(amountStr); BigDecimal amount = new BigDecimal(amountStr);
try (InputStream SOURCE_PDF = this.getClass()
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory().setProducer("My Application") Invoice i = new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(0)), amount, new BigDecimal(1.0)));
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
.load(SOURCE_PDF)) {
ze.PDFattachZugferdFile(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0)))); ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider();
String theXML = new String(ze.getProvider().getXML()); zf2p.generateXML(i);
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice")); String theXML = new String(zf2p.getXML());
ze.export(TARGET_PDF); assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
} catch (IOException e) { assertThat(theXML).valueByXPath("count(//*[local-name()='IncludedSupplyChainTradeLineItem'])")
fail("IOException should not be raised in testEdgeExport"); .asInt()
} .isEqualTo(1); //2 errors are OK because there is a known bug
// now check the contents (like MustangReaderTest)
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
assertFalse(zi.getUTF8().contains("EUR")); assertThat(theXML).valueByXPath("//*[local-name()='DuePayableAmount']")
.asDouble()
.isEqualTo(1);
// Reading ZUGFeRD
assertEquals(amountStr, zi.getAmount());
assertEquals(zi.getHolder(), orgname);
assertEquals(zi.getForeignReference(), number);
try {
assertEquals(zi.getVersion(), 2);
} catch (Exception e) {
e.printStackTrace();
}
} }

View File

@@ -19,15 +19,15 @@
*********************************************************************** */ *********************************************************************** */
package org.mustangproject.ZUGFeRD; package org.mustangproject.ZUGFeRD;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar;
import library.src.main.java.org.mustangproject.Contact;
import library.src.main.java.org.mustangproject.Invoice;
import library.src.main.java.org.mustangproject.Item;
import library.src.main.java.org.mustangproject.Product;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
@@ -56,7 +56,7 @@ public class ZF2PushTest extends TestCase {
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors() .setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
.load(SOURCE_PDF)) { .load(SOURCE_PDF)) {
ze.PDFattachZugferdFile(new ZUGFeRD2PushProvider().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0)))); ze.PDFattachZugferdFile(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setOwnOrganisationName(orgname).setOwnStreet("teststr").setOwnZIP("55232").setOwnLocation("teststadt").setOwnCountry("DE").setOwnTaxID("4711").setOwnVATID("0815").setRecipient(new Contact("Franz Müller", "0177123456", "fmueller@test.com", "teststr.12", "55232", "Entenhausen", "DE")).setNumber(number).addItem(new Item(new Product("Testprodukt","","C62",new BigDecimal(0)),amount,new BigDecimal(1.0))));
String theXML = new String(ze.getProvider().getXML()); String theXML = new String(ze.getProvider().getXML());
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice")); assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
ze.export(TARGET_PDF); ze.export(TARGET_PDF);

View File

@@ -24,7 +24,6 @@ import junit.framework.TestSuite;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -248,16 +247,16 @@ public class ZF2Test extends MustangReaderTestCase {
assertEquals(zi.getSellerTradePartyAddress().getCountryID(), "DE"); assertEquals(zi.getSellerTradePartyAddress().getCountryID(), "DE");
assertEquals(zi.getSellerTradePartyAddress().getCityName(), "Stadthausen"); assertEquals(zi.getSellerTradePartyAddress().getCityName(), "Stadthausen");
List<org.mustangproject.ZUGFeRD.Item> li = zi.getLineItemList(); List<library.src.main.java.org.mustangproject.Item> li = zi.getLineItemList();
assertEquals(zi.getLineItemList().get(0).getId().toString(), "1"); assertEquals(zi.getLineItemList().get(0).getId().toString(), "1");
assertEquals(zi.getLineItemList().get(0).product.getBuyerAssignedID(), ""); assertEquals(zi.getLineItemList().get(0).getProduct().getBuyerAssignedID(), "");
assertEquals(zi.getLineItemList().get(0).product.getSellerAssignedID(), ""); assertEquals(zi.getLineItemList().get(0).getProduct().getSellerAssignedID(), "");
assertEquals(zi.getLineItemList().get(0).getLineTotalAmount().toString(), "160.00"); assertEquals(zi.getLineItemList().get(0).getLineTotalAmount().toString(), "160.00");
assertEquals(zi.getLineItemList().get(0).getQuantity().toString(), "1.0000"); assertEquals(zi.getLineItemList().get(0).getQuantity().toString(), "1.0000");
assertEquals(zi.getLineItemList().get(0).getGrossPrice().toString(), "160.0000"); assertEquals(zi.getLineItemList().get(0).getGrossPrice().toString(), "160.0000");
assertEquals(zi.getLineItemList().get(0).product.getVATPercent().toString(), "7.00"); assertEquals(zi.getLineItemList().get(0).getProduct().getVATPercent().toString(), "7.00");
assertEquals(zi.getLineItemList().get(0).product.getName(), "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung"); assertEquals(zi.getLineItemList().get(0).getProduct().getName(), "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung");
assertEquals(zi.getLineItemList().get(0).product.getDescription(), ""); assertEquals(zi.getLineItemList().get(0).getProduct().getDescription(), "");
try { try {
assertEquals(zi.getVersion(), 2); assertEquals(zi.getVersion(), 2);

View File

@@ -19,15 +19,7 @@
*********************************************************************** */ *********************************************************************** */
package org.mustangproject.ZUGFeRD; package org.mustangproject.ZUGFeRD;
import java.io.ByteArrayOutputStream; import library.src.main.java.org.mustangproject.Invoice;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
@@ -47,7 +39,7 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter(TARGET_PDF); ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter(TARGET_PDF);
ZUGFeRD2PushProvider invoice=zii.extractInvoice(); Invoice invoice=zii.extractInvoice();
// Reading ZUGFeRD // Reading ZUGFeRD
assertEquals("Bei Spiel GmbH", invoice.getOwnOrganisationName()); assertEquals("Bei Spiel GmbH", invoice.getOwnOrganisationName());
assertEquals(3, invoice.getZFItems().length); assertEquals(3, invoice.getZFItems().length);

View File

@@ -285,7 +285,7 @@ public class XMLValidator extends Validator {
context.addCustomXML("<info><version>" + ((context.getVersion() != null) ? context.getVersion() : "invalid") context.addCustomXML("<info><version>" + ((context.getVersion() != null) ? context.getVersion() : "invalid")
+ "</version><profile>" + ((context.getProfile() != null) ? context.getProfile() : "invalid") + + "</version><profile>" + ((context.getProfile() != null) ? context.getProfile() : "invalid") +
"</profile><validator version=\"" + Main.class.getPackage().getImplementationVersion() + "\"></validator><rules><fired>" + firedRules + "</fired><failed>" + failedRules + "</failed></rules>" + "<duration unit='ms'>" + (endTime - startXMLTime) + "</duration></info>"); "</profile><validator version=\"" + XMLValidator.class.getPackage().getImplementationVersion() + "\"></validator><rules><fired>" + firedRules + "</fired><failed>" + failedRules + "</failed></rules>" + "<duration unit='ms'>" + (endTime - startXMLTime) + "</duration></info>");
} }