use .editorconfig for java
This commit is contained in:
23
.editorconfig
Normal file
23
.editorconfig
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# EditorConfig is awesome: https://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Unix-style newlines with a newline ending every file
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
# Tab indentation (no size specified)
|
||||||
|
[*.java]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
# 2 space indentation
|
||||||
|
[*.xsd,*.xsl,*.xml]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# all x** Files
|
||||||
|
[{package.json,.travis.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
@@ -19,5 +19,5 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
public final class Version {
|
public final class Version {
|
||||||
public static final String VERSION = "${project.version}";
|
public static final String VERSION = "${project.version}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ public class CustomXMLProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setXML(byte[] newData) {
|
public void setXML(byte[] newData) {
|
||||||
String zf=new String(newData);
|
String zf = new String(newData);
|
||||||
if (!zf.contains("<rsm:CrossIndustry")) {
|
if (!zf.contains("<rsm:CrossIndustry")) {
|
||||||
throw new RuntimeException("ZUGFeRD XML does not contain <rsm:CrossIndustry and can thus not be valid");
|
throw new RuntimeException("ZUGFeRD XML does not contain <rsm:CrossIndustry and can thus not be valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
zugferdData=newData;
|
zugferdData = newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,29 +23,34 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
public interface IExporterFactory {
|
public interface IExporterFactory {
|
||||||
public ZUGFeRDExporter load(String pdfFilename) throws IOException;
|
public ZUGFeRDExporter load(String pdfFilename) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||||
*
|
*
|
||||||
* @param pdfBinary
|
* @param pdfBinary binary of a PDF/A1 compliant document
|
||||||
* binary of a PDF/A1 compliant document
|
|
||||||
*/
|
*/
|
||||||
public ZUGFeRDExporter load(byte[] pdfBinary) throws IOException;
|
public ZUGFeRDExporter load(byte[] pdfBinary) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||||
*
|
*
|
||||||
* @param pdfSource
|
* @param pdfSource source to read a PDF/A1 compliant document from
|
||||||
* source to read a PDF/A1 compliant document from
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public ZUGFeRDExporter load(InputStream pdfSource) throws IOException;
|
public ZUGFeRDExporter load(InputStream pdfSource) throws IOException;
|
||||||
|
|
||||||
public IExporterFactory setCreator(String creator);
|
public IExporterFactory setCreator(String creator);
|
||||||
|
|
||||||
public IExporterFactory setConformanceLevel(PDFAConformanceLevel newLevel);
|
public IExporterFactory setConformanceLevel(PDFAConformanceLevel newLevel);
|
||||||
public IExporterFactory setProducer(String producer) ;
|
|
||||||
|
public IExporterFactory setProducer(String producer);
|
||||||
|
|
||||||
public IExporterFactory setZUGFeRDVersion(int version);
|
public IExporterFactory setZUGFeRDVersion(int version);
|
||||||
|
|
||||||
public IExporterFactory ignorePDFAErrors();
|
public IExporterFactory ignorePDFAErrors();
|
||||||
|
|
||||||
public IExporterFactory setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel zugferdConformanceLevel);
|
public IExporterFactory setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel zugferdConformanceLevel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
public interface IXMLProvider {
|
public interface IXMLProvider {
|
||||||
|
|
||||||
public byte[] getXML();
|
public byte[] getXML();
|
||||||
|
|
||||||
public void setTest();
|
public void setTest();
|
||||||
|
|
||||||
public void generateXML(IZUGFeRDExportableTransaction trans);
|
public void generateXML(IZUGFeRDExportableTransaction trans);
|
||||||
|
|||||||
@@ -18,14 +18,13 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author AlexanderSchmidt
|
* @author AlexanderSchmidt
|
||||||
*/
|
*/
|
||||||
public interface IZUGFeRDAllowanceCharge {
|
public interface IZUGFeRDAllowanceCharge {
|
||||||
BigDecimal getTotalAmount();
|
BigDecimal getTotalAmount();
|
||||||
|
|
||||||
String getReason();
|
String getReason();
|
||||||
|
|
||||||
BigDecimal getTaxPercent();
|
BigDecimal getTaxPercent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,50 +17,58 @@
|
|||||||
*
|
*
|
||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
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
|
||||||
* Licensed under the APLv2
|
* Licensed under the APLv2
|
||||||
* @date 2014-05-10
|
*
|
||||||
* @version 1.2.0
|
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* @version 1.2.0
|
||||||
|
* @date 2014-05-10
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
public interface IZUGFeRDExportableContact {
|
public interface IZUGFeRDExportableContact {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First and last name of the recipient
|
* First and last name of the recipient
|
||||||
|
*
|
||||||
* @return First and last name of the recipient
|
* @return First and last name of the recipient
|
||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postal code of the recipient
|
* Postal code of the recipient
|
||||||
|
*
|
||||||
* @return Postal code of the recipient
|
* @return Postal code of the recipient
|
||||||
*/
|
*/
|
||||||
String getZIP();
|
String getZIP();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
* VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
||||||
|
*
|
||||||
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact
|
||||||
*/
|
*/
|
||||||
String getVATID();
|
String getVATID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* two-letter country code of the contact
|
* two-letter country code of the contact
|
||||||
|
*
|
||||||
* @return two-letter iso country code of the contact
|
* @return two-letter iso country code of the contact
|
||||||
*/
|
*/
|
||||||
String getCountry();
|
String getCountry();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* Returns the city of the contact
|
* Returns the city of the contact
|
||||||
|
*
|
||||||
* @return Returns the city of the recipient
|
* @return Returns the city of the recipient
|
||||||
*/
|
*/
|
||||||
String getLocation();
|
String getLocation();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* Returns the street address (street+number) of the contact
|
* Returns the street address (street+number) of the contact
|
||||||
|
*
|
||||||
* @return street address (street+number) of the contact
|
* @return street address (street+number) of the contact
|
||||||
*/
|
*/
|
||||||
String getStreet();
|
String getStreet();
|
||||||
|
|||||||
@@ -31,22 +31,25 @@ import java.math.BigDecimal;
|
|||||||
public interface IZUGFeRDExportableItem {
|
public interface IZUGFeRDExportableItem {
|
||||||
|
|
||||||
IZUGFeRDExportableProduct getProduct();
|
IZUGFeRDExportableProduct getProduct();
|
||||||
IZUGFeRDAllowanceCharge[] getItemAllowances();
|
|
||||||
IZUGFeRDAllowanceCharge[] getItemCharges();
|
IZUGFeRDAllowanceCharge[] getItemAllowances();
|
||||||
|
|
||||||
|
IZUGFeRDAllowanceCharge[] getItemCharges();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The price of one item excl. taxes
|
* The price of one item excl. taxes
|
||||||
|
*
|
||||||
* @return The price of one item excl. taxes
|
* @return The price of one item excl. taxes
|
||||||
*/
|
*/
|
||||||
BigDecimal getPrice();
|
BigDecimal getPrice();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* how many
|
* how many
|
||||||
|
*
|
||||||
* @return the quantity of the item
|
* @return the quantity of the item
|
||||||
*/
|
*/
|
||||||
BigDecimal getQuantity();
|
BigDecimal getQuantity();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,61 +17,67 @@
|
|||||||
*
|
*
|
||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustangproject's ZUGFeRD implementation
|
* Mustangproject's ZUGFeRD implementation
|
||||||
* Necessary interface for ZUGFeRD exporter
|
* Necessary interface for ZUGFeRD exporter
|
||||||
* Licensed under the APLv2
|
* Licensed under the APLv2
|
||||||
* @date 2014-05-10
|
*
|
||||||
* @version 1.2.0
|
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* @version 1.2.0
|
||||||
|
* @date 2014-05-10
|
||||||
|
*/
|
||||||
|
|
||||||
public interface IZUGFeRDExportableProduct {
|
public interface IZUGFeRDExportableProduct {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit code of the product
|
* Unit code of the product
|
||||||
* Most common ones are
|
* Most common ones are
|
||||||
C62 one (piece)
|
* C62 one (piece)
|
||||||
DAY day
|
* DAY day
|
||||||
HAR hectare
|
* HAR hectare
|
||||||
HUR hour
|
* HUR hour
|
||||||
KGM kilogram
|
* KGM kilogram
|
||||||
KTM kilometre
|
* KTM kilometre
|
||||||
KWH kilowatt hour
|
* KWH kilowatt hour
|
||||||
LS lump sum
|
* LS lump sum
|
||||||
LTR litre
|
* LTR litre
|
||||||
MIN minute
|
* MIN minute
|
||||||
MMK square millimetre
|
* MMK square millimetre
|
||||||
MMT millimetre
|
* MMT millimetre
|
||||||
MTK square metre
|
* MTK square metre
|
||||||
MTQ cubic metre
|
* MTQ cubic metre
|
||||||
MTR metre
|
* MTR metre
|
||||||
NAR number of articles
|
* NAR number of articles
|
||||||
NPR number of pairs
|
* NPR number of pairs
|
||||||
P1 percent
|
* P1 percent
|
||||||
SET set
|
* SET set
|
||||||
TNE tonne (metric ton)
|
* TNE tonne (metric ton)
|
||||||
WEE week
|
* WEE week
|
||||||
|
*
|
||||||
* @return a UN/ECE rec 20 unit code see https://www.unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex2e.pdf
|
* @return a UN/ECE rec 20 unit code see https://www.unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex2e.pdf
|
||||||
*/
|
*/
|
||||||
String getUnit();
|
String getUnit();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short name of the product
|
* Short name of the product
|
||||||
|
*
|
||||||
* @return Short name of the product
|
* @return Short name of the product
|
||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* long description of the product
|
* long description of the product
|
||||||
|
*
|
||||||
* @return long description of the product
|
* @return long description of the product
|
||||||
*/
|
*/
|
||||||
String getDescription();
|
String getDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VAT percent of the product (e.g. 19, or 5.1 if you like)
|
* VAT percent of the product (e.g. 19, or 5.1 if you like)
|
||||||
|
*
|
||||||
* @return VAT percent of the product
|
* @return VAT percent of the product
|
||||||
*/
|
*/
|
||||||
BigDecimal getVATPercent();
|
BigDecimal getVATPercent();
|
||||||
|
|||||||
@@ -27,19 +27,20 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public interface IZUGFeRDExportableTransaction {
|
public interface IZUGFeRDExportableTransaction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number, typically invoice number of the invoice
|
* Number, typically invoice number of the invoice
|
||||||
|
*
|
||||||
* @return invoice number
|
* @return invoice number
|
||||||
*/
|
*/
|
||||||
String getNumber();
|
String getNumber();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the date when the invoice was created
|
* the date when the invoice was created
|
||||||
|
*
|
||||||
* @return when the invoice was created
|
* @return when the invoice was created
|
||||||
*/
|
*/
|
||||||
Date getIssueDate();
|
Date getIssueDate();
|
||||||
@@ -48,138 +49,160 @@ public interface IZUGFeRDExportableTransaction {
|
|||||||
* this should be the full sender institution name, details, manager and tax registration.
|
* this should be the full sender institution name, details, manager and tax registration.
|
||||||
* It is one of the few functions which may return null.
|
* It is one of the few functions which may return null.
|
||||||
* e.g.
|
* e.g.
|
||||||
|
* <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
|
||||||
*/
|
*/
|
||||||
String getOwnOrganisationFullPlaintextInfo();
|
String getOwnOrganisationFullPlaintextInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* when the invoice is to be paid
|
* when the invoice is to be paid
|
||||||
|
*
|
||||||
* @return when the invoice is to be paid
|
* @return when the invoice is to be paid
|
||||||
*/
|
*/
|
||||||
Date getDueDate();
|
Date getDueDate();
|
||||||
|
|
||||||
IZUGFeRDAllowanceCharge[] getZFAllowances();
|
IZUGFeRDAllowanceCharge[] getZFAllowances();
|
||||||
IZUGFeRDAllowanceCharge[] getZFCharges();
|
|
||||||
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
|
IZUGFeRDAllowanceCharge[] getZFCharges();
|
||||||
|
|
||||||
|
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
|
||||||
|
|
||||||
IZUGFeRDExportableItem[] getZFItems();
|
IZUGFeRDExportableItem[] getZFItems();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* the recipient
|
* the recipient
|
||||||
|
*
|
||||||
* @return the recipient of the invoice
|
* @return the recipient of the invoice
|
||||||
*/
|
*/
|
||||||
IZUGFeRDExportableContact getRecipient();
|
IZUGFeRDExportableContact getRecipient();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* BIC of the sender
|
* BIC of the sender
|
||||||
|
*
|
||||||
* @return the BIC code of the recipient sender's bank
|
* @return the BIC code of the recipient sender's bank
|
||||||
*/
|
*/
|
||||||
String getOwnBIC();
|
String getOwnBIC();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* BLZ of the sender
|
* BLZ of the sender
|
||||||
* @return the BLZ code of the recipient sender's bank
|
*
|
||||||
*/
|
* @return the BLZ code of the recipient sender's bank
|
||||||
String getOwnBLZ();
|
*/
|
||||||
|
String getOwnBLZ();
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* Bank name of the sender
|
* Bank name of the sender
|
||||||
|
*
|
||||||
* @return the name of the sender's bank
|
* @return the name of the sender's bank
|
||||||
*/
|
*/
|
||||||
String getOwnBankName();
|
String getOwnBankName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IBAN of the sender
|
* IBAN of the sender
|
||||||
* @return the IBAN of the invoice sender's bank account
|
*
|
||||||
|
* @return the IBAN of the invoice sender's bank account
|
||||||
*/
|
*/
|
||||||
String getOwnIBAN();
|
String getOwnIBAN();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IBAN of the sender
|
* IBAN of the sender
|
||||||
* @return the Account Number of the invoice sender's bank account
|
*
|
||||||
*/
|
* @return the Account Number of the invoice sender's bank account
|
||||||
String getOwnKto();
|
*/
|
||||||
|
String getOwnKto();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tax ID (not VAT ID) of the sender
|
* Tax ID (not VAT ID) of the sender
|
||||||
* @return Tax ID (not VAT ID) of the sender
|
*
|
||||||
|
* @return Tax ID (not VAT ID) of the sender
|
||||||
*/
|
*/
|
||||||
String getOwnTaxID();
|
String getOwnTaxID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
* VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
||||||
|
*
|
||||||
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
|
||||||
*/
|
*/
|
||||||
String getOwnVATID();
|
String getOwnVATID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own name
|
* own name
|
||||||
|
*
|
||||||
* @return the sender's organisation name
|
* @return the sender's organisation name
|
||||||
*/
|
*/
|
||||||
String getOwnOrganisationName();
|
String getOwnOrganisationName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own street address
|
* own street address
|
||||||
|
*
|
||||||
* @return sender street address
|
* @return sender street address
|
||||||
*/
|
*/
|
||||||
String getOwnStreet();
|
String getOwnStreet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own street postal code
|
* own street postal code
|
||||||
|
*
|
||||||
* @return sender postal code
|
* @return sender postal code
|
||||||
*/
|
*/
|
||||||
String getOwnZIP();
|
String getOwnZIP();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own city
|
* own city
|
||||||
|
*
|
||||||
* @return the invoice sender's city
|
* @return the invoice sender's city
|
||||||
*/
|
*/
|
||||||
String getOwnLocation();
|
String getOwnLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* own two digit country code
|
* own two digit country code
|
||||||
|
*
|
||||||
* @return the invoice senders two character country iso code
|
* @return the invoice senders two character country iso code
|
||||||
*/
|
*/
|
||||||
String getOwnCountry();
|
String getOwnCountry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get delivery date
|
* get delivery date
|
||||||
|
*
|
||||||
* @return the day the goods have been delivered
|
* @return the day the goods have been delivered
|
||||||
*/
|
*/
|
||||||
Date getDeliveryDate();
|
Date getDeliveryDate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get main invoice currency used on the invoice
|
* get main invoice currency used on the invoice
|
||||||
|
*
|
||||||
* @return three character currency of this invoice
|
* @return three character currency of this invoice
|
||||||
*/
|
*/
|
||||||
String getCurrency();
|
String getCurrency();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get payment information text. e.g. Bank transfer
|
* get payment information text. e.g. Bank transfer
|
||||||
|
*
|
||||||
* @return payment information text
|
* @return payment information text
|
||||||
*/
|
*/
|
||||||
String getOwnPaymentInfoText();
|
String getOwnPaymentInfoText();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get payment term descriptional text
|
* get payment term descriptional text
|
||||||
* e.g. Bis zum 22.10.2015 ohne Abzug
|
* e.g. Bis zum 22.10.2015 ohne Abzug
|
||||||
|
*
|
||||||
* @return get payment terms
|
* @return get payment terms
|
||||||
*/
|
*/
|
||||||
String getPaymentTermDescription();
|
String getPaymentTermDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get reference document number
|
* get reference document number
|
||||||
* typically used for Invoice Corrections
|
* typically used for Invoice Corrections
|
||||||
* Will be added as IncludedNote in comfort profile
|
* Will be added as IncludedNote in comfort profile
|
||||||
* @return the ID of the document this document refers to
|
*
|
||||||
*/
|
* @return the ID of the document this document refers to
|
||||||
String getReferenceNumber();
|
*/
|
||||||
|
String getReferenceNumber();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,24 +19,24 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
public enum PDFAConformanceLevel {
|
public enum PDFAConformanceLevel {
|
||||||
ACCESSIBLE("A"), BASIC("B"), UNICODE("U");
|
ACCESSIBLE("A"), BASIC("B"), UNICODE("U");
|
||||||
|
|
||||||
private final String letter;
|
private final String letter;
|
||||||
|
|
||||||
PDFAConformanceLevel(String letter) {
|
PDFAConformanceLevel(String letter) {
|
||||||
this.letter = letter;
|
this.letter = letter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLetter() {
|
public String getLetter() {
|
||||||
return letter;
|
return letter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PDFAConformanceLevel findByLetter(String letter) {
|
public static PDFAConformanceLevel findByLetter(String letter) {
|
||||||
for (PDFAConformanceLevel candidate : values()) {
|
for (PDFAConformanceLevel candidate : values()) {
|
||||||
if (candidate.letter.equals(letter)) {
|
if (candidate.letter.equals(letter)) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("PDF conformance level <" + letter + "> is unknown.");
|
throw new IllegalArgumentException("PDF conformance level <" + letter + "> is unknown.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,46 +19,48 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustangproject's ZUGFeRD implementation
|
* Mustangproject's ZUGFeRD implementation
|
||||||
* ZUGFeRD exporter helper class
|
* ZUGFeRD exporter helper class
|
||||||
* Licensed under the APLv2
|
* Licensed under the APLv2
|
||||||
* @date 2015-10-29
|
*
|
||||||
* @version 1.2.0
|
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* @version 1.2.0
|
||||||
|
* @date 2015-10-29
|
||||||
|
*/
|
||||||
public class VATAmount {
|
public class VATAmount {
|
||||||
|
|
||||||
public VATAmount(BigDecimal basis, BigDecimal calculated) {
|
public VATAmount(BigDecimal basis, BigDecimal calculated) {
|
||||||
super();
|
super();
|
||||||
this.basis = basis;
|
this.basis = basis;
|
||||||
this.calculated = calculated;
|
this.calculated = calculated;
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal basis, calculated;
|
BigDecimal basis, calculated;
|
||||||
|
|
||||||
public BigDecimal getBasis() {
|
public BigDecimal getBasis() {
|
||||||
return basis;
|
return basis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBasis(BigDecimal basis) {
|
public void setBasis(BigDecimal basis) {
|
||||||
this.basis = basis;
|
this.basis = basis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getCalculated() {
|
public BigDecimal getCalculated() {
|
||||||
return calculated;
|
return calculated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCalculated(BigDecimal calculated) {
|
public void setCalculated(BigDecimal calculated) {
|
||||||
this.calculated = calculated;
|
this.calculated = calculated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VATAmount add(VATAmount v) {
|
public VATAmount add(VATAmount v) {
|
||||||
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()));
|
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public VATAmount subtract(VATAmount v) {
|
public VATAmount subtract(VATAmount v) {
|
||||||
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()));
|
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
|||||||
|
|
||||||
|
|
||||||
protected void setZUGFeRDVersion(int ver) {
|
protected void setZUGFeRDVersion(int ver) {
|
||||||
namespace=ZUGFeRDExporter.getNamespaceForVersion(ver);
|
namespace = ZUGFeRDExporter.getNamespaceForVersion(ver);
|
||||||
prefix=ZUGFeRDExporter.getPrefixForVersion(ver);
|
prefix = ZUGFeRDExporter.getPrefixForVersion(ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private DefinedStructuredType addProperty(ArrayProperty parent, String name, String type, String category,
|
private DefinedStructuredType addProperty(ArrayProperty parent, String name, String type, String category,
|
||||||
String description) {
|
String description) {
|
||||||
XMPMetadata metadata = getMetadata();
|
XMPMetadata metadata = getMetadata();
|
||||||
|
|
||||||
DefinedStructuredType li = new DefinedStructuredType(metadata, getNamespace(), getPrefix(),
|
DefinedStructuredType li = new DefinedStructuredType(metadata, getNamespace(), getPrefix(),
|
||||||
|
|||||||
@@ -25,28 +25,29 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
* @version 1.2.0s
|
* @version 1.2.0s
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* */
|
||||||
|
|
||||||
import org.apache.xmpbox.XMPMetadata;
|
import org.apache.xmpbox.XMPMetadata;
|
||||||
import org.apache.xmpbox.schema.XMPSchema;
|
import org.apache.xmpbox.schema.XMPSchema;
|
||||||
|
|
||||||
public class XMPSchemaZugferd extends XMPSchema {
|
public class XMPSchemaZugferd extends XMPSchema {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is what needs to be added to the RDF metadata - basically the name of the embedded Zugferd file
|
* This is what needs to be added to the RDF metadata - basically the name of the embedded Zugferd file
|
||||||
*/
|
*/
|
||||||
public XMPSchemaZugferd(XMPMetadata metadata, ZUGFeRDConformanceLevel conformanceLevel, String URN, String prefix, String filename) {
|
public XMPSchemaZugferd(XMPMetadata metadata, ZUGFeRDConformanceLevel conformanceLevel, String URN, String prefix, String filename) {
|
||||||
super(metadata, URN, prefix, "ZUGFeRD Schema");
|
super(metadata, URN, prefix, "ZUGFeRD Schema");
|
||||||
|
|
||||||
setAboutAsSimple("");
|
setAboutAsSimple("");
|
||||||
|
|
||||||
String conformanceLevelValue=conformanceLevel.name();
|
String conformanceLevelValue = conformanceLevel.name();
|
||||||
if (conformanceLevelValue.equals("BASICWL")) {
|
if (conformanceLevelValue.equals("BASICWL")) {
|
||||||
conformanceLevelValue="BASIC WL";
|
conformanceLevelValue = "BASIC WL";
|
||||||
} else if (conformanceLevelValue.equals("EN16931")) {
|
} else if (conformanceLevelValue.equals("EN16931")) {
|
||||||
conformanceLevelValue="EN 16931";
|
conformanceLevelValue = "EN 16931";
|
||||||
}
|
}
|
||||||
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
|
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
|
||||||
setTextPropertyValue("DocumentType", "INVOICE");
|
setTextPropertyValue("DocumentType", "INVOICE");
|
||||||
setTextPropertyValue("DocumentFileName", filename);
|
setTextPropertyValue("DocumentFileName", filename);
|
||||||
setTextPropertyValue("Version", "1.0");
|
setTextPropertyValue("Version", "1.0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,14 +36,13 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
|
|||||||
private boolean isTest;
|
private boolean isTest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enables the flag to indicate a test invoice in the XML structure
|
* enables the flag to indicate a test invoice in the XML structure
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void setTest() {
|
public void setTest() {
|
||||||
isTest = true;
|
isTest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZUGFeRD1PullProvider() {
|
public ZUGFeRD1PullProvider() {
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
try {
|
try {
|
||||||
@@ -51,16 +50,16 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
|
|||||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||||
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
|
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
|
||||||
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new ZFNamespacePrefixMapper());
|
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new ZFNamespacePrefixMapper());
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
throw new ZUGFeRDExportException("Could not initialize JAXB", e);
|
throw new ZUGFeRDExportException("Could not initialize JAXB", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createZugferdXMLForTransaction(IZUGFeRDExportableTransaction trans) {
|
private String createZugferdXMLForTransaction(IZUGFeRDExportableTransaction trans) {
|
||||||
|
|
||||||
JAXBElement<CrossIndustryDocumentType> jaxElement =
|
JAXBElement<CrossIndustryDocumentType> jaxElement =
|
||||||
new ZUGFeRDTransactionModelConverter(trans).withTest(isTest).convertToModel();
|
new ZUGFeRDTransactionModelConverter(trans).withTest(isTest).convertToModel();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return marshalJaxToXMLString(jaxElement);
|
return marshalJaxToXMLString(jaxElement);
|
||||||
@@ -84,23 +83,22 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateXML(IZUGFeRDExportableTransaction trans) {
|
public void generateXML(IZUGFeRDExportableTransaction trans) {
|
||||||
// create a dummy file stream, this would probably normally be a
|
// create a dummy file stream, this would probably normally be a
|
||||||
// FileInputStream
|
// FileInputStream
|
||||||
|
|
||||||
byte[] zugferdRaw = createZugferdXMLForTransaction(trans).getBytes(); //$NON-NLS-1$
|
byte[] zugferdRaw = createZugferdXMLForTransaction(trans).getBytes(); //$NON-NLS-1$
|
||||||
|
|
||||||
if ((zugferdRaw[0] == (byte) 0xEF)
|
if ((zugferdRaw[0] == (byte) 0xEF)
|
||||||
&& (zugferdRaw[1] == (byte) 0xBB)
|
&& (zugferdRaw[1] == (byte) 0xBB)
|
||||||
&& (zugferdRaw[2] == (byte) 0xBF)) {
|
&& (zugferdRaw[2] == (byte) 0xBF)) {
|
||||||
// I don't like BOMs, lets remove it
|
// I don't like BOMs, lets remove it
|
||||||
zugferdData = new byte[zugferdRaw.length - 3];
|
zugferdData = new byte[zugferdRaw.length - 3];
|
||||||
System.arraycopy(zugferdRaw, 3, zugferdData, 0,
|
System.arraycopy(zugferdRaw, 3, zugferdData, 0,
|
||||||
zugferdRaw.length - 3);
|
zugferdRaw.length - 3);
|
||||||
} else {
|
} else {
|
||||||
zugferdData = zugferdRaw;
|
zugferdData = zugferdRaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,18 +29,18 @@ import java.util.HashMap;
|
|||||||
public class ZUGFeRD2PullProvider implements IXMLProvider {
|
public class ZUGFeRD2PullProvider implements IXMLProvider {
|
||||||
|
|
||||||
private class LineCalc {
|
private class LineCalc {
|
||||||
private IZUGFeRDExportableItem currentItem=null;
|
private IZUGFeRDExportableItem currentItem = null;
|
||||||
private BigDecimal totalGross;
|
private BigDecimal totalGross;
|
||||||
private BigDecimal itemTotalNetAmount;
|
private BigDecimal itemTotalNetAmount;
|
||||||
private BigDecimal itemTotalVATAmount;
|
private BigDecimal itemTotalVATAmount;
|
||||||
|
|
||||||
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
public LineCalc(IZUGFeRDExportableItem currentItem) {
|
||||||
this.currentItem=currentItem;
|
this.currentItem = currentItem;
|
||||||
BigDecimal multiplicator=currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
|
BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
|
||||||
// priceGross=currentItem.getPrice().multiply(multiplicator);
|
// priceGross=currentItem.getPrice().multiply(multiplicator);
|
||||||
totalGross=currentItem.getPrice().multiply(multiplicator).multiply(currentItem.getQuantity());
|
totalGross = currentItem.getPrice().multiply(multiplicator).multiply(currentItem.getQuantity());
|
||||||
itemTotalNetAmount=currentItem.getQuantity().multiply(currentItem.getPrice()).setScale(2,BigDecimal.ROUND_HALF_UP);
|
itemTotalNetAmount = currentItem.getQuantity().multiply(currentItem.getPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
itemTotalVATAmount=totalGross.subtract(itemTotalNetAmount);
|
itemTotalVATAmount = totalGross.subtract(itemTotalNetAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getItemTotalNetAmount() {
|
public BigDecimal getItemTotalNetAmount() {
|
||||||
@@ -54,7 +54,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// MAIN CLASS
|
//// MAIN CLASS
|
||||||
|
|
||||||
protected byte[] zugferdData;
|
protected byte[] zugferdData;
|
||||||
@@ -63,7 +62,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* enables the flag to indicate a test invoice in the XML structure
|
* enables the flag to indicate a test invoice in the XML structure
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void setTest() {
|
public void setTest() {
|
||||||
isTest = true;
|
isTest = true;
|
||||||
@@ -96,13 +94,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
*
|
*
|
||||||
* results 0.00 -1,10 -1,10 -1,01 20000123,34 20000123,34 12,00
|
* results 0.00 -1,10 -1,10 -1,01 20000123,34 20000123,34 12,00
|
||||||
*/
|
*/
|
||||||
value=value.setScale( scale, BigDecimal.ROUND_HALF_UP ); // first, round so that e.g. 1.189999999999999946709294817992486059665679931640625 becomes 1.19
|
value = value.setScale(scale, BigDecimal.ROUND_HALF_UP); // first, round so that e.g. 1.189999999999999946709294817992486059665679931640625 becomes 1.19
|
||||||
char[] repeat = new char[scale];
|
char[] repeat = new char[scale];
|
||||||
Arrays.fill(repeat, '0');
|
Arrays.fill(repeat, '0');
|
||||||
|
|
||||||
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
|
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
|
||||||
otherSymbols.setDecimalSeparator('.');
|
otherSymbols.setDecimalSeparator('.');
|
||||||
DecimalFormat dec = new DecimalFormat("0."+new String(repeat), otherSymbols);
|
DecimalFormat dec = new DecimalFormat("0." + new String(repeat), otherSymbols);
|
||||||
return dec.format(value);
|
return dec.format(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -118,6 +116,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
private String priceFormat(BigDecimal value) {
|
private String priceFormat(BigDecimal value) {
|
||||||
return nDigitFormat(value, 4);
|
return nDigitFormat(value, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String quantityFormat(BigDecimal value) {
|
private String quantityFormat(BigDecimal value) {
|
||||||
return nDigitFormat(value, 4);
|
return nDigitFormat(value, 4);
|
||||||
}
|
}
|
||||||
@@ -129,11 +128,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
|
|
||||||
private BigDecimal getTotalGross() {
|
private BigDecimal getTotalGross() {
|
||||||
|
|
||||||
BigDecimal res=getTotal();
|
BigDecimal res = getTotal();
|
||||||
HashMap<BigDecimal, VATAmount> VATPercentAmountMap=getVATPercentAmountMap();
|
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
||||||
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
||||||
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
||||||
res=res.add(amount.getCalculated());
|
res = res.add(amount.getCalculated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -141,10 +140,10 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal getTotal() {
|
private BigDecimal getTotal() {
|
||||||
BigDecimal res=new BigDecimal(0);
|
BigDecimal res = new BigDecimal(0);
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
LineCalc lc=new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
res=res.add(lc.getItemTotalNetAmount());
|
res = res.add(lc.getItemTotalNetAmount());
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -154,18 +153,18 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
* empty for no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable
|
* empty for no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable
|
||||||
* to 19% VAT (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT)
|
* to 19% VAT (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT)
|
||||||
* 190 Eur
|
* 190 Eur
|
||||||
* @return which taxes have been used with which amounts in this invoice
|
|
||||||
*
|
*
|
||||||
*/
|
* @return which taxes have been used with which amounts in this invoice
|
||||||
|
*/
|
||||||
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap() {
|
private HashMap<BigDecimal, VATAmount> getVATPercentAmountMap() {
|
||||||
HashMap<BigDecimal, VATAmount> hm=new HashMap<BigDecimal, VATAmount> ();
|
HashMap<BigDecimal, VATAmount> hm = new HashMap<BigDecimal, VATAmount>();
|
||||||
|
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
BigDecimal percent=currentItem.getProduct().getVATPercent();
|
BigDecimal percent = currentItem.getProduct().getVATPercent();
|
||||||
LineCalc lc=new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
VATAmount itemVATAmount=new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount() ) ;
|
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount());
|
||||||
VATAmount current=hm.get(percent);
|
VATAmount current = hm.get(percent);
|
||||||
if (current==null) {
|
if (current == null) {
|
||||||
hm.put(percent, itemVATAmount);
|
hm.put(percent, itemVATAmount);
|
||||||
} else {
|
} else {
|
||||||
hm.put(percent, current.add(itemVATAmount));
|
hm.put(percent, current.add(itemVATAmount));
|
||||||
@@ -180,17 +179,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void generateXML(IZUGFeRDExportableTransaction trans) {
|
public void generateXML(IZUGFeRDExportableTransaction trans) {
|
||||||
|
|
||||||
this.trans=trans;
|
this.trans = trans;
|
||||||
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$
|
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$
|
||||||
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
|
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
|
||||||
String testBooleanStr="false";
|
String testBooleanStr = "false";
|
||||||
if (isTest) {
|
if (isTest) {
|
||||||
testBooleanStr="true";
|
testBooleanStr = "true";
|
||||||
|
|
||||||
}
|
}
|
||||||
String senderReg="";
|
String senderReg = "";
|
||||||
if (trans.getOwnOrganisationFullPlaintextInfo()!=null) {
|
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
|
||||||
senderReg=""
|
senderReg = ""
|
||||||
+ "<ram:IncludedCINote>\n"
|
+ "<ram:IncludedCINote>\n"
|
||||||
+ " <ram:Content>\n"
|
+ " <ram:Content>\n"
|
||||||
+ trans.getOwnOrganisationFullPlaintextInfo()
|
+ trans.getOwnOrganisationFullPlaintextInfo()
|
||||||
@@ -201,25 +200,24 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
||||||
|
|
||||||
String xml= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
|
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
||||||
|
|
||||||
+ "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\""
|
|
||||||
// + " xsi:schemaLocation=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100 ../Schema/ZUGFeRD1p0.xsd\""
|
// + " xsi:schemaLocation=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100 ../Schema/ZUGFeRD1p0.xsd\""
|
||||||
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\""
|
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\""
|
||||||
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" //$NON-NLS-1$
|
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" //$NON-NLS-1$
|
||||||
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||||
// + " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
// + " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\n" //$NON-NLS-1$
|
||||||
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
+ " <ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ID>urn:cen.eu:en16931:2017:compliant:factur-x.eu:1p0:en16931</ram:ID>\n" //$NON-NLS-1$
|
+ " <ram:ID>urn:cen.eu:en16931:2017:compliant:factur-x.eu:1p0:en16931</ram:ID>\n" //$NON-NLS-1$
|
||||||
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
+ " </ram:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
|
||||||
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
|
||||||
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ID>"+trans.getNumber()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:ID>" + trans.getNumber() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// + " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
// + " <ram:Name>RECHNUNG</ram:Name>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
+ " <ram:TypeCode>380</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getIssueDate())+"</udt:DateTimeString></ram:IssueDateTime>\n" //date format was 20130605 //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:IssueDateTime><udt:DateTimeString format=\"102\">" + zugferdDateFormat.format(trans.getIssueDate()) + "</udt:DateTimeString></ram:IssueDateTime>\n" //date format was 20130605 //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ senderReg
|
+ senderReg
|
||||||
// + " <IncludedNote>\n"
|
// + " <IncludedNote>\n"
|
||||||
// + " <Content>\n"
|
// + " <Content>\n"
|
||||||
// + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
|
// + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
|
||||||
@@ -232,145 +230,142 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
// + " </Content>\n"
|
// + " </Content>\n"
|
||||||
// + " <SubjectCode>AAK</SubjectCode>\n"
|
// + " <SubjectCode>AAK</SubjectCode>\n"
|
||||||
// + " </IncludedNote>\n"
|
// + " </IncludedNote>\n"
|
||||||
+ " </rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
+ " </rsm:ExchangedDocument>\n" //$NON-NLS-1$
|
||||||
+ " <rsm:SupplyChainTradeTransaction>\n"; //$NON-NLS-1$
|
+ " <rsm:SupplyChainTradeTransaction>\n"; //$NON-NLS-1$
|
||||||
int lineID=0;
|
int lineID = 0;
|
||||||
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
|
||||||
lineID++;
|
lineID++;
|
||||||
|
|
||||||
LineCalc lc=new LineCalc(currentItem);
|
LineCalc lc = new LineCalc(currentItem);
|
||||||
xml=xml+ " <ram:IncludedSupplyChainTradeLineItem>\n"+ //$NON-NLS-1$
|
xml = xml + " <ram:IncludedSupplyChainTradeLineItem>\n" + //$NON-NLS-1$
|
||||||
" <ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
" <ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
||||||
+ " <ram:LineID>"+lineID+"</ram:LineID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:LineID>" + lineID + "</ram:LineID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
+ " </ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
||||||
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
|
||||||
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
|
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
|
||||||
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
|
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
|
||||||
+ " <ram:Name>"+currentItem.getProduct().getName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:Name>" + currentItem.getProduct().getName() + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:Description>"+currentItem.getProduct().getDescription()+"</ram:Description>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:Description>" + currentItem.getProduct().getDescription() + "</ram:Description>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
|
||||||
|
|
||||||
+ " <ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
||||||
+ " <ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
+ " <ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ChargeAmount>"+priceFormat(currentItem.getPrice())+"</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ //currencyID=\"EUR\"
|
+ " <ram:ChargeAmount>" + priceFormat(currentItem.getPrice()) + "</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ //currencyID=\"EUR\"
|
||||||
+ " <ram:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:BasisQuantity unitCode=\"" + currentItem.getProduct().getUnit() + "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// + " <AppliedTradeAllowanceCharge>\n"
|
// + " <AppliedTradeAllowanceCharge>\n"
|
||||||
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
// + " <ChargeIndicator>false</ChargeIndicator>\n"
|
||||||
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
|
||||||
// + " <Reason>Rabatt</Reason>\n"
|
// + " <Reason>Rabatt</Reason>\n"
|
||||||
// + " </AppliedTradeAllowanceCharge>\n"
|
// + " </AppliedTradeAllowanceCharge>\n"
|
||||||
+ " </ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
+ " </ram:GrossPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||||
+ " <ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
+ " <ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ChargeAmount>"+priceFormat(currentItem.getPrice())+"</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
+ " <ram:ChargeAmount>" + priceFormat(currentItem.getPrice()) + "</ram:ChargeAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
||||||
+ " <ram:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:BasisQuantity unitCode=\"" + currentItem.getProduct().getUnit() + "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
|
||||||
+ " </ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
|
||||||
|
|
||||||
+ " <ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
||||||
+ " <ram:BilledQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">"+quantityFormat(currentItem.getQuantity())+"</ram:BilledQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
+ " <ram:BilledQuantity unitCode=\"" + currentItem.getProduct().getUnit() + "\">" + quantityFormat(currentItem.getQuantity()) + "</ram:BilledQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
+ " </ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
+ " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:RateApplicablePercent>"+vatFormat(currentItem.getProduct().getVATPercent())+"</ram:RateApplicablePercent>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:RateApplicablePercent>" + vatFormat(currentItem.getProduct().getVATPercent()) + "</ram:RateApplicablePercent>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
+ " </ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
|
||||||
+ " <ram:LineTotalAmount>"+currencyFormat(lc.getItemTotalNetAmount())+"</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
+ " <ram:LineTotalAmount>" + currencyFormat(lc.getItemTotalNetAmount()) + "</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
||||||
+ " </ram:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
|
||||||
+ " </ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
|
||||||
+ " </ram:IncludedSupplyChainTradeLineItem>\n"; //$NON-NLS-1$
|
+ " </ram:IncludedSupplyChainTradeLineItem>\n"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
xml = xml + " <ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
||||||
|
|
||||||
xml=xml+ " <ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
|
||||||
// + " <BuyerReference>AB-312</BuyerReference>\n"
|
// + " <BuyerReference>AB-312</BuyerReference>\n"
|
||||||
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
|
||||||
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
|
||||||
+ " <ram:Name>"+trans.getOwnOrganisationName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:Name>" + trans.getOwnOrganisationName() + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:PostalTradeAddress>\n"
|
+ " <ram:PostalTradeAddress>\n"
|
||||||
+ " <ram:PostcodeCode>"+trans.getOwnZIP()+"</ram:PostcodeCode>\n"
|
+ " <ram:PostcodeCode>" + trans.getOwnZIP() + "</ram:PostcodeCode>\n"
|
||||||
+ " <ram:LineOne>"+trans.getOwnStreet()+"</ram:LineOne>\n"
|
+ " <ram:LineOne>" + trans.getOwnStreet() + "</ram:LineOne>\n"
|
||||||
+ " <ram:CityName>"+trans.getOwnLocation()+"</ram:CityName>\n"
|
+ " <ram:CityName>" + trans.getOwnLocation() + "</ram:CityName>\n"
|
||||||
+ " <ram:CountryID>"+trans.getOwnCountry()+"</ram:CountryID>\n"
|
+ " <ram:CountryID>" + trans.getOwnCountry() + "</ram:CountryID>\n"
|
||||||
+ " </ram:PostalTradeAddress>\n"
|
+ " </ram:PostalTradeAddress>\n"
|
||||||
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ID schemeID=\"FC\">"+trans.getOwnTaxID()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:ID schemeID=\"FC\">" + trans.getOwnTaxID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ID schemeID=\"VA\">"+trans.getOwnVATID()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:ID schemeID=\"VA\">" + trans.getOwnVATID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
||||||
+ " </ram:SellerTradeParty>\n" //$NON-NLS-1$
|
+ " </ram:SellerTradeParty>\n" //$NON-NLS-1$
|
||||||
+ " <ram:BuyerTradeParty>\n" //$NON-NLS-1$
|
+ " <ram:BuyerTradeParty>\n" //$NON-NLS-1$
|
||||||
// + " <ID>GE2020211</ID>\n"
|
// + " <ID>GE2020211</ID>\n"
|
||||||
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
|
// + " <GlobalID schemeID=\"0088\">4000001987658</GlobalID>\n"
|
||||||
+ " <ram:Name>"+trans.getRecipient().getName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:Name>" + trans.getRecipient().getName() + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// + " <DefinedTradeContact>\n"
|
// + " <DefinedTradeContact>\n"
|
||||||
// + " <PersonName>xxx</PersonName>\n"
|
// + " <PersonName>xxx</PersonName>\n"
|
||||||
// + " </DefinedTradeContact>\n"
|
// + " </DefinedTradeContact>\n"
|
||||||
+ " <ram:PostalTradeAddress>\n" //$NON-NLS-1$
|
+ " <ram:PostalTradeAddress>\n" //$NON-NLS-1$
|
||||||
+ " <ram:PostcodeCode>"+trans.getRecipient().getZIP()+"</ram:PostcodeCode>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:PostcodeCode>" + trans.getRecipient().getZIP() + "</ram:PostcodeCode>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:LineOne>"+trans.getRecipient().getStreet()+"</ram:LineOne>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:LineOne>" + trans.getRecipient().getStreet() + "</ram:LineOne>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:CityName>"+trans.getRecipient().getLocation()+"</ram:CityName>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:CityName>" + trans.getRecipient().getLocation() + "</ram:CityName>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:CountryID>"+trans.getRecipient().getCountry()+"</ram:CountryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:CountryID>" + trans.getRecipient().getCountry() + "</ram:CountryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:PostalTradeAddress>\n" //$NON-NLS-1$
|
+ " </ram:PostalTradeAddress>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ID schemeID=\"VA\">"+trans.getRecipient().getVATID()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:ID schemeID=\"VA\">" + trans.getRecipient().getVATID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
|
||||||
+ " </ram:BuyerTradeParty>\n" //$NON-NLS-1$
|
+ " </ram:BuyerTradeParty>\n" //$NON-NLS-1$
|
||||||
// + " <BuyerOrderReferencedDocument>\n"
|
// + " <BuyerOrderReferencedDocument>\n"
|
||||||
// + " <IssueDateTime format=\"102\">20130301</IssueDateTime>\n"
|
// + " <IssueDateTime format=\"102\">20130301</IssueDateTime>\n"
|
||||||
// + " <ID>2013-471331</ID>\n"
|
// + " <ID>2013-471331</ID>\n"
|
||||||
// + " </BuyerOrderReferencedDocument>\n"
|
// + " </BuyerOrderReferencedDocument>\n"
|
||||||
+ " </ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
+ " </ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
|
||||||
+ " <ram:ApplicableHeaderTradeDelivery>\n"
|
+ " <ram:ApplicableHeaderTradeDelivery>\n"
|
||||||
+ " <ram:ActualDeliverySupplyChainEvent>\n"
|
+ " <ram:ActualDeliverySupplyChainEvent>\n"
|
||||||
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDeliveryDate())+"</udt:DateTimeString></ram:OccurrenceDateTime>\n"
|
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">" + zugferdDateFormat.format(trans.getDeliveryDate()) + "</udt:DateTimeString></ram:OccurrenceDateTime>\n"
|
||||||
+ " </ram:ActualDeliverySupplyChainEvent>\n"
|
+ " </ram:ActualDeliverySupplyChainEvent>\n"
|
||||||
/*
|
/*
|
||||||
+ " <DeliveryNoteReferencedDocument>\n"
|
+ " <DeliveryNoteReferencedDocument>\n"
|
||||||
+ " <IssueDateTime format=\"102\">20130603</IssueDateTime>\n"
|
+ " <IssueDateTime format=\"102\">20130603</IssueDateTime>\n"
|
||||||
+ " <ID>2013-51112</ID>\n"
|
+ " <ID>2013-51112</ID>\n"
|
||||||
+ " </DeliveryNoteReferencedDocument>\n" */
|
+ " </DeliveryNoteReferencedDocument>\n" */
|
||||||
+ " </ram:ApplicableHeaderTradeDelivery>\n"
|
+ " </ram:ApplicableHeaderTradeDelivery>\n"
|
||||||
+ " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-1$
|
+ " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-1$
|
||||||
+ " <ram:PaymentReference>"+trans.getNumber()+"</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:PaymentReference>" + trans.getNumber() + "</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
|
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TypeCode>42</ram:TypeCode>\n" //$NON-NLS-1$
|
+ " <ram:TypeCode>42</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:Information>Überweisung</ram:Information>\n" //$NON-NLS-1$
|
+ " <ram:Information>Überweisung</ram:Information>\n" //$NON-NLS-1$
|
||||||
+ " <ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
+ " <ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
||||||
+ " <ram:IBANID>"+trans.getOwnIBAN()+"</ram:IBANID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:IBANID>" + trans.getOwnIBAN() + "</ram:IBANID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:ProprietaryID>"+trans.getOwnKto()+"</ram:ProprietaryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:ProprietaryID>" + trans.getOwnKto() + "</ram:ProprietaryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
+ " </ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
|
||||||
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
||||||
+ " <ram:BICID>"+trans.getOwnBIC()+"</ram:BICID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:BICID>" + trans.getOwnBIC() + "</ram:BICID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:GermanBankleitzahlID>"+ trans.getOwnBLZ()+"</ram:GermanBankleitzahlID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:GermanBankleitzahlID>" + trans.getOwnBLZ() + "</ram:GermanBankleitzahlID>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// + " <ram:Name>"+trans.getOwnBankName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
// + " <ram:Name>"+trans.getOwnBankName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
+ " </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
|
||||||
+ " </ram:SpecifiedTradeSettlementPaymentMeans>\n"; //$NON-NLS-1$
|
+ " </ram:SpecifiedTradeSettlementPaymentMeans>\n"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
|
||||||
HashMap<BigDecimal, VATAmount> VATPercentAmountMap=getVATPercentAmountMap();
|
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
||||||
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
|
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
||||||
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
|
if (amount != null) {
|
||||||
if (amount != null) {
|
xml += " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
||||||
xml += " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
|
+ " <ram:CalculatedAmount>" + currencyFormat(amount.getCalculated()) + "</ram:CalculatedAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ //currencyID=\"EUR\"
|
||||||
+ " <ram:CalculatedAmount>"+currencyFormat(amount.getCalculated())+"</ram:CalculatedAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ //currencyID=\"EUR\"
|
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:TypeCode>VAT</ram:TypeCode>\n" //$NON-NLS-1$
|
+ " <ram:BasisAmount>" + currencyFormat(amount.getBasis()) + "</ram:BasisAmount>\n" // currencyID=\"EUR\"
|
||||||
+ " <ram:BasisAmount>"+currencyFormat(amount.getBasis())+"</ram:BasisAmount>\n" // currencyID=\"EUR\"
|
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
||||||
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
|
+ " <ram:RateApplicablePercent>" + vatFormat(currentTaxPercent) + "</ram:RateApplicablePercent>\n" //$NON-NLS-1$
|
||||||
+ " <ram:RateApplicablePercent>"+vatFormat(currentTaxPercent)+"</ram:RateApplicablePercent>\n" //$NON-NLS-1$
|
+ " </ram:ApplicableTradeTax>\n"; //$NON-NLS-1$
|
||||||
+ " </ram:ApplicableTradeTax>\n"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* xml+= "
|
/* xml+= "
|
||||||
+ " <SpecifiedTradeAllowanceCharge>\n"
|
+ " <SpecifiedTradeAllowanceCharge>\n"
|
||||||
+ " <ChargeIndicator>false</ChargeIndicator>\n"
|
+ " <ChargeIndicator>false</ChargeIndicator>\n"
|
||||||
@@ -404,23 +399,23 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
+ " </AppliedTradeTax>\n"
|
+ " </AppliedTradeTax>\n"
|
||||||
+ " </SpecifiedLogisticsServiceCharge>\n"*/
|
+ " </SpecifiedLogisticsServiceCharge>\n"*/
|
||||||
|
|
||||||
xml=xml+ " <ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
xml = xml + " <ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
||||||
+ " <ram:Description>Zahlbar ohne Abzug bis "+germanDateFormat.format(trans.getDueDate())+"</ram:Description>\n"
|
+ " <ram:Description>Zahlbar ohne Abzug bis " + germanDateFormat.format(trans.getDueDate()) + "</ram:Description>\n"
|
||||||
+ " <ram:DueDateDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDueDate())+"</udt:DateTimeString></ram:DueDateDateTime>\n"//20130704 //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:DueDateDateTime><udt:DateTimeString format=\"102\">" + zugferdDateFormat.format(trans.getDueDate()) + "</udt:DateTimeString></ram:DueDateDateTime>\n"//20130704 //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " </ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
|
||||||
+ " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
+ " <ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
||||||
+ " <ram:LineTotalAmount>"+currencyFormat(getTotal())+"</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ currencyID=\"EUR\"
|
+ " <ram:LineTotalAmount>" + currencyFormat(getTotal()) + "</ram:LineTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ currencyID=\"EUR\"
|
||||||
+ " <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n" //$NON-NLS-1$ currencyID=\"EUR\"
|
+ " <ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n" //$NON-NLS-1$ currencyID=\"EUR\"
|
||||||
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //$NON-NLS-1$ // currencyID=\"EUR\"
|
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //$NON-NLS-1$ // currencyID=\"EUR\"
|
||||||
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>\n"
|
// + " <ChargeTotalAmount currencyID=\"EUR\">5.80</ChargeTotalAmount>\n"
|
||||||
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>\n"
|
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>\n"
|
||||||
+ " <ram:TaxBasisTotalAmount>"+currencyFormat(getTotal())+"</ram:TaxBasisTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
+ " <ram:TaxBasisTotalAmount>" + currencyFormat(getTotal()) + "</ram:TaxBasisTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
||||||
+ " <ram:TaxTotalAmount currencyID=\"EUR\">"+currencyFormat(getTotalGross().subtract(getTotal()))+"</ram:TaxTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
+ " <ram:TaxTotalAmount currencyID=\"EUR\">" + currencyFormat(getTotalGross().subtract(getTotal())) + "</ram:TaxTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ " <ram:GrandTotalAmount>"+currencyFormat(getTotalGross())+"</ram:GrandTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
+ " <ram:GrandTotalAmount>" + currencyFormat(getTotalGross()) + "</ram:GrandTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
||||||
// + " <TotalPrepaidAmount currencyID=\"EUR\">0.00</TotalPrepaidAmount>\n"
|
// + " <TotalPrepaidAmount currencyID=\"EUR\">0.00</TotalPrepaidAmount>\n"
|
||||||
+ " <ram:DuePayableAmount>"+currencyFormat(getTotalGross())+"</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
+ " <ram:DuePayableAmount>" + currencyFormat(getTotalGross()) + "</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
|
||||||
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
|
||||||
+ " </ram:ApplicableHeaderTradeSettlement>\n"; //$NON-NLS-1$
|
+ " </ram:ApplicableHeaderTradeSettlement>\n"; //$NON-NLS-1$
|
||||||
// + " <IncludedSupplyChainTradeLineItem>\n"
|
// + " <IncludedSupplyChainTradeLineItem>\n"
|
||||||
// + " <AssociatedDocumentLineDocument>\n"
|
// + " <AssociatedDocumentLineDocument>\n"
|
||||||
// + " <IncludedNote>\n"
|
// + " <IncludedNote>\n"
|
||||||
@@ -430,26 +425,24 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
|
|||||||
// + " </IncludedSupplyChainTradeLineItem>\n";
|
// + " </IncludedSupplyChainTradeLineItem>\n";
|
||||||
|
|
||||||
|
|
||||||
|
xml = xml + " </rsm:SupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
||||||
|
+ "</rsm:CrossIndustryInvoice>"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
byte[] zugferdRaw;
|
||||||
|
try {
|
||||||
|
zugferdRaw = xml.getBytes("UTF-8");
|
||||||
|
|
||||||
xml=xml + " </rsm:SupplyChainTradeTransaction>\n" //$NON-NLS-1$
|
if ((zugferdRaw[0] == (byte) 0xEF) && (zugferdRaw[1] == (byte) 0xBB) && (zugferdRaw[2] == (byte) 0xBF)) {
|
||||||
+ "</rsm:CrossIndustryInvoice>"; //$NON-NLS-1$
|
// I don't like BOMs, lets remove it
|
||||||
|
zugferdData = new byte[zugferdRaw.length - 3];
|
||||||
byte[] zugferdRaw;
|
System.arraycopy(zugferdRaw, 3, zugferdData, 0, zugferdRaw.length - 3);
|
||||||
try {
|
} else {
|
||||||
zugferdRaw = xml.getBytes("UTF-8");
|
zugferdData = zugferdRaw;
|
||||||
|
}
|
||||||
if ((zugferdRaw[0]==(byte)0xEF)&&(zugferdRaw[1]==(byte)0xBB)&&(zugferdRaw[2]==(byte)0xBF)) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// I don't like BOMs, lets remove it
|
// TODO Auto-generated catch block
|
||||||
zugferdData=new byte[zugferdRaw.length-3];
|
e.printStackTrace();
|
||||||
System.arraycopy(zugferdRaw,3,zugferdData,0,zugferdRaw.length-3);
|
} //$NON-NLS-1$
|
||||||
} else {
|
|
||||||
zugferdData=zugferdRaw;
|
|
||||||
}
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,5 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
public enum ZUGFeRDConformanceLevel {
|
public enum ZUGFeRDConformanceLevel {
|
||||||
BASIC, COMFORT, EXTENDED, EN16931/*=Comfort*/, MINIMUM, BASICWL /*basic without lines, less than basic*/, CIUS
|
BASIC, COMFORT, EXTENDED, EN16931/*=Comfort*/, MINIMUM, BASICWL /*basic without lines, less than basic*/, CIUS;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,23 +19,23 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
public class ZUGFeRDExportException extends RuntimeException {
|
public class ZUGFeRDExportException extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public ZUGFeRDExportException() {
|
public ZUGFeRDExportException() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZUGFeRDExportException(String message) {
|
public ZUGFeRDExportException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZUGFeRDExportException(String message, Throwable cause) {
|
public ZUGFeRDExportException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZUGFeRDExportException(Throwable cause) {
|
public ZUGFeRDExportException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
public static final int DefaultZUGFeRDVersion = 1;
|
public static final int DefaultZUGFeRDVersion = 1;
|
||||||
|
|
||||||
private static boolean isFacturX=false;
|
private static boolean isFacturX = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To use the ZUGFeRD exporter, implement IZUGFeRDExportableTransaction in
|
* To use the ZUGFeRD exporter, implement IZUGFeRDExportableTransaction in
|
||||||
@@ -65,14 +65,13 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
* ze.PDFmakeA3compliant(doc, "Your application name",
|
* ze.PDFmakeA3compliant(doc, "Your application name",
|
||||||
* System.getProperty("user.name"), true); ze.PDFattachZugferdFile(doc,
|
* System.getProperty("user.name"), true); ze.PDFattachZugferdFile(doc,
|
||||||
* yourTransaction);
|
* yourTransaction);
|
||||||
*
|
* <p/>
|
||||||
* doc.save(PDFfilename);
|
* doc.save(PDFfilename);
|
||||||
*
|
*
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* @deprecated Use the factory methods {@link #createFromPDFA3(String)},
|
* @deprecated Use the factory methods {@link #createFromPDFA3(String)},
|
||||||
* {@link #createFromPDFA3(InputStream)} or the
|
* {@link #createFromPDFA3(InputStream)} or the
|
||||||
* {@link ZUGFeRDExporterFromA1Factory} instead
|
* {@link ZUGFeRDExporterFromA1Factory} instead
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
// // MAIN CLASS
|
// // MAIN CLASS
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -92,11 +91,17 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
protected PDMetadata metadata = null;
|
protected PDMetadata metadata = null;
|
||||||
protected PDFAIdentificationSchema pdfaid = null;
|
protected PDFAIdentificationSchema pdfaid = null;
|
||||||
protected XMPMetadata xmp = null;
|
protected XMPMetadata xmp = null;
|
||||||
/** Producer attribute for PDF */
|
/**
|
||||||
|
* Producer attribute for PDF
|
||||||
|
*/
|
||||||
protected String producer = "mustangproject";
|
protected String producer = "mustangproject";
|
||||||
/** Author/Creator attribute for PDF for PDF */
|
/**
|
||||||
|
* Author/Creator attribute for PDF for PDF
|
||||||
|
*/
|
||||||
protected String creator = "mustangproject";
|
protected String creator = "mustangproject";
|
||||||
/** CreatorTool */
|
/**
|
||||||
|
* CreatorTool
|
||||||
|
*/
|
||||||
protected String creatorTool = "mustangproject";
|
protected String creatorTool = "mustangproject";
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -105,7 +110,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
private PDDocument doc;
|
private PDDocument doc;
|
||||||
int ZFVersion;
|
int ZFVersion;
|
||||||
|
|
||||||
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
|
private HashMap<String, byte[]> additionalXMLs = new HashMap<String, byte[]>();
|
||||||
|
|
||||||
|
|
||||||
private boolean disableAutoClose;
|
private boolean disableAutoClose;
|
||||||
@@ -113,7 +118,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
private boolean fileAttached = false;
|
private boolean fileAttached = false;
|
||||||
protected boolean attachZUGFeRDHeaders = true;
|
protected boolean attachZUGFeRDHeaders = true;
|
||||||
|
|
||||||
private boolean documentPrepared=false;
|
private boolean documentPrepared = false;
|
||||||
|
|
||||||
public ZUGFeRDExporter() {
|
public ZUGFeRDExporter() {
|
||||||
init();
|
init();
|
||||||
@@ -182,19 +187,19 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
public void setFacturX() {
|
public void setFacturX() {
|
||||||
setZUGFeRDVersion(2);
|
setZUGFeRDVersion(2);
|
||||||
isFacturX=true;
|
isFacturX = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All files are PDF/A-3, setConformance refers to the level conformance.
|
* All files are PDF/A-3, setConformance refers to the level conformance.
|
||||||
*
|
* <p/>
|
||||||
* PDF/A-3 has three conformance levels, called "A", "U" and "B".
|
* PDF/A-3 has three conformance levels, called "A", "U" and "B".
|
||||||
*
|
* <p/>
|
||||||
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
||||||
* means visually and unicode preservable and A means full compliance, i.e.
|
* means visually and unicode preservable and A means full compliance, i.e.
|
||||||
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
||||||
* metainformation for blind people.
|
* metainformation for blind people.
|
||||||
*
|
* <p/>
|
||||||
* Feel free to pass "A" as new level if you know what you are doing :-)
|
* Feel free to pass "A" as new level if you know what you are doing :-)
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link ZUGFeRDExporterFromA1Factory} instead
|
* @deprecated Use {@link ZUGFeRDExporterFromA1Factory} instead
|
||||||
@@ -209,19 +214,19 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* All files are PDF/A-3, setConformance refers to the level conformance.
|
* All files are PDF/A-3, setConformance refers to the level conformance.
|
||||||
*
|
* <p/>
|
||||||
* PDF/A-3 has three conformance levels, called "A", "U" and "B".
|
* PDF/A-3 has three conformance levels, called "A", "U" and "B".
|
||||||
*
|
* <p/>
|
||||||
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
||||||
* means visually and unicode preservable and A means full compliance, i.e.
|
* means visually and unicode preservable and A means full compliance, i.e.
|
||||||
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
||||||
* metainformation for blind people.
|
* metainformation for blind people.
|
||||||
*
|
* <p/>
|
||||||
* Feel free to pass "A" as new level if you know what you are doing :-)
|
* Feel free to pass "A" as new level if you know what you are doing :-)
|
||||||
*
|
*
|
||||||
* @deprecated Use
|
* @deprecated Use
|
||||||
* {@link #setConformanceLevel(org.mustangproject.ZUGFeRD.PDFAConformanceLevel)}
|
* {@link #setConformanceLevel(org.mustangproject.ZUGFeRD.PDFAConformanceLevel)}
|
||||||
* instead
|
* instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setConformanceLevel(String newLevel) {
|
public void setConformanceLevel(String newLevel) {
|
||||||
@@ -230,7 +235,6 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* enables the flag to indicate a test invoice in the XML structure
|
* enables the flag to indicate a test invoice in the XML structure
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void setTest() {
|
public void setTest() {
|
||||||
xmlProvider.setTest();
|
xmlProvider.setTest();
|
||||||
@@ -258,7 +262,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use the factory method {@link #createFromPDFA3(InputStream)}
|
* @deprecated Use the factory method {@link #createFromPDFA3(InputStream)}
|
||||||
* instead
|
* instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void loadPDFA3(InputStream file) throws IOException {
|
public void loadPDFA3(InputStream file) throws IOException {
|
||||||
@@ -274,11 +278,10 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||||
*
|
*
|
||||||
* @deprecated use the {@link ZUGFeRDExporterFromA1Factory} instead
|
* @deprecated use the {@link ZUGFeRDExporterFromA1Factory} instead
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PDDocumentCatalog PDFmakeA3compliant(String filename, String producer, String creator,
|
public PDDocumentCatalog PDFmakeA3compliant(String filename, String producer, String creator,
|
||||||
boolean attachZugferdHeaders) throws IOException, TransformerException {
|
boolean attachZugferdHeaders) throws IOException, TransformerException {
|
||||||
|
|
||||||
doc = createPDFA1Factory().setProducer(producer).setCreator(creator).load(filename).doc;
|
doc = createPDFA1Factory().setProducer(producer).setCreator(creator).load(filename).doc;
|
||||||
|
|
||||||
@@ -290,7 +293,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public PDDocumentCatalog PDFmakeA3compliant(InputStream file, String producer, String creator,
|
public PDDocumentCatalog PDFmakeA3compliant(InputStream file, String producer, String creator,
|
||||||
boolean attachZugferdHeaders) throws IOException, TransformerException {
|
boolean attachZugferdHeaders) throws IOException, TransformerException {
|
||||||
|
|
||||||
doc = createPDFA1Factory().setProducer(producer).setCreator(creator).load(file).doc;
|
doc = createPDFA1Factory().setProducer(producer).setCreator(creator).load(file).doc;
|
||||||
|
|
||||||
@@ -315,11 +318,10 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Embeds the Zugferd XML structure in a file named ZUGFeRD-invoice.xml.
|
* Embeds the Zugferd XML structure in a file named ZUGFeRD-invoice.xml.
|
||||||
*
|
*
|
||||||
* @param trans
|
* @param trans a IZUGFeRDExportableTransaction that provides the data-model to
|
||||||
* a IZUGFeRDExportableTransaction that provides the data-model to
|
* populate the XML. This parameter may be null, if so the XML data
|
||||||
* populate the XML. This parameter may be null, if so the XML data
|
* should hav ebeen set via
|
||||||
* should hav ebeen set via
|
* <code>setZUGFeRDXMLData(byte[] zugferdData)</code>
|
||||||
* <code>setZUGFeRDXMLData(byte[] zugferdData)</code>
|
|
||||||
*/
|
*/
|
||||||
public void PDFattachZugferdFile(IZUGFeRDExportableTransaction trans) throws IOException {
|
public void PDFattachZugferdFile(IZUGFeRDExportableTransaction trans) throws IOException {
|
||||||
prepareDocument();
|
prepareDocument();
|
||||||
@@ -338,7 +340,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
if (!documentPrepared) {
|
if (!documentPrepared) {
|
||||||
prepareDocument();
|
prepareDocument();
|
||||||
}
|
}
|
||||||
if ((!fileAttached)&&(attachZUGFeRDHeaders)) {
|
if ((!fileAttached) && (attachZUGFeRDHeaders)) {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"File must be attached (usually with PDFattachZugferdFile) before perfoming this operation");
|
"File must be attached (usually with PDFattachZugferdFile) before perfoming this operation");
|
||||||
}
|
}
|
||||||
@@ -362,22 +364,16 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Embeds an external file (generic - any type allowed) in the PDF.
|
* Embeds an external file (generic - any type allowed) in the PDF.
|
||||||
*
|
*
|
||||||
* @param doc
|
* @param doc PDDocument to attach the file to.
|
||||||
* PDDocument to attach the file to.
|
* @param filename name of the file that will become attachment name in the PDF
|
||||||
* @param filename
|
* @param relationship how the file relates to the content, e.g. "Alternative"
|
||||||
* name of the file that will become attachment name in the PDF
|
* @param description Human-readable description of the file content
|
||||||
* @param relationship
|
* @param subType type of the data e.g. could be "text/xml" - mime like
|
||||||
* how the file relates to the content, e.g. "Alternative"
|
* @param data the binary data of the file/attachment
|
||||||
* @param description
|
|
||||||
* Human-readable description of the file content
|
|
||||||
* @param subType
|
|
||||||
* type of the data e.g. could be "text/xml" - mime like
|
|
||||||
* @param data
|
|
||||||
* the binary data of the file/attachment
|
|
||||||
* @throws java.io.IOException
|
* @throws java.io.IOException
|
||||||
*/
|
*/
|
||||||
public void PDFAttachGenericFile(PDDocument doc, String filename, String relationship, String description,
|
public void PDFAttachGenericFile(PDDocument doc, String filename, String relationship, String description,
|
||||||
String subType, byte[] data) throws IOException {
|
String subType, byte[] data) throws IOException {
|
||||||
fileAttached = true;
|
fileAttached = true;
|
||||||
|
|
||||||
PDComplexFileSpecification fs = new PDComplexFileSpecification();
|
PDComplexFileSpecification fs = new PDComplexFileSpecification();
|
||||||
@@ -443,8 +439,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
* useful for use-cases where the XML has already been produced by some external
|
* useful for use-cases where the XML has already been produced by some external
|
||||||
* API or component.
|
* API or component.
|
||||||
*
|
*
|
||||||
* @param zugferdData
|
* @param zugferdData XML data to be set as a byte array (XML file in raw form).
|
||||||
* XML data to be set as a byte array (XML file in raw form).
|
|
||||||
*/
|
*/
|
||||||
public void setZUGFeRDXMLData(byte[] zugferdData) throws IOException {
|
public void setZUGFeRDXMLData(byte[] zugferdData) throws IOException {
|
||||||
CustomXMLProvider cus = new CustomXMLProvider();
|
CustomXMLProvider cus = new CustomXMLProvider();
|
||||||
@@ -457,9 +452,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Sets the ZUGFeRD conformance level (override).
|
* Sets the ZUGFeRD conformance level (override).
|
||||||
*
|
*
|
||||||
* @param zUGFeRDConformanceLevel
|
* @param zUGFeRDConformanceLevel the new conformance level
|
||||||
* the new conformance level
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link ZUGFeRDExporterFromA1Factory} instead
|
* @deprecated Use {@link ZUGFeRDExporterFromA1Factory} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -473,9 +466,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Sets the ZUGFeRD conformance level (override).
|
* Sets the ZUGFeRD conformance level (override).
|
||||||
*
|
*
|
||||||
* @param zUGFeRDConformanceLevel
|
* @param zUGFeRDConformanceLevel the new conformance level
|
||||||
* the new conformance level
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link #setConformanceLevel(PDFAConformanceLevel)} instead
|
* @deprecated Use {@link #setConformanceLevel(PDFAConformanceLevel)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -483,7 +474,8 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
this.profile = ZUGFeRDConformanceLevel.valueOf(zUGFeRDConformanceLevel);
|
this.profile = ZUGFeRDConformanceLevel.valueOf(zUGFeRDConformanceLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****
|
/**
|
||||||
|
* *
|
||||||
* Returns the PDFBox PDF Document
|
* Returns the PDFBox PDF Document
|
||||||
*
|
*
|
||||||
* @return PDDocument the PDFBox PDF
|
* @return PDDocument the PDFBox PDF
|
||||||
@@ -589,11 +581,10 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
} catch (TransformerException e) {
|
} catch (TransformerException e) {
|
||||||
throw new ZUGFeRDExportException("Could not export XmpMetadata", e);
|
throw new ZUGFeRDExportException("Could not export XmpMetadata", e);
|
||||||
}
|
}
|
||||||
documentPrepared=true;
|
documentPrepared = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return if pdf file will be automatically closed after adding ZF
|
* @return if pdf file will be automatically closed after adding ZF
|
||||||
*/
|
*/
|
||||||
public boolean isAutoCloseDisabled() {
|
public boolean isAutoCloseDisabled() {
|
||||||
@@ -601,7 +592,6 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param disableAutoClose prevent PDF file from being closed after adding ZF
|
* @param disableAutoClose prevent PDF file from being closed after adding ZF
|
||||||
*/
|
*/
|
||||||
public void disableAutoClose(boolean disableAutoClose) {
|
public void disableAutoClose(boolean disableAutoClose) {
|
||||||
@@ -610,14 +600,17 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* the human author (use factory method instead)
|
* the human author (use factory method instead)
|
||||||
|
*
|
||||||
* @param creator
|
* @param creator
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setCreator(String creator) {
|
public void setCreator(String creator) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the CreatorTool attribute for the PDF
|
* the CreatorTool attribute for the PDF
|
||||||
|
*
|
||||||
* @param creator
|
* @param creator
|
||||||
*/
|
*/
|
||||||
protected void setCreatorTool(String creatorTool) {
|
protected void setCreatorTool(String creatorTool) {
|
||||||
@@ -626,6 +619,7 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* the authoring software (use factory method instead)
|
* the authoring software (use factory method instead)
|
||||||
|
*
|
||||||
* @param producer
|
* @param producer
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -634,7 +628,6 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param ensurePDFisUpgraded if not set the PDF/A won't be relabelled A/3, e.g. if it already is one
|
* @param ensurePDFisUpgraded if not set the PDF/A won't be relabelled A/3, e.g. if it already is one
|
||||||
*/
|
*/
|
||||||
public void setPDFA3(boolean ensurePDFisUpgraded) {
|
public void setPDFA3(boolean ensurePDFisUpgraded) {
|
||||||
@@ -642,11 +635,10 @@ public class ZUGFeRDExporter implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param attachZUGFeRDHeaders if false the ZUGFeRD XMP metadata won't be added, e.g. if it's not the first file
|
* @param attachZUGFeRDHeaders if false the ZUGFeRD XMP metadata won't be added, e.g. if it's not the first file
|
||||||
*/
|
*/
|
||||||
public void setAttachZUGFeRDHeaders(boolean attachZUGFeRDHeaders) {
|
public void setAttachZUGFeRDHeaders(boolean attachZUGFeRDHeaders) {
|
||||||
this.attachZUGFeRDHeaders=attachZUGFeRDHeaders;
|
this.attachZUGFeRDHeaders = attachZUGFeRDHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
|
||||||
public class ZUGFeRDExporterFromA1Factory extends ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
public class ZUGFeRDExporterFromA1Factory extends ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
||||||
public ZUGFeRDExporterFromA1Factory() {
|
public ZUGFeRDExporterFromA1Factory() {
|
||||||
ensurePDFisUpgraded=true;
|
ensurePDFisUpgraded = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,25 +34,31 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
protected boolean ignorePDFAErrors = false;
|
protected boolean ignorePDFAErrors = false;
|
||||||
protected ZUGFeRDConformanceLevel zugferdConformanceLevel = ZUGFeRDConformanceLevel.EXTENDED;
|
protected ZUGFeRDConformanceLevel zugferdConformanceLevel = ZUGFeRDConformanceLevel.EXTENDED;
|
||||||
protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE;
|
protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE;
|
||||||
/** Producer (attribute for PDF */
|
/**
|
||||||
|
* Producer (attribute for PDF
|
||||||
|
*/
|
||||||
protected String producer = "mustangproject";
|
protected String producer = "mustangproject";
|
||||||
/** Human creator (attribute for PDF) */
|
/**
|
||||||
|
* Human creator (attribute for PDF)
|
||||||
|
*/
|
||||||
protected String creator = "mustangproject";
|
protected String creator = "mustangproject";
|
||||||
/** Creator tool (attribute for PDF) */
|
/**
|
||||||
|
* Creator tool (attribute for PDF)
|
||||||
|
*/
|
||||||
protected String creatorTool = null;
|
protected String creatorTool = null;
|
||||||
|
|
||||||
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
|
private HashMap<String, byte[]> additionalXMLs = new HashMap<String, byte[]>();
|
||||||
|
|
||||||
|
|
||||||
protected int ZFVersion=ZUGFeRDExporter.DefaultZUGFeRDVersion;
|
protected int ZFVersion = ZUGFeRDExporter.DefaultZUGFeRDVersion;
|
||||||
protected boolean ensurePDFisUpgraded=false;
|
protected boolean ensurePDFisUpgraded = false;
|
||||||
private boolean attachZUGFeRDHeaders=true;
|
private boolean attachZUGFeRDHeaders = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||||
*
|
*
|
||||||
* @param pdfFilename
|
* @param pdfFilename filename of an PDF/A1 compliant document
|
||||||
* filename of an PDF/A1 compliant document
|
|
||||||
*/
|
*/
|
||||||
public ZUGFeRDExporter load(String pdfFilename) throws IOException {
|
public ZUGFeRDExporter load(String pdfFilename) throws IOException {
|
||||||
|
|
||||||
@@ -74,13 +80,11 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||||
*
|
*
|
||||||
* @param pdfBinary
|
* @param pdfBinary binary of a PDF/A1 compliant document
|
||||||
* binary of a PDF/A1 compliant document
|
|
||||||
*/
|
*/
|
||||||
public ZUGFeRDExporter load(byte[] pdfBinary) throws IOException {
|
public ZUGFeRDExporter load(byte[] pdfBinary) throws IOException {
|
||||||
ensurePDFIsValidPDFA(new ByteArrayDataSource(new ByteArrayInputStream(pdfBinary)));
|
ensurePDFIsValidPDFA(new ByteArrayDataSource(new ByteArrayInputStream(pdfBinary)));
|
||||||
@@ -97,17 +101,16 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
return zugFeRDExporter;
|
return zugFeRDExporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZUGFeRDExporterFromA3Factory () {
|
public ZUGFeRDExporterFromA3Factory() {
|
||||||
|
|
||||||
ensurePDFisUpgraded=false;
|
ensurePDFisUpgraded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
* Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the
|
||||||
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
* metadata level, this will not e.g. convert graphics to JPG-2000)
|
||||||
*
|
*
|
||||||
* @param pdfSource
|
* @param pdfSource source to read a PDF/A1 compliant document from
|
||||||
* source to read a PDF/A1 compliant document from
|
|
||||||
*/
|
*/
|
||||||
public ZUGFeRDExporter load(InputStream pdfSource) throws IOException {
|
public ZUGFeRDExporter load(InputStream pdfSource) throws IOException {
|
||||||
return load(readAllBytes(pdfSource));
|
return load(readAllBytes(pdfSource));
|
||||||
@@ -124,6 +127,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
IOUtils.copy(in, buffer);
|
IOUtils.copy(in, buffer);
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValidA1(DataSource dataSource) throws IOException {
|
private static boolean isValidA1(DataSource dataSource) throws IOException {
|
||||||
return getPDFAParserValidationResult(new PreflightParser(dataSource));
|
return getPDFAParserValidationResult(new PreflightParser(dataSource));
|
||||||
}
|
}
|
||||||
@@ -131,8 +135,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
/**
|
/**
|
||||||
* Sets the ZUGFeRD conformance level (override).
|
* Sets the ZUGFeRD conformance level (override).
|
||||||
*
|
*
|
||||||
* @param zugferdConformanceLevel
|
* @param zugferdConformanceLevel the new conformance level
|
||||||
* the new conformance level
|
|
||||||
*/
|
*/
|
||||||
public IExporterFactory setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel zugferdConformanceLevel) {
|
public IExporterFactory setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel zugferdConformanceLevel) {
|
||||||
this.zugferdConformanceLevel = zugferdConformanceLevel;
|
this.zugferdConformanceLevel = zugferdConformanceLevel;
|
||||||
@@ -170,17 +173,15 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* All files are PDF/A-3, setConformance refers to the level conformance.
|
* All files are PDF/A-3, setConformance refers to the level conformance.
|
||||||
*
|
* <p/>
|
||||||
* PDF/A-3 has three coformance levels, called "A", "U" and "B".
|
* PDF/A-3 has three coformance levels, called "A", "U" and "B".
|
||||||
*
|
* <p/>
|
||||||
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
* PDF/A-3-B where B means only visually preservable, U -standard for Mustang-
|
||||||
* means visually and unicode preservable and A means full compliance, i.e.
|
* means visually and unicode preservable and A means full compliance, i.e.
|
||||||
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
|
||||||
* metainformation for blind people.
|
* metainformation for blind people.
|
||||||
*
|
* <p/>
|
||||||
* Feel free to pass "A" as new level if you know what you are doing :-)
|
* Feel free to pass "A" as new level if you know what you are doing :-)
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public IExporterFactory setConformanceLevel(PDFAConformanceLevel newLevel) {
|
public IExporterFactory setConformanceLevel(PDFAConformanceLevel newLevel) {
|
||||||
conformanceLevel = newLevel;
|
conformanceLevel = newLevel;
|
||||||
@@ -207,6 +208,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
this.producer = producer;
|
this.producer = producer;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IExporterFactory setAttachZUGFeRDHeaders(boolean attachHeaders) {
|
public IExporterFactory setAttachZUGFeRDHeaders(boolean attachHeaders) {
|
||||||
this.attachZUGFeRDHeaders = attachHeaders;
|
this.attachZUGFeRDHeaders = attachHeaders;
|
||||||
return this;
|
return this;
|
||||||
@@ -215,7 +217,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IExporterFactory setZUGFeRDVersion(int version) {
|
public IExporterFactory setZUGFeRDVersion(int version) {
|
||||||
this.ZFVersion=version;
|
this.ZFVersion = version;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,19 +55,25 @@ public class ZUGFeRDImporter {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @var if metadata has been found */
|
/**
|
||||||
|
* @var if metadata has been found
|
||||||
|
*/
|
||||||
private boolean containsMeta = false;
|
private boolean containsMeta = false;
|
||||||
/** @var the reference (i.e. invoice number) of the sender */
|
/**
|
||||||
|
* @var the reference (i.e. invoice number) of the sender
|
||||||
|
*/
|
||||||
private String foreignReference;
|
private String foreignReference;
|
||||||
private String BLZ;
|
private String BLZ;
|
||||||
private String BIC;
|
private String BIC;
|
||||||
private String IBAN;
|
private String IBAN;
|
||||||
private String KTO;
|
private String KTO;
|
||||||
private String holder;
|
private String holder;
|
||||||
private String amount;
|
private String amount;
|
||||||
private String dueDate;
|
private String dueDate;
|
||||||
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
|
private HashMap<String, byte[]> additionalXMLs = new HashMap<String, byte[]>();
|
||||||
/** Raw XML form of the extracted data - may be directly obtained. */
|
/**
|
||||||
|
* Raw XML form of the extracted data - may be directly obtained.
|
||||||
|
*/
|
||||||
private byte[] rawXML = null;
|
private byte[] rawXML = null;
|
||||||
private String bankName;
|
private String bankName;
|
||||||
private boolean amountFound;
|
private boolean amountFound;
|
||||||
@@ -80,8 +86,7 @@ public class ZUGFeRDImporter {
|
|||||||
* Extracts a ZUGFeRD invoice from a PDF document represented by a file name.
|
* Extracts a ZUGFeRD invoice from a PDF document represented by a file name.
|
||||||
* Errors are just logged to STDOUT.
|
* Errors are just logged to STDOUT.
|
||||||
*
|
*
|
||||||
* @param pdfFilename
|
* @param pdfFilename the filename of the pdf
|
||||||
* the filename of the pdf
|
|
||||||
*/
|
*/
|
||||||
public void extract(String pdfFilename) {
|
public void extract(String pdfFilename) {
|
||||||
try {
|
try {
|
||||||
@@ -97,12 +102,13 @@ public class ZUGFeRDImporter {
|
|||||||
static String convertStreamToString(java.io.InputStream is) {
|
static String convertStreamToString(java.io.InputStream is) {
|
||||||
// source https://stackoverflow.com/questions/309424/how-do-i-read-convert-an-inputstream-into-a-string-in-java referring to
|
// source https://stackoverflow.com/questions/309424/how-do-i-read-convert-an-inputstream-into-a-string-in-java referring to
|
||||||
// https://community.oracle.com/blogs/pat/2004/10/23/stupid-scanner-tricks
|
// https://community.oracle.com/blogs/pat/2004/10/23/stupid-scanner-tricks
|
||||||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
|
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
|
||||||
return s.hasNext() ? s.next() : "";
|
return s.hasNext() ? s.next() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* get xmp metadata of the PDF, null if not available
|
* get xmp metadata of the PDF, null if not available
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public String getXMP() {
|
public String getXMP() {
|
||||||
@@ -113,8 +119,7 @@ public class ZUGFeRDImporter {
|
|||||||
* Extracts a ZUGFeRD invoice from a PDF document represented by an input
|
* Extracts a ZUGFeRD invoice from a PDF document represented by an input
|
||||||
* stream. Errors are reported via exception handling.
|
* stream. Errors are reported via exception handling.
|
||||||
*
|
*
|
||||||
* @param pdfStream
|
* @param pdfStream a inputstream of a pdf file
|
||||||
* a inputstream of a pdf file
|
|
||||||
*/
|
*/
|
||||||
public void extractLowLevel(InputStream pdfStream) throws IOException {
|
public void extractLowLevel(InputStream pdfStream) throws IOException {
|
||||||
PDEmbeddedFilesNameTreeNode etn;
|
PDEmbeddedFilesNameTreeNode etn;
|
||||||
@@ -123,9 +128,9 @@ public class ZUGFeRDImporter {
|
|||||||
// PDDocumentInformation info = doc.getDocumentInformation();
|
// PDDocumentInformation info = doc.getDocumentInformation();
|
||||||
PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
PDDocumentNameDictionary names = new PDDocumentNameDictionary(doc.getDocumentCatalog());
|
||||||
//start
|
//start
|
||||||
InputStream XMP=doc.getDocumentCatalog().getMetadata().exportXMPMetadata();
|
InputStream XMP = doc.getDocumentCatalog().getMetadata().exportXMPMetadata();
|
||||||
|
|
||||||
xmpString=convertStreamToString(XMP);
|
xmpString = convertStreamToString(XMP);
|
||||||
etn = names.getEmbeddedFiles();
|
etn = names.getEmbeddedFiles();
|
||||||
if (etn == null) {
|
if (etn == null) {
|
||||||
return;
|
return;
|
||||||
@@ -136,7 +141,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
if (efMap != null) {
|
if (efMap != null) {
|
||||||
extractFiles(efMap); // see
|
extractFiles(efMap); // see
|
||||||
// https://memorynotfound.com/apache-pdfbox-extract-embedded-file-pdf-document/
|
// https://memorynotfound.com/apache-pdfbox-extract-embedded-file-pdf-document/
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
List<PDNameTreeNode<PDComplexFileSpecification>> kids = etn.getKids();
|
List<PDNameTreeNode<PDComplexFileSpecification>> kids = etn.getKids();
|
||||||
@@ -204,7 +209,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
factory = DocumentBuilderFactory.newInstance();
|
factory = DocumentBuilderFactory.newInstance();
|
||||||
factory.setNamespaceAware(true); // otherwise we can not act namespace independently, i.e. use
|
factory.setNamespaceAware(true); // otherwise we can not act namespace independently, i.e. use
|
||||||
// document.getElementsByTagNameNS("*",...
|
// document.getElementsByTagNameNS("*",...
|
||||||
try {
|
try {
|
||||||
builder = factory.newDocumentBuilder();
|
builder = factory.newDocumentBuilder();
|
||||||
} catch (ParserConfigurationException ex3) {
|
} catch (ParserConfigurationException ex3) {
|
||||||
@@ -282,11 +287,11 @@ public class ZUGFeRDImporter {
|
|||||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
||||||
setIBAN(detail.getTextContent());
|
setIBAN(detail.getTextContent());
|
||||||
}
|
}
|
||||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("ProprietaryID"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("ProprietaryID"))) { //$NON-NLS-1$
|
||||||
setKTO(detail.getTextContent());
|
setKTO(detail.getTextContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ndList = document.getElementsByTagNameNS("*", "PayeeSpecifiedCreditorFinancialInstitution");// ZF1 //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*", "PayeeSpecifiedCreditorFinancialInstitution");// ZF1 //$NON-NLS-1$
|
||||||
@@ -300,9 +305,9 @@ public class ZUGFeRDImporter {
|
|||||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
||||||
setBIC(detail.getTextContent());
|
setBIC(detail.getTextContent());
|
||||||
}
|
}
|
||||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("GermanBankleitzahlID"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("GermanBankleitzahlID"))) { //$NON-NLS-1$
|
||||||
setBLZ(detail.getTextContent());
|
setBLZ(detail.getTextContent());
|
||||||
}
|
}
|
||||||
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||||
setBankName(detail.getTextContent());
|
setBankName(detail.getTextContent());
|
||||||
}
|
}
|
||||||
@@ -372,7 +377,6 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return if export found parseable ZUGFeRD data
|
* @return if export found parseable ZUGFeRD data
|
||||||
*/
|
*/
|
||||||
public boolean containsMeta() {
|
public boolean containsMeta() {
|
||||||
@@ -380,14 +384,13 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return the reference (purpose) the sender specified for this invoice
|
* @return the reference (purpose) the sender specified for this invoice
|
||||||
*/
|
*/
|
||||||
public String getForeignReference() {
|
public String getForeignReference() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (foreignReference==null) {
|
if (foreignReference == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return foreignReference;
|
return foreignReference;
|
||||||
@@ -397,33 +400,31 @@ public class ZUGFeRDImporter {
|
|||||||
this.foreignReference = foreignReference;
|
this.foreignReference = foreignReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the sender's bank's BLZ code
|
||||||
* @return the sender's bank's BLZ code
|
*/
|
||||||
*/
|
public String getBLZ() {
|
||||||
public String getBLZ() {
|
if (!parsed) {
|
||||||
if (!parsed) {
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
}
|
||||||
}
|
if (BLZ == null) {
|
||||||
if (BLZ==null) {
|
parse();
|
||||||
parse();
|
}
|
||||||
}
|
return BLZ;
|
||||||
return BLZ;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void setBLZ(String blz) {
|
private void setBLZ(String blz) {
|
||||||
this.BLZ = blz;
|
this.BLZ = blz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return the sender's bank's BIC code
|
* @return the sender's bank's BIC code
|
||||||
*/
|
*/
|
||||||
public String getBIC() {
|
public String getBIC() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (BIC==null) {
|
if (BIC == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return BIC;
|
return BIC;
|
||||||
@@ -442,42 +443,39 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return the sender's IBAN
|
* @return the sender's IBAN
|
||||||
*/
|
*/
|
||||||
public String getIBAN() {
|
public String getIBAN() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (IBAN==null) {
|
if (IBAN == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return IBAN;
|
return IBAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the sender's KTO
|
||||||
* @return the sender's KTO
|
*/
|
||||||
*/
|
public String getKTO() {
|
||||||
public String getKTO() {
|
if (!parsed) {
|
||||||
if (!parsed) {
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
}
|
||||||
}
|
if (KTO == null) {
|
||||||
if (KTO==null) {
|
parse();
|
||||||
parse();
|
}
|
||||||
}
|
return KTO;
|
||||||
return KTO;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return the sender's bank name
|
* @return the sender's bank name
|
||||||
*/
|
*/
|
||||||
public String getBankName() {
|
public String getBankName() {
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (bankName==null) {
|
if (bankName == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return bankName;
|
return bankName;
|
||||||
@@ -487,19 +485,18 @@ public class ZUGFeRDImporter {
|
|||||||
this.IBAN = IBAN;
|
this.IBAN = IBAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setKTO(String KTO) {
|
private void setKTO(String KTO) {
|
||||||
this.KTO = KTO;
|
this.KTO = KTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return the name of the owner of the sender's bank account
|
* @return the name of the owner of the sender's bank account
|
||||||
*/
|
*/
|
||||||
public String getHolder() {
|
public String getHolder() {
|
||||||
if (rawXML == null) {
|
if (rawXML == null) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (holder==null) {
|
if (holder == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return holder;
|
return holder;
|
||||||
@@ -510,28 +507,26 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return the total payable amount
|
* @return the total payable amount
|
||||||
*/
|
*/
|
||||||
public String getAmount() {
|
public String getAmount() {
|
||||||
if (rawXML == null) {
|
if (rawXML == null) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (amount==null) {
|
if (amount == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return when the payment is due
|
* @return when the payment is due
|
||||||
*/
|
*/
|
||||||
public String getDueDate() {
|
public String getDueDate() {
|
||||||
if (rawXML == null) {
|
if (rawXML == null) {
|
||||||
throw new RuntimeException("use extract() before requesting a value");
|
throw new RuntimeException("use extract() before requesting a value");
|
||||||
}
|
}
|
||||||
if (dueDate==null) {
|
if (dueDate == null) {
|
||||||
parse();
|
parse();
|
||||||
}
|
}
|
||||||
return dueDate;
|
return dueDate;
|
||||||
@@ -542,16 +537,13 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param meta raw XML to be set
|
||||||
* @param meta
|
|
||||||
* raw XML to be set
|
|
||||||
*/
|
*/
|
||||||
public void setMeta(String meta) {
|
public void setMeta(String meta) {
|
||||||
this.rawXML = meta.getBytes();
|
this.rawXML = meta.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return raw XML of the invoice
|
* @return raw XML of the invoice
|
||||||
*/
|
*/
|
||||||
public String getMeta() {
|
public String getMeta() {
|
||||||
@@ -564,35 +556,34 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return return UTF8 XML (without BOM) of the invoice
|
* @return return UTF8 XML (without BOM) of the invoice
|
||||||
*/
|
*/
|
||||||
public String getUTF8() {
|
public String getUTF8() {
|
||||||
if (rawXML == null) {
|
if (rawXML == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (rawXML.length<3) {
|
if (rawXML.length < 3) {
|
||||||
return new String(rawXML);
|
return new String(rawXML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
byte[] bomlessData;
|
byte[] bomlessData;
|
||||||
|
|
||||||
if ((rawXML[0] == (byte) 0xEF)
|
if ((rawXML[0] == (byte) 0xEF)
|
||||||
&& (rawXML[1] == (byte) 0xBB)
|
&& (rawXML[1] == (byte) 0xBB)
|
||||||
&& (rawXML[2] == (byte) 0xBF)) {
|
&& (rawXML[2] == (byte) 0xBF)) {
|
||||||
// I don't like BOMs, lets remove it
|
// I don't like BOMs, lets remove it
|
||||||
bomlessData = new byte[rawXML.length - 3];
|
bomlessData = new byte[rawXML.length - 3];
|
||||||
System.arraycopy(rawXML, 3, bomlessData, 0,
|
System.arraycopy(rawXML, 3, bomlessData, 0,
|
||||||
rawXML.length - 3);
|
rawXML.length - 3);
|
||||||
} else {
|
} else {
|
||||||
bomlessData = rawXML;
|
bomlessData = rawXML;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String(bomlessData);
|
return new String(bomlessData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
||||||
*/
|
*/
|
||||||
public byte[] getRawXML() {
|
public byte[] getRawXML() {
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class ZUGFeRDMigrator {
|
public class ZUGFeRDMigrator {
|
||||||
|
|
||||||
static final ClassLoader CLASS_LOADER = ZUGFeRDMigrator.class.getClassLoader();
|
static final ClassLoader CLASS_LOADER = ZUGFeRDMigrator.class.getClassLoader();
|
||||||
private static final String RESOURCE_PATH = ""; //$NON-NLS-1$
|
private static final String RESOURCE_PATH = ""; //$NON-NLS-1$
|
||||||
private static final Logger LOG = Logger.getLogger(ZUGFeRDMigrator.class.getName());
|
private static final Logger LOG = Logger.getLogger(ZUGFeRDMigrator.class.getName());
|
||||||
// private static File createTempFileResult(final Transformer transformer, final StreamSource toTransform,
|
// private static File createTempFileResult(final Transformer transformer, final StreamSource toTransform,
|
||||||
// final String suffix) throws TransformerException, IOException {
|
// final String suffix) throws TransformerException, IOException {
|
||||||
// File result = File.createTempFile("ZUV_", suffix); //$NON-NLS-1$
|
// File result = File.createTempFile("ZUV_", suffix); //$NON-NLS-1$
|
||||||
// result.deleteOnExit();
|
// result.deleteOnExit();
|
||||||
@@ -40,48 +40,48 @@ public class ZUGFeRDMigrator {
|
|||||||
// }
|
// }
|
||||||
// return result;
|
// return result;
|
||||||
// }
|
// }
|
||||||
private TransformerFactory mFactory = null;
|
private TransformerFactory mFactory = null;
|
||||||
private Templates mXsltTemplate = null;
|
private Templates mXsltTemplate = null;
|
||||||
|
|
||||||
public ZUGFeRDMigrator() {
|
public ZUGFeRDMigrator() {
|
||||||
mFactory = new net.sf.saxon.TransformerFactoryImpl();
|
mFactory = new net.sf.saxon.TransformerFactoryImpl();
|
||||||
//fact = TransformerFactory.newInstance();
|
//fact = TransformerFactory.newInstance();
|
||||||
mFactory.setURIResolver(new ClasspathResourceURIResolver());
|
mFactory.setURIResolver(new ClasspathResourceURIResolver());
|
||||||
try {
|
try {
|
||||||
mXsltTemplate = mFactory.newTemplates(new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "COMFORTtoEN16931.xsl")));
|
mXsltTemplate = mFactory.newTemplates(new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "COMFORTtoEN16931.xsl")));
|
||||||
} catch (TransformerConfigurationException ex) {
|
} catch (TransformerConfigurationException ex) {
|
||||||
LOG.log(Level.SEVERE, null, ex);
|
LOG.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String migrateFromV1ToV2(String xmlFilename) throws FileNotFoundException, TransformerException, UnsupportedEncodingException {
|
public String migrateFromV1ToV2(String xmlFilename) throws FileNotFoundException, TransformerException, UnsupportedEncodingException {
|
||||||
/**
|
/**
|
||||||
* *
|
* *
|
||||||
* http://www.unece.org/fileadmin/DAM/cefact/xml/XML-Naming-And-Design-Rules-V2_1.pdf
|
* http://www.unece.org/fileadmin/DAM/cefact/xml/XML-Naming-And-Design-Rules-V2_1.pdf
|
||||||
* http://www.ferd-net.de/upload/Dokumente/FACTUR-X_ZUGFeRD_2p0_Teil1_Profil_EN16931_1p03.pdf
|
* http://www.ferd-net.de/upload/Dokumente/FACTUR-X_ZUGFeRD_2p0_Teil1_Profil_EN16931_1p03.pdf
|
||||||
* http://countwordsfree.com/xmlviewer
|
* http://countwordsfree.com/xmlviewer
|
||||||
*/
|
*/
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
applySchematronXsl(new FileInputStream(xmlFilename), baos);
|
applySchematronXsl(new FileInputStream(xmlFilename), baos);
|
||||||
String res = null;
|
String res = null;
|
||||||
res = baos.toString("UTF-8");
|
res = baos.toString("UTF-8");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applySchematronXsl(final InputStream xmlFile,
|
public void applySchematronXsl(final InputStream xmlFile,
|
||||||
final OutputStream EN16931Outstream) throws TransformerException {
|
final OutputStream EN16931Outstream) throws TransformerException {
|
||||||
Transformer transformer = mXsltTemplate.newTransformer();
|
Transformer transformer = mXsltTemplate.newTransformer();
|
||||||
transformer.transform(new StreamSource(xmlFile), new StreamResult(EN16931Outstream));
|
transformer.transform(new StreamSource(xmlFile), new StreamResult(EN16931Outstream));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ClasspathResourceURIResolver implements URIResolver {
|
private static class ClasspathResourceURIResolver implements URIResolver {
|
||||||
ClasspathResourceURIResolver() {
|
ClasspathResourceURIResolver() {
|
||||||
// Do nothing, just prevents synthetic access warning.
|
// Do nothing, just prevents synthetic access warning.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Source resolve(String href, String base) throws TransformerException {
|
public Source resolve(String href, String base) throws TransformerException {
|
||||||
return new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + href));
|
return new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + href));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class DateTimeTypeConstants {
|
public class DateTimeTypeConstants {
|
||||||
public static final String DATE = "102";
|
public static final String DATE = "102";
|
||||||
public static final String MONTH = "610";
|
public static final String MONTH = "610";
|
||||||
public static final String WEEK = "616";
|
public static final String WEEK = "616";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class DocumentCodeTypeConstants {
|
public class DocumentCodeTypeConstants {
|
||||||
public static final String INVOICE = "380";
|
public static final String INVOICE = "380";
|
||||||
public static final String DEBITNOTE = "84";
|
public static final String DEBITNOTE = "84";
|
||||||
public static final String CREDITNOTE = "389";
|
public static final String CREDITNOTE = "389";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class NoteTypeConstants {
|
public class NoteTypeConstants {
|
||||||
public static final String GENERAL = "";
|
public static final String GENERAL = "";
|
||||||
public static final String REGULARINFO = "REG";
|
public static final String REGULARINFO = "REG";
|
||||||
public static final String PRICECONDITION = "AAK";
|
public static final String PRICECONDITION = "AAK";
|
||||||
public static final String CONDITIONS = "AAJ";
|
public static final String CONDITIONS = "AAJ";
|
||||||
public static final String PAYMENTINFO = "PMT";
|
public static final String PAYMENTINFO = "PMT";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,13 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class PaymentMeansCodeTypeConstants {
|
public class PaymentMeansCodeTypeConstants {
|
||||||
public static final String BANKACCOUNT = "42";
|
public static final String BANKACCOUNT = "42";
|
||||||
public static final String NOTSPECIFIED = "1";
|
public static final String NOTSPECIFIED = "1";
|
||||||
public static final String AUTOMATICCLEARING = "3";
|
public static final String AUTOMATICCLEARING = "3";
|
||||||
public static final String CASH = "10";
|
public static final String CASH = "10";
|
||||||
public static final String CHECK = "20";
|
public static final String CHECK = "20";
|
||||||
public static final String DEBITADVICE = "31";
|
public static final String DEBITADVICE = "31";
|
||||||
public static final String CREDITCARD = "48";
|
public static final String CREDITCARD = "48";
|
||||||
public static final String DEBIT = "49";
|
public static final String DEBIT = "49";
|
||||||
public static final String COMPENSATION = "97";
|
public static final String COMPENSATION = "97";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,25 +19,25 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class QuantityTypeConstants {
|
public class QuantityTypeConstants {
|
||||||
public static final String PIECE = "C62";
|
public static final String PIECE = "C62";
|
||||||
public static final String DAY = "DAY";
|
public static final String DAY = "DAY";
|
||||||
public static final String HECTARE = "HAR";
|
public static final String HECTARE = "HAR";
|
||||||
public static final String HOUR = "HUR";
|
public static final String HOUR = "HUR";
|
||||||
public static final String KILOGRAM = "KGM";
|
public static final String KILOGRAM = "KGM";
|
||||||
public static final String KILOMETER = "KTM";
|
public static final String KILOMETER = "KTM";
|
||||||
public static final String KILOWATTHOUR = "KWH";
|
public static final String KILOWATTHOUR = "KWH";
|
||||||
public static final String FIXEDRATE = "LS";
|
public static final String FIXEDRATE = "LS";
|
||||||
public static final String LITRE = "LTR";
|
public static final String LITRE = "LTR";
|
||||||
public static final String MINUTE = "MIN";
|
public static final String MINUTE = "MIN";
|
||||||
public static final String SQUAREMILLIMETER = "MMK";
|
public static final String SQUAREMILLIMETER = "MMK";
|
||||||
public static final String MILLIMETER = "MMT";
|
public static final String MILLIMETER = "MMT";
|
||||||
public static final String SQUAREMETER = "MTK";
|
public static final String SQUAREMETER = "MTK";
|
||||||
public static final String CUBICMETER = "MTQ";
|
public static final String CUBICMETER = "MTQ";
|
||||||
public static final String METER = "MTR";
|
public static final String METER = "MTR";
|
||||||
public static final String PRODUCTCOUNT = "NAR";
|
public static final String PRODUCTCOUNT = "NAR";
|
||||||
public static final String PRODUCTPAIR = "NPR";
|
public static final String PRODUCTPAIR = "NPR";
|
||||||
public static final String PERCENT = "P1";
|
public static final String PERCENT = "P1";
|
||||||
public static final String SET = "SET";
|
public static final String SET = "SET";
|
||||||
public static final String TON = "TNE";
|
public static final String TON = "TNE";
|
||||||
public static final String WEEK = "WEE";
|
public static final String WEEK = "WEE";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class TaxCategoryCodeTypeConstants {
|
public class TaxCategoryCodeTypeConstants {
|
||||||
public static final String STANDARDRATE = "S";
|
public static final String STANDARDRATE = "S";
|
||||||
public static final String REVERSECHARGE = "AE";
|
public static final String REVERSECHARGE = "AE";
|
||||||
public static final String TAXEXEMPT = "E";
|
public static final String TAXEXEMPT = "E";
|
||||||
public static final String ZEROTAXPRODUCTS = "Z";
|
public static final String ZEROTAXPRODUCTS = "Z";
|
||||||
public static final String UNTAXEDSERVICE = "O";
|
public static final String UNTAXEDSERVICE = "O";
|
||||||
public static final String INTRACOMMUNITY = "IC";
|
public static final String INTRACOMMUNITY = "IC";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,6 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class TaxRegistrationTypeConstants {
|
public class TaxRegistrationTypeConstants {
|
||||||
public static final String USTID = "VA";
|
public static final String USTID = "VA";
|
||||||
public static final String TAXID = "FC";
|
public static final String TAXID = "FC";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
package org.mustangproject.ZUGFeRD.model;
|
package org.mustangproject.ZUGFeRD.model;
|
||||||
|
|
||||||
public class TaxTypeCodeTypeConstants {
|
public class TaxTypeCodeTypeConstants {
|
||||||
public static final String SALESTAX = "VAT";
|
public static final String SALESTAX = "VAT";
|
||||||
public static final String INSURANCETAX = "ZF_INSURANCE_TAX";
|
public static final String INSURANCETAX = "ZF_INSURANCE_TAX";
|
||||||
public static final String OLDPART = "AAJ";
|
public static final String OLDPART = "AAJ";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,18 +23,18 @@ import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
|
|||||||
public class FileChecker {
|
public class FileChecker {
|
||||||
String filename;
|
String filename;
|
||||||
StatRun thisRun;
|
StatRun thisRun;
|
||||||
boolean isPDF=false;
|
boolean isPDF = false;
|
||||||
|
|
||||||
public FileChecker(String filename, StatRun statistics) {
|
public FileChecker(String filename, StatRun statistics) {
|
||||||
this.filename=filename;
|
this.filename = filename;
|
||||||
thisRun=statistics;
|
thisRun = statistics;
|
||||||
thisRun.incFileCount();
|
thisRun.incFileCount();
|
||||||
String extension = "";
|
String extension = "";
|
||||||
if (!thisRun.shallIgnoreFileExt()) {
|
if (!thisRun.shallIgnoreFileExt()) {
|
||||||
int extIndex = filename.lastIndexOf(".");
|
int extIndex = filename.lastIndexOf(".");
|
||||||
if (extIndex >= 0) {
|
if (extIndex >= 0) {
|
||||||
extension = filename.substring(extIndex).toLowerCase();
|
extension = filename.substring(extIndex).toLowerCase();
|
||||||
isPDF=extension.equals(".pdf");// alternative check for PDF: File starts with %PDF-
|
isPDF = extension.equals(".pdf");// alternative check for PDF: File starts with %PDF-
|
||||||
if (isPDF) {
|
if (isPDF) {
|
||||||
thisRun.incPDFCount();
|
thisRun.incPDFCount();
|
||||||
}
|
}
|
||||||
@@ -46,10 +46,10 @@ public class FileChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkForZUGFeRD() {
|
public boolean checkForZUGFeRD() {
|
||||||
if ((!isPDF)&&(!thisRun.shallIgnoreFileExt())) {
|
if ((!isPDF) && (!thisRun.shallIgnoreFileExt())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ZUGFeRDImporter zi=new ZUGFeRDImporter();
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
try {
|
try {
|
||||||
zi.extract(filename);
|
zi.extract(filename);
|
||||||
if (zi.canParse()) {
|
if (zi.canParse()) {
|
||||||
@@ -62,10 +62,10 @@ public class FileChecker {
|
|||||||
// something really rare happened -- corrupted ZF?
|
// something really rare happened -- corrupted ZF?
|
||||||
/***
|
/***
|
||||||
* e.g. Exception in thread "main" java.lang.NullPointerException
|
* e.g. Exception in thread "main" java.lang.NullPointerException
|
||||||
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extractLowLevel(ZUGFeRDImporter.java:90)
|
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extractLowLevel(ZUGFeRDImporter.java:90)
|
||||||
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extract(ZUGFeRDImporter.java:64)
|
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extract(ZUGFeRDImporter.java:64)
|
||||||
at toecount.FileChecker.checkForZUGFeRD(FileChecker.java:33)
|
at toecount.FileChecker.checkForZUGFeRD(FileChecker.java:33)
|
||||||
at toecount.Toecount.main(Toecount.java:111)
|
at toecount.Toecount.main(Toecount.java:111)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// Ignore nevertheless, most likely we're batch processing
|
// Ignore nevertheless, most likely we're batch processing
|
||||||
@@ -73,10 +73,10 @@ public class FileChecker {
|
|||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
/**
|
/**
|
||||||
* probably thrown up from
|
* probably thrown up from
|
||||||
AM org.apache.pdfbox.pdfparser.PDFParser parse, most likely
|
AM org.apache.pdfbox.pdfparser.PDFParser parse, most likely
|
||||||
INFORMATION: Document is encrypted
|
INFORMATION: Document is encrypted
|
||||||
but also other internal PDF errors possible like
|
but also other internal PDF errors possible like
|
||||||
..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref
|
..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref
|
||||||
*/
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,12 @@ public class FileTraverser extends SimpleFileVisitor<Path> {
|
|||||||
|
|
||||||
|
|
||||||
private StatRun thisRun;
|
private StatRun thisRun;
|
||||||
|
|
||||||
public FileTraverser(StatRun statistics) {
|
public FileTraverser(StatRun statistics) {
|
||||||
this.thisRun=statistics;
|
this.thisRun = statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* check each file
|
* check each file
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -51,7 +52,7 @@ public class FileTraverser extends SimpleFileVisitor<Path> {
|
|||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* for each directory
|
* for each directory
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -62,7 +63,7 @@ public class FileTraverser extends SimpleFileVisitor<Path> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* show errors like file permission stacktraces
|
* show errors like file permission stacktraces
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,60 +23,64 @@ public class StatRun {
|
|||||||
private int horseCount = 0;
|
private int horseCount = 0;
|
||||||
private int fileCount = 0;
|
private int fileCount = 0;
|
||||||
private int dirCount = 0;
|
private int dirCount = 0;
|
||||||
private boolean checkFileExt=true;
|
private boolean checkFileExt = true;
|
||||||
|
|
||||||
public void ignoreFileExtension() {
|
public void ignoreFileExtension() {
|
||||||
checkFileExt=false;
|
checkFileExt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shallIgnoreFileExt() {
|
public boolean shallIgnoreFileExt() {
|
||||||
return !checkFileExt;
|
return !checkFileExt;
|
||||||
}
|
}
|
||||||
public void incFileCount(){
|
|
||||||
|
public void incFileCount() {
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incPDFCount(){
|
public void incPDFCount() {
|
||||||
pdfCount++;
|
pdfCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incZUGFeRDCount(){
|
public void incZUGFeRDCount() {
|
||||||
horseCount++;
|
horseCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incDirCount(){
|
public void incDirCount() {
|
||||||
dirCount++;
|
dirCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFileCount(){
|
public int getFileCount() {
|
||||||
return fileCount;
|
return fileCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPDFCount(){
|
public int getPDFCount() {
|
||||||
return pdfCount;
|
return pdfCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getZUGFeRDCount(){
|
public int getZUGFeRDCount() {
|
||||||
return horseCount;
|
return horseCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDirCount(){
|
public int getDirCount() {
|
||||||
return dirCount;
|
return dirCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* returns final statistics
|
* returns final statistics
|
||||||
|
*
|
||||||
* @return english string with linefeeds detailling number of files, directories, number of pdfs and of zugferd files
|
* @return english string with linefeeds detailling number of files, directories, number of pdfs and of zugferd files
|
||||||
*/
|
*/
|
||||||
public String getSummaryLine() {
|
public String getSummaryLine() {
|
||||||
|
|
||||||
return "\r\n===================================================================\r\n"+String.format(
|
return "\r\n===================================================================\r\n" + String.format(
|
||||||
"Files:\t%d\tDirs:\t%d\tPDF:\t%d\tZUGFeRD:\t%d\r\n",
|
"Files:\t%d\tDirs:\t%d\tPDF:\t%d\tZUGFeRD:\t%d\r\n",
|
||||||
getFileCount(), getDirCount(), getPDFCount(), getZUGFeRDCount());
|
getFileCount(), getDirCount(), getPDFCount(), getZUGFeRDCount());
|
||||||
|
|
||||||
}
|
}
|
||||||
/***
|
|
||||||
|
/**
|
||||||
* show that something is happening
|
* show that something is happening
|
||||||
|
*
|
||||||
* @return String, usually a dot
|
* @return String, usually a dot
|
||||||
*/
|
*/
|
||||||
public String getOutputLine() {
|
public String getOutputLine() {
|
||||||
|
|||||||
@@ -108,19 +108,15 @@ public class Toecount {
|
|||||||
+ "\t\t\tFor ZUGFeRD v2: <M>INIMUM, BASIC <W>L, <B>ASIC, <C>IUS, <E>N16931, E<X>TENDED\r\n");
|
+ "\t\t\tFor ZUGFeRD v2: <M>INIMUM, BASIC <W>L, <B>ASIC, <C>IUS, <E>N16931, E<X>TENDED\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* Asks the user (repeatedly, if neccessary) on the command line for a String
|
* Asks the user (repeatedly, if neccessary) on the command line for a String
|
||||||
* (offering a defaultValue) conforming to a Regex pattern
|
* (offering a defaultValue) conforming to a Regex pattern
|
||||||
*
|
*
|
||||||
* @param prompt
|
* @param prompt the question to be asked to the user
|
||||||
* the question to be asked to the user
|
* @param defaultValue the default return value if user hits enter
|
||||||
* @param defaultValue
|
* @param pattern a regex of acceptable values
|
||||||
* the default return value if user hits enter
|
|
||||||
* @param pattern
|
|
||||||
* a regex of acceptable values
|
|
||||||
* @return the user answer conforming to pattern
|
* @return the user answer conforming to pattern
|
||||||
* @throws Exception
|
* @throws Exception if pattern not compielable or IOexception on input
|
||||||
* if pattern not compielable or IOexception on input
|
|
||||||
*/
|
*/
|
||||||
protected static String getStringFromUser(String prompt, String defaultValue, String pattern) throws Exception {
|
protected static String getStringFromUser(String prompt, String defaultValue, String pattern) throws Exception {
|
||||||
String input = "";
|
String input = "";
|
||||||
@@ -156,24 +152,18 @@ public class Toecount {
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/**
|
||||||
* Prompts the user for a input or output filename
|
* Prompts the user for a input or output filename
|
||||||
*
|
*
|
||||||
* @param the
|
* @param the text the user is asked
|
||||||
* text the user is asked
|
* @param a default Filename
|
||||||
* @param a
|
* @param expectedExtension will warn if filename does not match expected file extension
|
||||||
* default Filename
|
* @param ensureFileExists will warn if file does NOT exist (for input files)
|
||||||
* @param expectedExtension
|
* @param ensureFileNotExists will warn if file DOES exist (for output files)
|
||||||
* will warn if filename does not match expected file extension
|
|
||||||
* @param ensureFileExists
|
|
||||||
* will warn if file does NOT exist (for input files)
|
|
||||||
* @param ensureFileNotExists
|
|
||||||
* will warn if file DOES exist (for output files)
|
|
||||||
*
|
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
protected static String getFilenameFromUser(String prompt, String defaultFilename, String expectedExtension,
|
protected static String getFilenameFromUser(String prompt, String defaultFilename, String expectedExtension,
|
||||||
boolean ensureFileExists, boolean ensureFileNotExists) {
|
boolean ensureFileExists, boolean ensureFileNotExists) {
|
||||||
boolean fileExistenceOK = false;
|
boolean fileExistenceOK = false;
|
||||||
String selectedName = "";
|
String selectedName = "";
|
||||||
do {
|
do {
|
||||||
@@ -316,9 +306,7 @@ public class Toecount {
|
|||||||
|
|
||||||
if (helpRequested) {
|
if (helpRequested) {
|
||||||
printHelp();
|
printHelp();
|
||||||
}
|
} else if (((directoryName != null) && (directoryName.length() > 0)) || filesFromStdIn.booleanValue()) {
|
||||||
|
|
||||||
else if (((directoryName != null) && (directoryName.length() > 0)) || filesFromStdIn.booleanValue()) {
|
|
||||||
performMetrics(directoryName, filesFromStdIn, ignoreFileExt);
|
performMetrics(directoryName, filesFromStdIn, ignoreFileExt);
|
||||||
} else if (combineRequested) {
|
} else if (combineRequested) {
|
||||||
performCombine(sourceName, sourceXMLName, outName, zugferdVersion, zugferdProfile);
|
performCombine(sourceName, sourceXMLName, outName, zugferdVersion, zugferdProfile);
|
||||||
@@ -431,7 +419,7 @@ public class Toecount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void performCombine(String pdfName, String xmlName, String outName, String zfVersion,
|
private static void performCombine(String pdfName, String xmlName, String outName, String zfVersion,
|
||||||
String zfProfile) throws Exception {
|
String zfProfile) throws Exception {
|
||||||
/*
|
/*
|
||||||
* ZUGFeRDExporter ze= new ZUGFeRDExporterFromA1Factory()
|
* ZUGFeRDExporter ze= new ZUGFeRDExporterFromA1Factory()
|
||||||
* .setProducer("toecount") .setCreator(System.getProperty("user.name"))
|
* .setProducer("toecount") .setCreator(System.getProperty("user.name"))
|
||||||
|
|||||||
@@ -21,37 +21,37 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
public class IZUGFeRDAllowanceChargeImpl implements IZUGFeRDAllowanceCharge {
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
private String reason;
|
private String reason;
|
||||||
private BigDecimal taxPercent;
|
private BigDecimal taxPercent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getTotalAmount() {
|
public BigDecimal getTotalAmount() {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getReason() {
|
public String getReason() {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getTaxPercent() {
|
public BigDecimal getTaxPercent() {
|
||||||
return taxPercent;
|
return taxPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDAllowanceChargeImpl setTotalAmount(BigDecimal totalAmount) {
|
public IZUGFeRDAllowanceChargeImpl setTotalAmount(BigDecimal totalAmount) {
|
||||||
this.totalAmount = totalAmount;
|
this.totalAmount = totalAmount;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDAllowanceChargeImpl setReason(String reason) {
|
public IZUGFeRDAllowanceChargeImpl setReason(String reason) {
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDAllowanceChargeImpl setTaxPercent(BigDecimal taxPercent) {
|
public IZUGFeRDAllowanceChargeImpl setTaxPercent(BigDecimal taxPercent) {
|
||||||
this.taxPercent = taxPercent;
|
this.taxPercent = taxPercent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,70 +19,70 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
public class IZUGFeRDExportableContactImpl implements IZUGFeRDExportableContact {
|
public class IZUGFeRDExportableContactImpl implements IZUGFeRDExportableContact {
|
||||||
private String name;
|
private String name;
|
||||||
private String zIP;
|
private String zIP;
|
||||||
private String vATID;
|
private String vATID;
|
||||||
private String country;
|
private String country;
|
||||||
private String location;
|
private String location;
|
||||||
private String street;
|
private String street;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getZIP() {
|
public String getZIP() {
|
||||||
return zIP;
|
return zIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getVATID() {
|
public String getVATID() {
|
||||||
return vATID;
|
return vATID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCountry() {
|
public String getCountry() {
|
||||||
return country;
|
return country;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStreet() {
|
public String getStreet() {
|
||||||
return street;
|
return street;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableContactImpl setName(String name) {
|
public IZUGFeRDExportableContactImpl setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableContactImpl setZIP(String zIP) {
|
public IZUGFeRDExportableContactImpl setZIP(String zIP) {
|
||||||
this.zIP = zIP;
|
this.zIP = zIP;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableContactImpl setVATID(String vATID) {
|
public IZUGFeRDExportableContactImpl setVATID(String vATID) {
|
||||||
this.vATID = vATID;
|
this.vATID = vATID;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableContactImpl setCountry(String country) {
|
public IZUGFeRDExportableContactImpl setCountry(String country) {
|
||||||
this.country = country;
|
this.country = country;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableContactImpl setLocation(String location) {
|
public IZUGFeRDExportableContactImpl setLocation(String location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableContactImpl setStreet(String street) {
|
public IZUGFeRDExportableContactImpl setStreet(String street) {
|
||||||
this.street = street;
|
this.street = street;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,59 +21,59 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class IZUGFeRDExportableItemImpl implements IZUGFeRDExportableItem {
|
public class IZUGFeRDExportableItemImpl implements IZUGFeRDExportableItem {
|
||||||
private IZUGFeRDExportableProduct product;
|
private IZUGFeRDExportableProduct product;
|
||||||
private IZUGFeRDAllowanceCharge[] itemAllowances;
|
private IZUGFeRDAllowanceCharge[] itemAllowances;
|
||||||
private IZUGFeRDAllowanceCharge[] itemCharges;
|
private IZUGFeRDAllowanceCharge[] itemCharges;
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
private BigDecimal quantity;
|
private BigDecimal quantity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDExportableProduct getProduct() {
|
public IZUGFeRDExportableProduct getProduct() {
|
||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDAllowanceCharge[] getItemAllowances() {
|
public IZUGFeRDAllowanceCharge[] getItemAllowances() {
|
||||||
return itemAllowances;
|
return itemAllowances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDAllowanceCharge[] getItemCharges() {
|
public IZUGFeRDAllowanceCharge[] getItemCharges() {
|
||||||
return itemCharges;
|
return itemCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getPrice() {
|
public BigDecimal getPrice() {
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getQuantity() {
|
public BigDecimal getQuantity() {
|
||||||
return quantity;
|
return quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableItemImpl setProduct(IZUGFeRDExportableProduct product) {
|
public IZUGFeRDExportableItemImpl setProduct(IZUGFeRDExportableProduct product) {
|
||||||
this.product = product;
|
this.product = product;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableItemImpl setItemAllowances(IZUGFeRDAllowanceCharge[] itemAllowances) {
|
public IZUGFeRDExportableItemImpl setItemAllowances(IZUGFeRDAllowanceCharge[] itemAllowances) {
|
||||||
this.itemAllowances = itemAllowances;
|
this.itemAllowances = itemAllowances;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableItemImpl setItemCharges(IZUGFeRDAllowanceCharge[] itemCharges) {
|
public IZUGFeRDExportableItemImpl setItemCharges(IZUGFeRDAllowanceCharge[] itemCharges) {
|
||||||
this.itemCharges = itemCharges;
|
this.itemCharges = itemCharges;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableItemImpl setPrice(BigDecimal price) {
|
public IZUGFeRDExportableItemImpl setPrice(BigDecimal price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableItemImpl setQuantity(BigDecimal quantity) {
|
public IZUGFeRDExportableItemImpl setQuantity(BigDecimal quantity) {
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,48 +21,48 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class IZUGFeRDExportableProductImpl implements IZUGFeRDExportableProduct {
|
public class IZUGFeRDExportableProductImpl implements IZUGFeRDExportableProduct {
|
||||||
private String unit;
|
private String unit;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private BigDecimal vatPercent;
|
private BigDecimal vatPercent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUnit() {
|
public String getUnit() {
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal getVATPercent() {
|
public BigDecimal getVATPercent() {
|
||||||
return vatPercent;
|
return vatPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableProductImpl setUnit(String unit) {
|
public IZUGFeRDExportableProductImpl setUnit(String unit) {
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableProductImpl setName(String name) {
|
public IZUGFeRDExportableProductImpl setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableProductImpl setDescription(String description) {
|
public IZUGFeRDExportableProductImpl setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableProductImpl setVatPercent(BigDecimal vatPercent) {
|
public IZUGFeRDExportableProductImpl setVatPercent(BigDecimal vatPercent) {
|
||||||
this.vatPercent = vatPercent;
|
this.vatPercent = vatPercent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,290 +21,290 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class IZUGFeRDExportableTransactionImpl implements IZUGFeRDExportableTransaction {
|
public class IZUGFeRDExportableTransactionImpl implements IZUGFeRDExportableTransaction {
|
||||||
private String number;
|
private String number;
|
||||||
private Date issueDate;
|
private Date issueDate;
|
||||||
private String ownOrganisationFullPlaintextInfo;
|
private String ownOrganisationFullPlaintextInfo;
|
||||||
private Date dueDate;
|
private Date dueDate;
|
||||||
private IZUGFeRDAllowanceCharge[] zFAllowances;
|
private IZUGFeRDAllowanceCharge[] zFAllowances;
|
||||||
private IZUGFeRDAllowanceCharge[] zFCharges;
|
private IZUGFeRDAllowanceCharge[] zFCharges;
|
||||||
private IZUGFeRDAllowanceCharge[] zFLogisticsServiceCharges;
|
private IZUGFeRDAllowanceCharge[] zFLogisticsServiceCharges;
|
||||||
private IZUGFeRDExportableItem[] zFItems;
|
private IZUGFeRDExportableItem[] zFItems;
|
||||||
private IZUGFeRDExportableContact recipient;
|
private IZUGFeRDExportableContact recipient;
|
||||||
private String ownKto;
|
private String ownKto;
|
||||||
private String ownBLZ;
|
private String ownBLZ;
|
||||||
private String ownBIC;
|
private String ownBIC;
|
||||||
private String ownBankName;
|
private String ownBankName;
|
||||||
private String ownIBAN;
|
private String ownIBAN;
|
||||||
private String ownTaxID;
|
private String ownTaxID;
|
||||||
private String ownVATID;
|
private String ownVATID;
|
||||||
private String ownOrganisationName;
|
private String ownOrganisationName;
|
||||||
private String ownStreet;
|
private String ownStreet;
|
||||||
private String ownZIP;
|
private String ownZIP;
|
||||||
private String ownLocation;
|
private String ownLocation;
|
||||||
private String ownCountry;
|
private String ownCountry;
|
||||||
private Date deliveryDate;
|
private Date deliveryDate;
|
||||||
private String currency;
|
private String currency;
|
||||||
private String ownPaymentInfoText;
|
private String ownPaymentInfoText;
|
||||||
private String paymentTermDescription;
|
private String paymentTermDescription;
|
||||||
private String referenceNumber;
|
private String referenceNumber;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNumber() {
|
public String getNumber() {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getIssueDate() {
|
public Date getIssueDate() {
|
||||||
return issueDate;
|
return issueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnOrganisationFullPlaintextInfo() {
|
public String getOwnOrganisationFullPlaintextInfo() {
|
||||||
return ownOrganisationFullPlaintextInfo;
|
return ownOrganisationFullPlaintextInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getDueDate() {
|
public Date getDueDate() {
|
||||||
return dueDate;
|
return dueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
||||||
return zFAllowances;
|
return zFAllowances;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDAllowanceCharge[] getZFCharges() {
|
public IZUGFeRDAllowanceCharge[] getZFCharges() {
|
||||||
return zFCharges;
|
return zFCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
||||||
return zFLogisticsServiceCharges;
|
return zFLogisticsServiceCharges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDExportableItem[] getZFItems() {
|
public IZUGFeRDExportableItem[] getZFItems() {
|
||||||
return zFItems;
|
return zFItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDExportableContact getRecipient() {
|
public IZUGFeRDExportableContact getRecipient() {
|
||||||
return recipient;
|
return recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnKto() {
|
public String getOwnKto() {
|
||||||
return ownKto;
|
return ownKto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBLZ() {
|
public String getOwnBLZ() {
|
||||||
return ownBLZ;
|
return ownBLZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBIC() {
|
public String getOwnBIC() {
|
||||||
return ownBIC;
|
return ownBIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBankName() {
|
public String getOwnBankName() {
|
||||||
return ownBankName;
|
return ownBankName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnIBAN() {
|
public String getOwnIBAN() {
|
||||||
return ownIBAN;
|
return ownIBAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnTaxID() {
|
public String getOwnTaxID() {
|
||||||
return ownTaxID;
|
return ownTaxID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnVATID() {
|
public String getOwnVATID() {
|
||||||
return ownVATID;
|
return ownVATID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnOrganisationName() {
|
public String getOwnOrganisationName() {
|
||||||
return ownOrganisationName;
|
return ownOrganisationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnStreet() {
|
public String getOwnStreet() {
|
||||||
return ownStreet;
|
return ownStreet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnZIP() {
|
public String getOwnZIP() {
|
||||||
return ownZIP;
|
return ownZIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnLocation() {
|
public String getOwnLocation() {
|
||||||
return ownLocation;
|
return ownLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnCountry() {
|
public String getOwnCountry() {
|
||||||
return ownCountry;
|
return ownCountry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getDeliveryDate() {
|
public Date getDeliveryDate() {
|
||||||
return deliveryDate;
|
return deliveryDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrency() {
|
public String getCurrency() {
|
||||||
return currency;
|
return currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnPaymentInfoText() {
|
public String getOwnPaymentInfoText() {
|
||||||
return ownPaymentInfoText;
|
return ownPaymentInfoText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPaymentTermDescription() {
|
public String getPaymentTermDescription() {
|
||||||
return paymentTermDescription;
|
return paymentTermDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getReferenceNumber() {
|
public String getReferenceNumber() {
|
||||||
return referenceNumber;
|
return referenceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setNumber(String number) {
|
public IZUGFeRDExportableTransactionImpl setNumber(String number) {
|
||||||
this.number = number;
|
this.number = number;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setIssueDate(Date issueDate) {
|
public IZUGFeRDExportableTransactionImpl setIssueDate(Date issueDate) {
|
||||||
this.issueDate = issueDate;
|
this.issueDate = issueDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnOrganisationFullPlaintextInfo(String ownOrganisationFullPlaintextInfo) {
|
public IZUGFeRDExportableTransactionImpl setOwnOrganisationFullPlaintextInfo(String ownOrganisationFullPlaintextInfo) {
|
||||||
this.ownOrganisationFullPlaintextInfo = ownOrganisationFullPlaintextInfo;
|
this.ownOrganisationFullPlaintextInfo = ownOrganisationFullPlaintextInfo;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setDueDate(Date dueDate) {
|
public IZUGFeRDExportableTransactionImpl setDueDate(Date dueDate) {
|
||||||
this.dueDate = dueDate;
|
this.dueDate = dueDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setZFAllowances(IZUGFeRDAllowanceCharge... zFAllowances) {
|
public IZUGFeRDExportableTransactionImpl setZFAllowances(IZUGFeRDAllowanceCharge... zFAllowances) {
|
||||||
this.zFAllowances = zFAllowances;
|
this.zFAllowances = zFAllowances;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setZFCharges(IZUGFeRDAllowanceCharge... zFCharges) {
|
public IZUGFeRDExportableTransactionImpl setZFCharges(IZUGFeRDAllowanceCharge... zFCharges) {
|
||||||
this.zFCharges = zFCharges;
|
this.zFCharges = zFCharges;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setZFLogisticsServiceCharges(IZUGFeRDAllowanceCharge... zFLogisticsServiceCharges) {
|
public IZUGFeRDExportableTransactionImpl setZFLogisticsServiceCharges(IZUGFeRDAllowanceCharge... zFLogisticsServiceCharges) {
|
||||||
this.zFLogisticsServiceCharges = zFLogisticsServiceCharges;
|
this.zFLogisticsServiceCharges = zFLogisticsServiceCharges;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setZFItems(IZUGFeRDExportableItem... zFItems) {
|
public IZUGFeRDExportableTransactionImpl setZFItems(IZUGFeRDExportableItem... zFItems) {
|
||||||
this.zFItems = zFItems;
|
this.zFItems = zFItems;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setRecipient(IZUGFeRDExportableContact recipient) {
|
public IZUGFeRDExportableTransactionImpl setRecipient(IZUGFeRDExportableContact recipient) {
|
||||||
this.recipient = recipient;
|
this.recipient = recipient;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnBLZ(String ownBLZ) {
|
public IZUGFeRDExportableTransactionImpl setOwnBLZ(String ownBLZ) {
|
||||||
this.ownBLZ = ownBLZ;
|
this.ownBLZ = ownBLZ;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnBIC(String ownBIC) {
|
public IZUGFeRDExportableTransactionImpl setOwnBIC(String ownBIC) {
|
||||||
this.ownBIC = ownBIC;
|
this.ownBIC = ownBIC;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnBankName(String ownBankName) {
|
public IZUGFeRDExportableTransactionImpl setOwnBankName(String ownBankName) {
|
||||||
this.ownBankName = ownBankName;
|
this.ownBankName = ownBankName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnKto(String ownKto) {
|
public IZUGFeRDExportableTransactionImpl setOwnKto(String ownKto) {
|
||||||
this.ownKto = ownKto;
|
this.ownKto = ownKto;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnIBAN(String ownIBAN) {
|
public IZUGFeRDExportableTransactionImpl setOwnIBAN(String ownIBAN) {
|
||||||
this.ownIBAN = ownIBAN;
|
this.ownIBAN = ownIBAN;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnTaxID(String ownTaxID) {
|
public IZUGFeRDExportableTransactionImpl setOwnTaxID(String ownTaxID) {
|
||||||
this.ownTaxID = ownTaxID;
|
this.ownTaxID = ownTaxID;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnVATID(String ownVATID) {
|
public IZUGFeRDExportableTransactionImpl setOwnVATID(String ownVATID) {
|
||||||
this.ownVATID = ownVATID;
|
this.ownVATID = ownVATID;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnOrganisationName(String ownOrganisationName) {
|
public IZUGFeRDExportableTransactionImpl setOwnOrganisationName(String ownOrganisationName) {
|
||||||
this.ownOrganisationName = ownOrganisationName;
|
this.ownOrganisationName = ownOrganisationName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnStreet(String ownStreet) {
|
public IZUGFeRDExportableTransactionImpl setOwnStreet(String ownStreet) {
|
||||||
this.ownStreet = ownStreet;
|
this.ownStreet = ownStreet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnZIP(String ownZIP) {
|
public IZUGFeRDExportableTransactionImpl setOwnZIP(String ownZIP) {
|
||||||
this.ownZIP = ownZIP;
|
this.ownZIP = ownZIP;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnLocation(String ownLocation) {
|
public IZUGFeRDExportableTransactionImpl setOwnLocation(String ownLocation) {
|
||||||
this.ownLocation = ownLocation;
|
this.ownLocation = ownLocation;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnCountry(String ownCountry) {
|
public IZUGFeRDExportableTransactionImpl setOwnCountry(String ownCountry) {
|
||||||
this.ownCountry = ownCountry;
|
this.ownCountry = ownCountry;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setDeliveryDate(Date deliveryDate) {
|
public IZUGFeRDExportableTransactionImpl setDeliveryDate(Date deliveryDate) {
|
||||||
this.deliveryDate = deliveryDate;
|
this.deliveryDate = deliveryDate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setCurrency(String currency) {
|
public IZUGFeRDExportableTransactionImpl setCurrency(String currency) {
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setOwnPaymentInfoText(String ownPaymentInfoText) {
|
public IZUGFeRDExportableTransactionImpl setOwnPaymentInfoText(String ownPaymentInfoText) {
|
||||||
this.ownPaymentInfoText = ownPaymentInfoText;
|
this.ownPaymentInfoText = ownPaymentInfoText;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setPaymentTermDescription(String paymentTermDescription) {
|
public IZUGFeRDExportableTransactionImpl setPaymentTermDescription(String paymentTermDescription) {
|
||||||
this.paymentTermDescription = paymentTermDescription;
|
this.paymentTermDescription = paymentTermDescription;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IZUGFeRDExportableTransactionImpl setReferenceNumber(String referenceNumber) {
|
public IZUGFeRDExportableTransactionImpl setReferenceNumber(String referenceNumber) {
|
||||||
this.referenceNumber = referenceNumber;
|
this.referenceNumber = referenceNumber;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
/**
|
/**
|
||||||
* Create the test case
|
* Create the test case
|
||||||
*
|
*
|
||||||
* @param testName
|
* @param testName name of the test case
|
||||||
* name of the test case
|
|
||||||
*/
|
*/
|
||||||
public MustangReaderWriterCustomXMLTest(String testName) {
|
public MustangReaderWriterCustomXMLTest(String testName) {
|
||||||
super(testName);
|
super(testName);
|
||||||
@@ -50,7 +49,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
|
|
||||||
// //////// TESTS
|
// //////// TESTS
|
||||||
// //////////////////////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
public void testCustomZF2Export() throws Exception {
|
public void testCustomZF2Export() throws Exception {
|
||||||
|
|
||||||
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20171118_506custom.pdf";
|
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20171118_506custom.pdf";
|
||||||
// the writing part
|
// the writing part
|
||||||
@@ -62,10 +61,10 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931)
|
ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931)
|
||||||
.load(SOURCE_PDF);
|
.load(SOURCE_PDF);
|
||||||
|
|
||||||
final byte[] UTF8ByteOrderMark = new byte[] { (byte)0xef, (byte)0xbb,
|
final byte[] UTF8ByteOrderMark = new byte[]{(byte) 0xef, (byte) 0xbb,
|
||||||
(byte)0xbf };
|
(byte) 0xbf};
|
||||||
/* we have much more information than just in the basic profile (comfort or extended) but it's perfectly valid to provide more information, just not less. */
|
/* we have much more information than just in the basic profile (comfort or extended) but it's perfectly valid to provide more information, just not less. */
|
||||||
String ownZUGFeRDXML = new String(UTF8ByteOrderMark)+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
String ownZUGFeRDXML = new String(UTF8ByteOrderMark) + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||||
"<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" +
|
"<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" +
|
||||||
" <rsm:ExchangedDocumentContext>\n" +
|
" <rsm:ExchangedDocumentContext>\n" +
|
||||||
" <ram:TestIndicator><udt:Indicator>false</udt:Indicator></ram:TestIndicator>\n" +
|
" <ram:TestIndicator><udt:Indicator>false</udt:Indicator></ram:TestIndicator>\n" +
|
||||||
@@ -222,7 +221,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
" </ram:PayeePartyCreditorFinancialAccount>\n" +
|
" </ram:PayeePartyCreditorFinancialAccount>\n" +
|
||||||
" <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" +
|
" <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" +
|
||||||
" <ram:BICID>COBADEFFXXX</ram:BICID>\n" +
|
" <ram:BICID>COBADEFFXXX</ram:BICID>\n" +
|
||||||
" <ram:GermanBankleitzahlID>41441604</ram:GermanBankleitzahlID>\n" +
|
" <ram:GermanBankleitzahlID>41441604</ram:GermanBankleitzahlID>\n" +
|
||||||
" <ram:Name>Commerzbank</ram:Name>\n" +
|
" <ram:Name>Commerzbank</ram:Name>\n" +
|
||||||
" </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" +
|
" </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" +
|
||||||
" </ram:SpecifiedTradeSettlementPaymentMeans>\n" +
|
" </ram:SpecifiedTradeSettlementPaymentMeans>\n" +
|
||||||
@@ -256,15 +255,15 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
" </ram:ApplicableHeaderTradeSettlement>\n" +
|
" </ram:ApplicableHeaderTradeSettlement>\n" +
|
||||||
" </rsm:SupplyChainTradeTransaction>\n" +
|
" </rsm:SupplyChainTradeTransaction>\n" +
|
||||||
"</rsm:CrossIndustryInvoice>";
|
"</rsm:CrossIndustryInvoice>";
|
||||||
zea1.setZUGFeRDXMLData(ownZUGFeRDXML.getBytes("UTF-8"));
|
zea1.setZUGFeRDXMLData(ownZUGFeRDXML.getBytes("UTF-8"));
|
||||||
|
|
||||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
zea1.disableAutoClose(true);
|
zea1.disableAutoClose(true);
|
||||||
zea1.export(TARGET_PDF);
|
zea1.export(TARGET_PDF);
|
||||||
zea1.export(baos);
|
zea1.export(baos);
|
||||||
zea1.close();
|
zea1.close();
|
||||||
String pdfContent=baos.toString("UTF-8");
|
String pdfContent = baos.toString("UTF-8");
|
||||||
assertFalse(pdfContent.indexOf("(via mustangproject.org")==-1);
|
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
|
||||||
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);
|
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -279,31 +278,32 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
|
|
||||||
String amount = null;
|
String amount = null;
|
||||||
String bic = null;
|
String bic = null;
|
||||||
String blz = null;
|
String blz = null;
|
||||||
String iban = null;
|
String iban = null;
|
||||||
String kto = null;
|
String kto = null;
|
||||||
String holder = null;
|
String holder = null;
|
||||||
String ref = null;
|
String ref = null;
|
||||||
|
|
||||||
if (zi.canParse()) {
|
if (zi.canParse()) {
|
||||||
zi.parse();
|
zi.parse();
|
||||||
amount = zi.getAmount();
|
amount = zi.getAmount();
|
||||||
blz = zi.getBLZ();
|
blz = zi.getBLZ();
|
||||||
bic = zi.getBIC();
|
bic = zi.getBIC();
|
||||||
iban = zi.getIBAN();
|
iban = zi.getIBAN();
|
||||||
kto = zi.getKTO();
|
kto = zi.getKTO();
|
||||||
holder = zi.getHolder();
|
holder = zi.getHolder();
|
||||||
ref = zi.getForeignReference();
|
ref = zi.getForeignReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(amount, "571.04");
|
assertEquals(amount, "571.04");
|
||||||
assertEquals(blz, "41441604");
|
assertEquals(blz, "41441604");
|
||||||
assertEquals(bic, "COBADEFFXXX");
|
assertEquals(bic, "COBADEFFXXX");
|
||||||
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
||||||
assertEquals(kto, "44421800");
|
assertEquals(kto, "44421800");
|
||||||
assertEquals(holder, "Bei Spiel GmbH");
|
assertEquals(holder, "Bei Spiel GmbH");
|
||||||
assertEquals(ref, "RE-20171118/506");
|
assertEquals(ref, "RE-20171118/506");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exporter test bases on @{code
|
* The exporter test bases on @{code
|
||||||
* ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds
|
* ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds
|
||||||
@@ -362,10 +362,10 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
+ "<ram:ProprietaryID>44421800</ram:ProprietaryID>\n"
|
+ "<ram:ProprietaryID>44421800</ram:ProprietaryID>\n"
|
||||||
+ "</ram:PayeePartyCreditorFinancialAccount>\n"
|
+ "</ram:PayeePartyCreditorFinancialAccount>\n"
|
||||||
+ "<ram:PayeeSpecifiedCreditorFinancialInstitution>\n"
|
+ "<ram:PayeeSpecifiedCreditorFinancialInstitution>\n"
|
||||||
+ "<ram:BICID>COBADEFFXXX</ram:BICID>\n"
|
+ "<ram:BICID>COBADEFFXXX</ram:BICID>\n"
|
||||||
+ "<ram:GermanBankleitzahlID>41441604</ram:GermanBankleitzahlID>\n"
|
+ "<ram:GermanBankleitzahlID>41441604</ram:GermanBankleitzahlID>\n"
|
||||||
+ "<ram:Name>Commerzbank</ram:Name>\n"
|
+ "<ram:Name>Commerzbank</ram:Name>\n"
|
||||||
+ "</ram:PayeeSpecifiedCreditorFinancialInstitution>\n"
|
+ "</ram:PayeeSpecifiedCreditorFinancialInstitution>\n"
|
||||||
+ "</ram:SpecifiedTradeSettlementPaymentMeans>\n" + "<ram:ApplicableTradeTax>\n"
|
+ "</ram:SpecifiedTradeSettlementPaymentMeans>\n" + "<ram:ApplicableTradeTax>\n"
|
||||||
+ "<ram:CalculatedAmount currencyID=\"EUR\">11.20</ram:CalculatedAmount>\n"
|
+ "<ram:CalculatedAmount currencyID=\"EUR\">11.20</ram:CalculatedAmount>\n"
|
||||||
+ "<ram:TypeCode>VAT</ram:TypeCode>\n"
|
+ "<ram:TypeCode>VAT</ram:TypeCode>\n"
|
||||||
@@ -459,13 +459,13 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
+ "</rsm:SpecifiedSupplyChainTradeTransaction>\n" + "</rsm:CrossIndustryDocument>";
|
+ "</rsm:SpecifiedSupplyChainTradeTransaction>\n" + "</rsm:CrossIndustryDocument>";
|
||||||
zea1.setZUGFeRDXMLData(ownZUGFeRDXML.getBytes("UTF-8"));
|
zea1.setZUGFeRDXMLData(ownZUGFeRDXML.getBytes("UTF-8"));
|
||||||
|
|
||||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
zea1.disableAutoClose(true);
|
zea1.disableAutoClose(true);
|
||||||
zea1.export(TARGET_PDF);
|
zea1.export(TARGET_PDF);
|
||||||
zea1.export(baos);
|
zea1.export(baos);
|
||||||
zea1.close();
|
zea1.close();
|
||||||
String pdfContent=baos.toString("UTF-8");
|
String pdfContent = baos.toString("UTF-8");
|
||||||
assertFalse(pdfContent.indexOf("(via mustangproject.org")==-1);
|
assertFalse(pdfContent.indexOf("(via mustangproject.org") == -1);
|
||||||
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>") == -1);
|
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>") == -1);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -480,7 +480,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
|
|
||||||
String amount = null;
|
String amount = null;
|
||||||
String bic = null;
|
String bic = null;
|
||||||
String blz = null;
|
String blz = null;
|
||||||
String iban = null;
|
String iban = null;
|
||||||
String kto = null;
|
String kto = null;
|
||||||
String holder = null;
|
String holder = null;
|
||||||
@@ -490,7 +490,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
zi.parse();
|
zi.parse();
|
||||||
amount = zi.getAmount();
|
amount = zi.getAmount();
|
||||||
bic = zi.getBIC();
|
bic = zi.getBIC();
|
||||||
blz = zi.getBLZ();
|
blz = zi.getBLZ();
|
||||||
iban = zi.getIBAN();
|
iban = zi.getIBAN();
|
||||||
kto = zi.getKTO();
|
kto = zi.getKTO();
|
||||||
holder = zi.getHolder();
|
holder = zi.getHolder();
|
||||||
@@ -499,7 +499,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
|
|||||||
|
|
||||||
assertEquals(amount, "571.04");
|
assertEquals(amount, "571.04");
|
||||||
assertEquals(bic, "COBADEFFXXX");
|
assertEquals(bic, "COBADEFFXXX");
|
||||||
assertEquals(blz, "41441604");
|
assertEquals(blz, "41441604");
|
||||||
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
||||||
assertEquals(kto, "44421800");
|
assertEquals(kto, "44421800");
|
||||||
assertEquals(holder, "Bei Spiel GmbH");
|
assertEquals(holder, "Bei Spiel GmbH");
|
||||||
|
|||||||
@@ -33,457 +33,405 @@ import java.util.Date;
|
|||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExportableTransaction
|
public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExportableTransaction {
|
||||||
{
|
|
||||||
|
@Override
|
||||||
@Override
|
public Date getDeliveryDate() {
|
||||||
public Date getDeliveryDate()
|
return new GregorianCalendar(2017, Calendar.MAY, 7).getTime();
|
||||||
{
|
}
|
||||||
return new GregorianCalendar(2017, Calendar.MAY, 7).getTime();
|
|
||||||
}
|
@Override
|
||||||
|
public Date getDueDate() {
|
||||||
@Override
|
return new GregorianCalendar(2017, Calendar.MAY, 30).getTime();
|
||||||
public Date getDueDate()
|
}
|
||||||
{
|
|
||||||
return new GregorianCalendar(2017, Calendar.MAY, 30).getTime();
|
@Override
|
||||||
}
|
public Date getIssueDate() {
|
||||||
|
return new GregorianCalendar(2017, Calendar.MAY, 9).getTime();
|
||||||
@Override
|
}
|
||||||
public Date getIssueDate()
|
|
||||||
{
|
@Override
|
||||||
return new GregorianCalendar(2017, Calendar.MAY, 9).getTime();
|
public String getNumber() {
|
||||||
}
|
return "RE-20170509/505";
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getNumber()
|
@Override
|
||||||
{
|
public String getOwnKto() {
|
||||||
return "RE-20170509/505";
|
return "44421800";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnKto()
|
public String getOwnBLZ() {
|
||||||
{
|
return "41441604";
|
||||||
return "44421800";
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String getOwnBIC() {
|
||||||
public String getOwnBLZ()
|
return "COBADEFFXXX";
|
||||||
{
|
}
|
||||||
return "41441604";
|
|
||||||
}
|
@Override
|
||||||
|
public String getOwnBankName() {
|
||||||
@Override
|
return "Commerzbank";
|
||||||
public String getOwnBIC()
|
}
|
||||||
{
|
|
||||||
return "COBADEFFXXX";
|
@Override
|
||||||
}
|
public String getOwnCountry() {
|
||||||
|
return "DE";
|
||||||
@Override
|
}
|
||||||
public String getOwnBankName()
|
|
||||||
{
|
@Override
|
||||||
return "Commerzbank";
|
public String getOwnIBAN() {
|
||||||
}
|
return "DE88 2008 0000 0970 3757 00";
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getOwnCountry()
|
@Override
|
||||||
{
|
public String getOwnLocation() {
|
||||||
return "DE";
|
return "Stadthausen";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnIBAN()
|
public String getOwnOrganisationName() {
|
||||||
{
|
return "Bei Spiel GmbH";
|
||||||
return "DE88 2008 0000 0970 3757 00";
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String getOwnStreet() {
|
||||||
public String getOwnLocation()
|
return "Ecke 12";
|
||||||
{
|
}
|
||||||
return "Stadthausen";
|
|
||||||
}
|
@Override
|
||||||
|
public String getOwnTaxID() {
|
||||||
@Override
|
return "22/815/0815/4";
|
||||||
public String getOwnOrganisationName()
|
}
|
||||||
{
|
|
||||||
return "Bei Spiel GmbH";
|
@Override
|
||||||
}
|
public String getOwnVATID() {
|
||||||
|
return "DE136695976";
|
||||||
@Override
|
}
|
||||||
public String getOwnStreet()
|
|
||||||
{
|
@Override
|
||||||
return "Ecke 12";
|
public String getOwnZIP() {
|
||||||
}
|
return "12345";
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getOwnTaxID()
|
@Override
|
||||||
{
|
public IZUGFeRDExportableContact getRecipient() {
|
||||||
return "22/815/0815/4";
|
return new Contact();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOwnVATID()
|
@Override
|
||||||
{
|
public String getOwnOrganisationFullPlaintextInfo() {
|
||||||
return "DE136695976";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnZIP()
|
public String getCurrency() {
|
||||||
{
|
return "EUR";
|
||||||
return "12345";
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public IZUGFeRDExportableItem[] getZFItems() {
|
||||||
public IZUGFeRDExportableContact getRecipient()
|
Item[] allItems = new Item[3];
|
||||||
{
|
Product designProduct = new Product("", "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung", "HUR", new BigDecimal("7.000000"));
|
||||||
return new Contact();
|
Product balloonProduct = new Product("", "Luftballon: Bunt, ca. 500ml", "C62", new BigDecimal("19.000000"));
|
||||||
}
|
Product airProduct = new Product("", "Heiße Luft pro Liter", "LTR", new BigDecimal("19.000000"));
|
||||||
|
|
||||||
|
allItems[0] = new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
||||||
@Override
|
allItems[1] = new Item(new BigDecimal("0.79"), new BigDecimal("400"), balloonProduct);
|
||||||
public String getOwnOrganisationFullPlaintextInfo()
|
allItems[2] = new Item(new BigDecimal("0.10"), new BigDecimal("200"), airProduct);
|
||||||
{
|
return allItems;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String getOwnPaymentInfoText() {
|
||||||
public String getCurrency()
|
return "Überweisung";
|
||||||
{
|
}
|
||||||
return "EUR";
|
|
||||||
}
|
@Override
|
||||||
|
public String getPaymentTermDescription() {
|
||||||
@Override
|
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
public IZUGFeRDExportableItem[] getZFItems()
|
return "Zahlbar ohne Abzug bis zum " + germanDateFormat.format(getDueDate());
|
||||||
{
|
}
|
||||||
Item[] allItems = new Item[3];
|
|
||||||
Product designProduct = new Product("", "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung", "HUR", new BigDecimal("7.000000"));
|
@Override
|
||||||
Product balloonProduct = new Product("", "Luftballon: Bunt, ca. 500ml", "C62", new BigDecimal("19.000000"));
|
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
||||||
Product airProduct = new Product("", "Heiße Luft pro Liter", "LTR", new BigDecimal("19.000000"));
|
return null;
|
||||||
|
}
|
||||||
allItems[0] = new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
|
||||||
allItems[1] = new Item(new BigDecimal("0.79"), new BigDecimal("400"), balloonProduct);
|
@Override
|
||||||
allItems[2] = new Item(new BigDecimal("0.10"), new BigDecimal("200"), airProduct);
|
public IZUGFeRDAllowanceCharge[] getZFCharges() {
|
||||||
return allItems;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnPaymentInfoText() {
|
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
||||||
return "Überweisung";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPaymentTermDescription() {
|
public String getReferenceNumber() {
|
||||||
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
return null;
|
||||||
return "Zahlbar ohne Abzug bis zum " + germanDateFormat.format(getDueDate());
|
}
|
||||||
}
|
|
||||||
|
class Contact implements IZUGFeRDExportableContact {
|
||||||
@Override
|
|
||||||
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
@Override
|
||||||
return null;
|
public String getCountry() {
|
||||||
}
|
return "DE";
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public IZUGFeRDAllowanceCharge[] getZFCharges() {
|
@Override
|
||||||
return null;
|
public String getLocation() {
|
||||||
}
|
return "Spielkreis";
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
@Override
|
||||||
return null;
|
public String getName() {
|
||||||
}
|
return "Theodor Est";
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public String getReferenceNumber() {
|
@Override
|
||||||
return null;
|
public String getStreet() {
|
||||||
}
|
return "Bahnstr. 42";
|
||||||
|
}
|
||||||
class Contact implements IZUGFeRDExportableContact
|
|
||||||
{
|
@Override
|
||||||
|
public String getVATID() {
|
||||||
@Override
|
return "DE999999999";
|
||||||
public String getCountry()
|
}
|
||||||
{
|
|
||||||
return "DE";
|
@Override
|
||||||
}
|
public String getZIP() {
|
||||||
|
return "88802";
|
||||||
@Override
|
}
|
||||||
public String getLocation()
|
}
|
||||||
{
|
|
||||||
return "Spielkreis";
|
class Item implements IZUGFeRDExportableItem {
|
||||||
}
|
|
||||||
|
public Item(BigDecimal price, BigDecimal quantity, Product product) {
|
||||||
@Override
|
super();
|
||||||
public String getName()
|
this.price = price;
|
||||||
{
|
this.quantity = quantity;
|
||||||
return "Theodor Est";
|
this.product = product;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private BigDecimal price, quantity;
|
||||||
public String getStreet()
|
private Product product;
|
||||||
{
|
|
||||||
return "Bahnstr. 42";
|
@Override
|
||||||
}
|
public BigDecimal getPrice() {
|
||||||
|
return price;
|
||||||
@Override
|
}
|
||||||
public String getVATID()
|
|
||||||
{
|
public void setPrice(BigDecimal price) {
|
||||||
return "DE999999999";
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getZIP()
|
public BigDecimal getQuantity() {
|
||||||
{
|
return quantity;
|
||||||
return "88802";
|
}
|
||||||
}
|
|
||||||
}
|
public void setQuantity(BigDecimal quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
class Item implements IZUGFeRDExportableItem
|
}
|
||||||
{
|
|
||||||
|
@Override
|
||||||
public Item(BigDecimal price, BigDecimal quantity, Product product)
|
public Product getProduct() {
|
||||||
{
|
return product;
|
||||||
super();
|
}
|
||||||
this.price = price;
|
|
||||||
this.quantity = quantity;
|
public void setProduct(Product product) {
|
||||||
this.product = product;
|
this.product = product;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal price,quantity;
|
@Override
|
||||||
private Product product;
|
public IZUGFeRDAllowanceCharge[] getItemAllowances() {
|
||||||
|
return null;
|
||||||
@Override
|
}
|
||||||
public BigDecimal getPrice()
|
|
||||||
{
|
@Override
|
||||||
return price;
|
public IZUGFeRDAllowanceCharge[] getItemCharges() {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
public void setPrice(BigDecimal price)
|
|
||||||
{
|
}
|
||||||
this.price = price;
|
|
||||||
}
|
class Product implements IZUGFeRDExportableProduct {
|
||||||
|
private String description, name, unit;
|
||||||
@Override
|
private BigDecimal VATPercent;
|
||||||
public BigDecimal getQuantity()
|
|
||||||
{
|
public Product(String description, String name, String unit, BigDecimal VATPercent) {
|
||||||
return quantity;
|
super();
|
||||||
}
|
this.description = description;
|
||||||
|
this.name = name;
|
||||||
public void setQuantity(BigDecimal quantity)
|
this.unit = unit;
|
||||||
{
|
this.VATPercent = VATPercent;
|
||||||
this.quantity = quantity;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String getDescription() {
|
||||||
public Product getProduct()
|
return description;
|
||||||
{
|
}
|
||||||
return product;
|
|
||||||
}
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
public void setProduct(Product product)
|
}
|
||||||
{
|
|
||||||
this.product = product;
|
@Override
|
||||||
}
|
public String getName() {
|
||||||
|
return name;
|
||||||
@Override
|
}
|
||||||
public IZUGFeRDAllowanceCharge[] getItemAllowances() {
|
|
||||||
return null;
|
public void setName(String name) {
|
||||||
}
|
this.name = name;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public IZUGFeRDAllowanceCharge[] getItemCharges() {
|
@Override
|
||||||
return null;
|
public String getUnit() {
|
||||||
}
|
return unit;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
class Product implements IZUGFeRDExportableProduct
|
this.unit = unit;
|
||||||
{
|
}
|
||||||
private String description, name, unit;
|
|
||||||
private BigDecimal VATPercent;
|
@Override
|
||||||
|
public BigDecimal getVATPercent() {
|
||||||
public Product(String description, String name, String unit, BigDecimal VATPercent)
|
return VATPercent;
|
||||||
{
|
}
|
||||||
super();
|
|
||||||
this.description = description;
|
public void setVATPercent(BigDecimal vATPercent) {
|
||||||
this.name = name;
|
VATPercent = vATPercent;
|
||||||
this.unit = unit;
|
}
|
||||||
this.VATPercent = VATPercent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public String getDescription()
|
* Create the test case
|
||||||
{
|
*
|
||||||
return description;
|
* @param testName name of the test case
|
||||||
}
|
*/
|
||||||
|
public MustangReaderWriterEdgeTest(String testName) {
|
||||||
public void setDescription(String description)
|
super(testName);
|
||||||
{
|
}
|
||||||
this.description = description;
|
|
||||||
}
|
/**
|
||||||
|
* @return the suite of tests being tested
|
||||||
@Override
|
*/
|
||||||
public String getName()
|
public static Test suite() {
|
||||||
{
|
return new TestSuite(MustangReaderWriterEdgeTest.class);
|
||||||
return name;
|
}
|
||||||
}
|
|
||||||
|
// //////// TESTS //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
public void setName(String name)
|
|
||||||
{
|
/**
|
||||||
this.name = name;
|
* The importer test imports from ./src/test/MustangGnuaccountingBeispielRE-20170509_505.pdf to check the values.
|
||||||
}
|
* --> as only Name Ascending is supported for Test Unit sequence, I renamed the this test-A-Export to run before
|
||||||
|
* testZExport
|
||||||
@Override
|
*
|
||||||
public String getUnit()
|
* @throws IOException
|
||||||
{
|
*/
|
||||||
return unit;
|
|
||||||
}
|
public void testAImport() throws IOException {
|
||||||
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
public void setUnit(String unit)
|
zi.extractLowLevel(this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf"));
|
||||||
{
|
// Reading ZUGFeRD
|
||||||
this.unit = unit;
|
|
||||||
}
|
String amount = null;
|
||||||
|
String bic = null;
|
||||||
@Override
|
String blz = null;
|
||||||
public BigDecimal getVATPercent()
|
String iban = null;
|
||||||
{
|
String kto = null;
|
||||||
return VATPercent;
|
String holder = null;
|
||||||
}
|
String ref = null;
|
||||||
|
String dueDate = null;
|
||||||
public void setVATPercent(BigDecimal vATPercent)
|
|
||||||
{
|
if (zi.canParse()) {
|
||||||
VATPercent = vATPercent;
|
zi.parse();
|
||||||
}
|
amount = zi.getAmount();
|
||||||
|
bic = zi.getBIC();
|
||||||
}
|
blz = zi.getBLZ();
|
||||||
|
iban = zi.getIBAN();
|
||||||
/**
|
kto = zi.getKTO();
|
||||||
* Create the test case
|
holder = zi.getHolder();
|
||||||
*
|
dueDate = zi.getDueDate();
|
||||||
* @param testName
|
ref = zi.getForeignReference();
|
||||||
* name of the test case
|
}
|
||||||
*/
|
|
||||||
public MustangReaderWriterEdgeTest(String testName)
|
assertEquals(amount, "571.04");
|
||||||
{
|
assertEquals(bic, getOwnBIC());
|
||||||
super(testName);
|
assertEquals(blz, getOwnBLZ());
|
||||||
}
|
assertEquals(iban, getOwnIBAN());
|
||||||
|
assertEquals(kto, getOwnKto());
|
||||||
/**
|
assertEquals(holder, getOwnOrganisationName());
|
||||||
* @return the suite of tests being tested
|
|
||||||
*/
|
assertEquals(dueDate, "20170530");
|
||||||
public static Test suite()
|
assertEquals(ref, getNumber());
|
||||||
{
|
|
||||||
return new TestSuite(MustangReaderWriterEdgeTest.class);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
// //////// TESTS //////////////////////////////////////////////////////////////////////////////////////////
|
* The exporter test bases on @{code ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds metadata,
|
||||||
|
* writes
|
||||||
/**
|
* to @{code ./target/testout-*} and then imports to check the values.
|
||||||
* The importer test imports from ./src/test/MustangGnuaccountingBeispielRE-20170509_505.pdf to check the values.
|
* It would not make sense to have it run before the less complex importer test (which is probably redundant)
|
||||||
* --> as only Name Ascending is supported for Test Unit sequence, I renamed the this test-A-Export to run before
|
* --> as only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export
|
||||||
* testZExport
|
*/
|
||||||
*
|
public void testEdgeExport() throws Exception {
|
||||||
* @throws IOException
|
|
||||||
*/
|
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505newEdge.pdf";
|
||||||
|
// the writing part
|
||||||
public void testAImport() throws IOException
|
|
||||||
{
|
try (InputStream SOURCE_PDF =
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
||||||
zi.extractLowLevel(this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf"));
|
|
||||||
// Reading ZUGFeRD
|
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory()
|
||||||
|
.setProducer("My Application")
|
||||||
String amount = null;
|
.setCreator(System.getProperty("user.name"))
|
||||||
String bic = null;
|
.ignorePDFAErrors()
|
||||||
String blz = null;
|
.load(SOURCE_PDF)) {
|
||||||
String iban = null;
|
ze.setZUGFeRDVersion(1);
|
||||||
String kto = null;
|
ze.PDFattachZugferdFile(this);
|
||||||
String holder = null;
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
String ref = null;
|
assertTrue(theXML.contains("<rsm:CrossIndustryDocument"));
|
||||||
String dueDate = null;
|
ze.export(TARGET_PDF);
|
||||||
|
}
|
||||||
if (zi.canParse())
|
|
||||||
{
|
// now check the contents (like MustangReaderTest)
|
||||||
zi.parse();
|
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
||||||
amount = zi.getAmount();
|
zi.extract(TARGET_PDF);
|
||||||
bic = zi.getBIC();
|
// Reading ZUGFeRD
|
||||||
blz = zi.getBLZ();
|
|
||||||
iban = zi.getIBAN();
|
String amount = null;
|
||||||
kto = zi.getKTO();
|
String bic = null;
|
||||||
holder = zi.getHolder();
|
String blz = null;
|
||||||
dueDate = zi.getDueDate();
|
String iban = null;
|
||||||
ref = zi.getForeignReference();
|
String kto = null;
|
||||||
}
|
String holder = null;
|
||||||
|
String ref = null;
|
||||||
assertEquals(amount, "571.04");
|
|
||||||
assertEquals(bic, getOwnBIC());
|
if (zi.canParse()) {
|
||||||
assertEquals(blz, getOwnBLZ());
|
zi.parse();
|
||||||
assertEquals(iban, getOwnIBAN());
|
amount = zi.getAmount();
|
||||||
assertEquals(kto, getOwnKto());
|
bic = zi.getBIC();
|
||||||
assertEquals(holder, getOwnOrganisationName());
|
blz = zi.getBLZ();
|
||||||
|
iban = zi.getIBAN();
|
||||||
assertEquals(dueDate, "20170530");
|
kto = zi.getKTO();
|
||||||
assertEquals(ref, getNumber());
|
holder = zi.getHolder();
|
||||||
|
ref = zi.getForeignReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
assertEquals(amount, "571.04");
|
||||||
* The exporter test bases on @{code ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds metadata,
|
assertEquals(bic, getOwnBIC());
|
||||||
* writes
|
assertEquals(blz, getOwnBLZ());
|
||||||
* to @{code ./target/testout-*} and then imports to check the values.
|
assertEquals(iban, getOwnIBAN());
|
||||||
* It would not make sense to have it run before the less complex importer test (which is probably redundant)
|
assertEquals(kto, getOwnKto());
|
||||||
* --> as only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export
|
assertEquals(holder, getOwnOrganisationName());
|
||||||
*/
|
assertEquals(ref, getNumber());
|
||||||
public void testEdgeExport() throws Exception {
|
|
||||||
|
}
|
||||||
final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505newEdge.pdf";
|
|
||||||
// the writing part
|
|
||||||
|
|
||||||
try(InputStream SOURCE_PDF =
|
|
||||||
this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
|
||||||
|
|
||||||
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory()
|
|
||||||
.setProducer("My Application")
|
|
||||||
.setCreator(System.getProperty("user.name"))
|
|
||||||
.ignorePDFAErrors()
|
|
||||||
.load(SOURCE_PDF)) {
|
|
||||||
ze.setZUGFeRDVersion(1);
|
|
||||||
ze.PDFattachZugferdFile(this);
|
|
||||||
String theXML=new String(ze.getProvider().getXML());
|
|
||||||
assertTrue(theXML.contains("<rsm:CrossIndustryDocument"));
|
|
||||||
ze.export(TARGET_PDF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// now check the contents (like MustangReaderTest)
|
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter();
|
|
||||||
zi.extract(TARGET_PDF);
|
|
||||||
// Reading ZUGFeRD
|
|
||||||
|
|
||||||
String amount = null;
|
|
||||||
String bic = null;
|
|
||||||
String blz = null;
|
|
||||||
String iban = null;
|
|
||||||
String kto = null;
|
|
||||||
String holder = null;
|
|
||||||
String ref = null;
|
|
||||||
|
|
||||||
if (zi.canParse())
|
|
||||||
{
|
|
||||||
zi.parse();
|
|
||||||
amount = zi.getAmount();
|
|
||||||
bic = zi.getBIC();
|
|
||||||
blz = zi.getBLZ();
|
|
||||||
iban = zi.getIBAN();
|
|
||||||
kto = zi.getKTO();
|
|
||||||
holder = zi.getHolder();
|
|
||||||
ref = zi.getForeignReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
assertEquals(amount, "571.04");
|
|
||||||
assertEquals(bic, getOwnBIC());
|
|
||||||
assertEquals(blz, getOwnBLZ());
|
|
||||||
assertEquals(iban, getOwnIBAN());
|
|
||||||
assertEquals(kto, getOwnKto());
|
|
||||||
assertEquals(holder, getOwnOrganisationName());
|
|
||||||
assertEquals(ref, getNumber());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,17 +57,17 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
return "RE-20171118/506";
|
return "RE-20171118/506";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnKto() {
|
public String getOwnKto() {
|
||||||
return "44421800";
|
return "44421800";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBLZ() {
|
public String getOwnBLZ() {
|
||||||
return "41441604";
|
return "41441604";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOwnBIC() {
|
public String getOwnBIC() {
|
||||||
return "COBADEFFXXX";
|
return "COBADEFFXXX";
|
||||||
}
|
}
|
||||||
@@ -320,8 +320,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
/**
|
/**
|
||||||
* Create the test case
|
* Create the test case
|
||||||
*
|
*
|
||||||
* @param testName
|
* @param testName name of the test case
|
||||||
* name of the test case
|
|
||||||
*/
|
*/
|
||||||
public MustangReaderWriterTest(String testName) {
|
public MustangReaderWriterTest(String testName) {
|
||||||
super(testName);
|
super(testName);
|
||||||
@@ -356,7 +355,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
|
|
||||||
String amount = null;
|
String amount = null;
|
||||||
String blz = null;
|
String blz = null;
|
||||||
String bic = null;
|
String bic = null;
|
||||||
String iban = null;
|
String iban = null;
|
||||||
String kto = null;
|
String kto = null;
|
||||||
@@ -366,7 +365,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
if (zi.canParse()) {
|
if (zi.canParse()) {
|
||||||
zi.parse();
|
zi.parse();
|
||||||
amount = zi.getAmount();
|
amount = zi.getAmount();
|
||||||
blz = zi.getBLZ();
|
blz = zi.getBLZ();
|
||||||
bic = zi.getBIC();
|
bic = zi.getBIC();
|
||||||
iban = zi.getIBAN();
|
iban = zi.getIBAN();
|
||||||
kto = zi.getKTO();
|
kto = zi.getKTO();
|
||||||
@@ -376,7 +375,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
// this resembles the data written in MustangReaderWriterCustomXMLTest
|
// this resembles the data written in MustangReaderWriterCustomXMLTest
|
||||||
assertEquals(amount, "571.04");
|
assertEquals(amount, "571.04");
|
||||||
assertEquals(blz, "41441604");
|
assertEquals(blz, "41441604");
|
||||||
assertEquals(bic, "COBADEFFXXX");
|
assertEquals(bic, "COBADEFFXXX");
|
||||||
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
|
||||||
assertEquals(kto, "44421800");
|
assertEquals(kto, "44421800");
|
||||||
assertEquals(holder, "Bei Spiel GmbH");
|
assertEquals(holder, "Bei Spiel GmbH");
|
||||||
@@ -393,7 +392,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
}
|
}
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
|
|
||||||
String amount = zi.getAmount();
|
String amount = zi.getAmount();
|
||||||
|
|
||||||
assertEquals("<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" +
|
assertEquals("<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" +
|
||||||
" <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n" +
|
" <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n" +
|
||||||
@@ -476,7 +475,6 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void testMigratePDFA1ToA3() throws IOException {
|
public void testMigratePDFA1ToA3() throws IOException {
|
||||||
// just make sure there is no Exception
|
// just make sure there is no Exception
|
||||||
InputStream SOURCE_PDF = this.getClass()
|
InputStream SOURCE_PDF = this.getClass()
|
||||||
@@ -506,7 +504,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
try (InputStream SOURCE_PDF = this.getClass()
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf");
|
||||||
|
|
||||||
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().setZUGFeRDVersion(2).setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931).load(SOURCE_PDF)) {
|
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().setZUGFeRDVersion(2).setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931).load(SOURCE_PDF)) {
|
||||||
|
|
||||||
ze.PDFattachZugferdFile(this);
|
ze.PDFattachZugferdFile(this);
|
||||||
ze.disableAutoClose(true);
|
ze.disableAutoClose(true);
|
||||||
@@ -554,8 +552,8 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Test(expected = IndexOutOfBoundsException.class)
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
* @Test(expected = IndexOutOfBoundsException.class)
|
||||||
*/
|
*/
|
||||||
public void testExceptionOnPDF14() throws Exception {
|
public void testExceptionOnPDF14() throws Exception {
|
||||||
|
|
||||||
@@ -566,7 +564,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
|
|||||||
try (InputStream SOURCE_PDF = this.getClass()
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDF14.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDF14.pdf");
|
||||||
|
|
||||||
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().load(SOURCE_PDF)) {
|
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().load(SOURCE_PDF)) {
|
||||||
|
|
||||||
ze.PDFattachZugferdFile(this);
|
ze.PDFattachZugferdFile(this);
|
||||||
ze.export(TARGET_PDF);
|
ze.export(TARGET_PDF);
|
||||||
|
|||||||
@@ -26,28 +26,35 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/** This test utility class is providing usability functions for test file resources */
|
* This test utility class is providing usability functions for test file resources
|
||||||
|
*/
|
||||||
public class ResourceUtilities {
|
public class ResourceUtilities {
|
||||||
private static final Logger LOG = Logger.getLogger(ResourceUtilities.class.getName());
|
private static final Logger LOG = Logger.getLogger(ResourceUtilities.class.getName());
|
||||||
|
|
||||||
/** Loading a File into a String using a certain encoding and file path */
|
/**
|
||||||
public static String readFile(Charset encoding, String path) throws IOException {
|
* Loading a File into a String using a certain encoding and file path
|
||||||
byte[] content = Files.readAllBytes(Paths.get(path));
|
*/
|
||||||
return new String(content, encoding);
|
public static String readFile(Charset encoding, String path) throws IOException {
|
||||||
}
|
byte[] content = Files.readAllBytes(Paths.get(path));
|
||||||
|
return new String(content, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
/** Saving a String as a file to a certain file path */
|
/**
|
||||||
public static void saveFile(Charset encoding, String path, String content) throws FileNotFoundException {
|
* Saving a String as a file to a certain file path
|
||||||
|
*/
|
||||||
|
public static void saveFile(Charset encoding, String path, String content) throws FileNotFoundException {
|
||||||
|
|
||||||
// resources will be released automatically
|
// resources will be released automatically
|
||||||
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(path)), encoding), true)) {
|
try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(path)), encoding), true)) {
|
||||||
out.println(content);
|
out.println(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** The relative path of the test file will be resolved and the absolute will be returned
|
/**
|
||||||
|
* The relative path of the test file will be resolved and the absolute will be returned
|
||||||
|
*
|
||||||
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
||||||
* @return the absolute path of the test file
|
* @return the absolute path of the test file
|
||||||
* @throws FileNotFoundException If the file could not be found
|
* @throws FileNotFoundException If the file could not be found
|
||||||
@@ -66,7 +73,9 @@ public class ResourceUtilities {
|
|||||||
return uri.getPath();
|
return uri.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The relative path of the test file will be resolved and the absolute will be returned
|
/**
|
||||||
|
* The relative path of the test file will be resolved and the absolute will be returned
|
||||||
|
*
|
||||||
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
||||||
* @return the URI created based on the relativeFilePath
|
* @return the URI created based on the relativeFilePath
|
||||||
* @throws URISyntaxException if no URI could be created from the given relative path
|
* @throws URISyntaxException if no URI could be created from the given relative path
|
||||||
@@ -77,19 +86,23 @@ public class ResourceUtilities {
|
|||||||
return new URI(filePath);
|
return new URI(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The relative path of the test file will be used to determine an absolute
|
/**
|
||||||
* path to a temporary directory in the output directory.
|
* The relative path of the test file will be used to determine an absolute
|
||||||
|
* path to a temporary directory in the output directory.
|
||||||
|
*
|
||||||
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
||||||
* @return absolute path to a test output
|
* @return absolute path to a test output
|
||||||
* @throws IOException if no absolute Path could be created.
|
* @throws IOException if no absolute Path could be created.
|
||||||
*/
|
*/
|
||||||
public static String getTestOutput(String relativeFilePath) throws IOException {
|
public static String getTestOutput(String relativeFilePath) throws IOException {
|
||||||
File tempFile=File.createTempFile(relativeFilePath, null);
|
File tempFile = File.createTempFile(relativeFilePath, null);
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
return tempFile.getAbsolutePath();
|
return tempFile.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The Input of the test file will be resolved and the absolute will be returned
|
/**
|
||||||
|
* The Input of the test file will be resolved and the absolute will be returned
|
||||||
|
*
|
||||||
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
* @param relativeFilePath Path of the test resource relative to <code>src/test/resource/</code>.
|
||||||
* @return the absolute path of the test file
|
* @return the absolute path of the test file
|
||||||
*/
|
*/
|
||||||
@@ -97,7 +110,9 @@ public class ResourceUtilities {
|
|||||||
return ResourceUtilities.class.getClassLoader().getResourceAsStream(relativeFilePath);
|
return ResourceUtilities.class.getClassLoader().getResourceAsStream(relativeFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Relative to the test output directory a test file will be returned dependent on the relativeFilePath provided.
|
/**
|
||||||
|
* Relative to the test output directory a test file will be returned dependent on the relativeFilePath provided.
|
||||||
|
*
|
||||||
* @param relativeFilePath Path of the test output resource relative to <code>target/test-classes/</code>.
|
* @param relativeFilePath Path of the test output resource relative to <code>target/test-classes/</code>.
|
||||||
* @return the empty <code>File</code> of the test output (to be filled)
|
* @return the empty <code>File</code> of the test output (to be filled)
|
||||||
*/
|
*/
|
||||||
@@ -127,17 +142,17 @@ public class ResourceUtilities {
|
|||||||
public static File getTempTestDirectory() {
|
public static File getTempTestDirectory() {
|
||||||
File tempDir = new File(ResourceUtilities.getTestOutputFolder() + "temp");
|
File tempDir = new File(ResourceUtilities.getTestOutputFolder() + "temp");
|
||||||
tempDir.mkdir(); //if it already exist no problem
|
tempDir.mkdir(); //if it already exist no problem
|
||||||
return tempDir;
|
return tempDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To fix the 3 slashes bug for File URI: For example:
|
* To fix the 3 slashes bug for File URI: For example:
|
||||||
* file:/C:/work/test.txt -> file:///C:/work/test.txt
|
* file:/C:/work/test.txt -> file:///C:/work/test.txt
|
||||||
*
|
*
|
||||||
* @param u - the File URI
|
* @param u - the File URI
|
||||||
* @return the String of the URI
|
* @return the String of the URI
|
||||||
*/
|
*/
|
||||||
public static String toExternalForm(URI u) {
|
public static String toExternalForm(URI u) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (u.getScheme() != null) {
|
if (u.getScheme() != null) {
|
||||||
sb.append(u.getScheme());
|
sb.append(u.getScheme());
|
||||||
@@ -180,13 +195,14 @@ public class ResourceUtilities {
|
|||||||
sb.append(u.getFragment());
|
sb.append(u.getFragment());
|
||||||
}
|
}
|
||||||
String ret = null;
|
String ret = null;
|
||||||
try {
|
try {
|
||||||
ret = new URI(sb.toString()).toASCIIString();
|
ret = new URI(sb.toString()).toASCIIString();
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
LOG.log(Level.SEVERE, null, ex);
|
LOG.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
private ResourceUtilities() {
|
|
||||||
}
|
private ResourceUtilities() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,18 +38,18 @@ import java.util.logging.Logger;
|
|||||||
* will be migrated to <code>src/test/resources/migration/output</code>.
|
* will be migrated to <code>src/test/resources/migration/output</code>.
|
||||||
* If there is a similar named file as test reference <code>src/test/resources/migration/reference</code> a test
|
* If there is a similar named file as test reference <code>src/test/resources/migration/reference</code> a test
|
||||||
* will be triggered for every single file.
|
* will be triggered for every single file.
|
||||||
*
|
* <p/>
|
||||||
* Note: Any 'ZUGFeRD1' will be exchanged to 'ZUGFeRD2' during migration and adequate reference will be searched for.
|
* Note: Any 'ZUGFeRD1' will be exchanged to 'ZUGFeRD2' during migration and adequate reference will be searched for.
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class VersionMigrationTest {
|
public class VersionMigrationTest {
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(VersionMigrationTest.class.getName());
|
private static final Logger LOG = Logger.getLogger(VersionMigrationTest.class.getName());
|
||||||
|
|
||||||
private static final String INPUT_DIR = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "migration" + File.separator + "input" + File.separator;
|
private static final String INPUT_DIR = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "migration" + File.separator + "input" + File.separator;
|
||||||
private static final String REFERENCE_DIR = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "migration" + File.separator + "reference" + File.separator;
|
private static final String REFERENCE_DIR = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "migration" + File.separator + "reference" + File.separator;
|
||||||
private static final String OUTPUT_DIR = "target" + File.separator + "test-classes" + File.separator + "migration" + File.separator + "output" + File.separator;
|
private static final String OUTPUT_DIR = "target" + File.separator + "test-classes" + File.separator + "migration" + File.separator + "output" + File.separator;
|
||||||
private File mTestFile = null;
|
private File mTestFile = null;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
@@ -70,76 +70,75 @@ public class VersionMigrationTest {
|
|||||||
|
|
||||||
private static void addFilesFromFolder(final File folder, Collection<Object[]> testSuiteData) {
|
private static void addFilesFromFolder(final File folder, Collection<Object[]> testSuiteData) {
|
||||||
String filePath = null;
|
String filePath = null;
|
||||||
for (final File fileEntry : folder.listFiles()) {
|
for (final File fileEntry : folder.listFiles()) {
|
||||||
filePath = fileEntry.getAbsolutePath();
|
filePath = fileEntry.getAbsolutePath();
|
||||||
if (fileEntry.isDirectory()) {
|
if (fileEntry.isDirectory()) {
|
||||||
LOG.log(Level.INFO, "*** testDirectory:{0}", filePath);
|
LOG.log(Level.INFO, "*** testDirectory:{0}", filePath);
|
||||||
addFilesFromFolder(fileEntry, testSuiteData);
|
addFilesFromFolder(fileEntry, testSuiteData);
|
||||||
} else {
|
} else {
|
||||||
LOG.log(Level.INFO, "*** testFile: {0}", filePath);
|
LOG.log(Level.INFO, "*** testFile: {0}", filePath);
|
||||||
Object[] testData = new Object[]{fileEntry};
|
Object[] testData = new Object[]{fileEntry};
|
||||||
testSuiteData.add(testData);
|
testSuiteData.add(testData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
/**
|
/**
|
||||||
* ZUGFeRD 1.0 to 2.0 migration test.
|
* ZUGFeRD 1.0 to 2.0 migration test.
|
||||||
* For more information see class description. */
|
* For more information see class description. */
|
||||||
public void testFile() {
|
public void testFile() {
|
||||||
testMigration(mTestFile.getName());
|
testMigration(mTestFile.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testMigration(String fileName) {
|
private void testMigration(String fileName) {
|
||||||
try {
|
try {
|
||||||
String tmp = new ZUGFeRDMigrator().migrateFromV1ToV2(INPUT_DIR + fileName);
|
String tmp = new ZUGFeRDMigrator().migrateFromV1ToV2(INPUT_DIR + fileName);
|
||||||
String newName = fileName.replace("ZUGFeRD1", "ZUGFeRD2");
|
String newName = fileName.replace("ZUGFeRD1", "ZUGFeRD2");
|
||||||
ResourceUtilities.saveFile(StandardCharsets.UTF_8, OUTPUT_DIR + newName, tmp);
|
ResourceUtilities.saveFile(StandardCharsets.UTF_8, OUTPUT_DIR + newName, tmp);
|
||||||
if(new File(REFERENCE_DIR + newName).exists()){
|
if (new File(REFERENCE_DIR + newName).exists()) {
|
||||||
// we need to save the string and reload it otherwise two bytes are missing (likely EOF related)
|
// we need to save the string and reload it otherwise two bytes are missing (likely EOF related)
|
||||||
String outXML = ResourceUtilities.readFile(StandardCharsets.UTF_8, OUTPUT_DIR + newName);
|
String outXML = ResourceUtilities.readFile(StandardCharsets.UTF_8, OUTPUT_DIR + newName);
|
||||||
String refXML = ResourceUtilities.readFile(StandardCharsets.UTF_8, REFERENCE_DIR + newName);
|
String refXML = ResourceUtilities.readFile(StandardCharsets.UTF_8, REFERENCE_DIR + newName);
|
||||||
int t = outXML.length();
|
int t = outXML.length();
|
||||||
int r = refXML.length();
|
int r = refXML.length();
|
||||||
if (t != r || !(outXML.equals(refXML))) {
|
if (t != r || !(outXML.equals(refXML))) {
|
||||||
LOG.info("There are differences between:"
|
LOG.info("There are differences between:"
|
||||||
+ "\nZUGFeRD 2.0 Test Output @ " + OUTPUT_DIR + newName
|
+ "\nZUGFeRD 2.0 Test Output @ " + OUTPUT_DIR + newName
|
||||||
+ "\nZUGFeRD 2.0 Test Reference @ " + REFERENCE_DIR + newName);
|
+ "\nZUGFeRD 2.0 Test Reference @ " + REFERENCE_DIR + newName);
|
||||||
LOG.info("\n\nFile sizes:\n "
|
LOG.info("\n\nFile sizes:\n "
|
||||||
+ "\nZUGFeRD 2.0 Test Output character count: " + t
|
+ "\nZUGFeRD 2.0 Test Output character count: " + t
|
||||||
+ "\nZUGFeRD 2.0 Test Refer. character count: " + r);
|
+ "\nZUGFeRD 2.0 Test Refer. character count: " + r);
|
||||||
findLineDiffs(outXML, refXML);
|
findLineDiffs(outXML, refXML);
|
||||||
Assert.fail("Version update failed, as test result and reference are different!");
|
Assert.fail("Version update failed, as test result and reference are different!");
|
||||||
}else{
|
} else {
|
||||||
LOG.log(Level.INFO,"\n*** Tested successfull migration from ZUGFeRD 1.0 to 2.0: '" + newName + "'' ***\n", OUTPUT_DIR);
|
LOG.log(Level.INFO, "\n*** Tested successfull migration from ZUGFeRD 1.0 to 2.0: '" + newName + "'' ***\n", OUTPUT_DIR);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
LOG.log(Level.INFO,"\n*** Migrated from ZUGFeRD 1.0 to 2.0 invoice: '" + newName + "'' ***\n", OUTPUT_DIR);
|
LOG.log(Level.INFO, "\n*** Migrated from ZUGFeRD 1.0 to 2.0 invoice: '" + newName + "'' ***\n", OUTPUT_DIR);
|
||||||
}
|
}
|
||||||
} catch (IOException | TransformerException t) {
|
} catch (IOException | TransformerException t) {
|
||||||
LOG.log(Level.SEVERE, t.getMessage(), t);
|
LOG.log(Level.SEVERE, t.getMessage(), t);
|
||||||
Assert.fail("Failed with " + t.getClass().getName() + ": '" + t.getMessage() + "'");
|
Assert.fail("Failed with " + t.getClass().getName() + ": '" + t.getMessage() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void findLineDiffs(String outXML, String refXML) {
|
||||||
private static void findLineDiffs(String outXML, String refXML){
|
Scanner outScanner = new Scanner(outXML);
|
||||||
Scanner outScanner = new Scanner(outXML);
|
Scanner refScanner = new Scanner(refXML);
|
||||||
Scanner refScanner = new Scanner(refXML);
|
String outLine = null;
|
||||||
String outLine = null;
|
String refLine = null;
|
||||||
String refLine = null;
|
while (outScanner.hasNextLine() && refScanner.hasNextLine()) {
|
||||||
while (outScanner.hasNextLine() && refScanner.hasNextLine()) {
|
outLine = outScanner.nextLine();
|
||||||
outLine = outScanner.nextLine();
|
refLine = refScanner.nextLine();
|
||||||
refLine = refScanner.nextLine();
|
if (!outLine.equals(refLine)) {
|
||||||
if(!outLine.equals(refLine)){
|
LOG.info("First line difference between reference and output file:" +
|
||||||
LOG.info("First line difference between reference and output file:" +
|
"\nRefLine: " + refLine +
|
||||||
"\nRefLine: " + refLine +
|
"\nOutLine: " + outLine + "\n");
|
||||||
"\nOutLine: " + outLine + "\n");
|
}
|
||||||
}
|
}
|
||||||
}
|
refScanner.close();
|
||||||
refScanner.close();
|
outScanner.close();
|
||||||
outScanner.close();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,48 +27,48 @@ import java.util.Date;
|
|||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
public class ZUGFeRDTransactionModelConverterTest {
|
public class ZUGFeRDTransactionModelConverterTest {
|
||||||
@Test
|
@Test
|
||||||
public void convertToModel_convertsMinimalTransactionToValidXml() throws Exception {
|
public void convertToModel_convertsMinimalTransactionToValidXml() throws Exception {
|
||||||
// setup
|
// setup
|
||||||
IZUGFeRDExportableTransaction transaction = new IZUGFeRDExportableTransactionImpl()
|
IZUGFeRDExportableTransaction transaction = new IZUGFeRDExportableTransactionImpl()
|
||||||
.setIssueDate(createDate(2000, 1, 1))
|
.setIssueDate(createDate(2000, 1, 1))
|
||||||
.setDeliveryDate(createDate(2000, 1, 2))
|
.setDeliveryDate(createDate(2000, 1, 2))
|
||||||
.setDueDate(createDate(2000, 1, 3))
|
.setDueDate(createDate(2000, 1, 3))
|
||||||
.setNumber("num")
|
.setNumber("num")
|
||||||
.setRecipient(new IZUGFeRDExportableContactImpl()
|
.setRecipient(new IZUGFeRDExportableContactImpl()
|
||||||
.setName("recipient name")
|
.setName("recipient name")
|
||||||
.setStreet("recipient street")
|
.setStreet("recipient street")
|
||||||
.setLocation("recipient city")
|
.setLocation("recipient city")
|
||||||
.setCountry("recipient country")
|
.setCountry("recipient country")
|
||||||
)
|
)
|
||||||
.setOwnOrganisationName("own org")
|
.setOwnOrganisationName("own org")
|
||||||
.setOwnStreet("own street")
|
.setOwnStreet("own street")
|
||||||
.setOwnCountry("own country")
|
.setOwnCountry("own country")
|
||||||
.setOwnLocation("own city")
|
.setOwnLocation("own city")
|
||||||
.setOwnBankName("own bank")
|
.setOwnBankName("own bank")
|
||||||
.setZFItems(
|
.setZFItems(
|
||||||
new IZUGFeRDExportableItemImpl()
|
new IZUGFeRDExportableItemImpl()
|
||||||
.setProduct(new IZUGFeRDExportableProductImpl()
|
.setProduct(new IZUGFeRDExportableProductImpl()
|
||||||
.setVatPercent(new BigDecimal("1.19"))
|
.setVatPercent(new BigDecimal("1.19"))
|
||||||
.setName("product name")
|
.setName("product name")
|
||||||
.setDescription("product description")
|
.setDescription("product description")
|
||||||
.setUnit("product unit")
|
.setUnit("product unit")
|
||||||
)
|
)
|
||||||
.setQuantity(BigDecimal.ONE)
|
.setQuantity(BigDecimal.ONE)
|
||||||
.setPrice(BigDecimal.TEN)
|
.setPrice(BigDecimal.TEN)
|
||||||
);
|
);
|
||||||
|
|
||||||
// execution
|
// execution
|
||||||
final JAXBElement<CrossIndustryDocumentType> actual =
|
final JAXBElement<CrossIndustryDocumentType> actual =
|
||||||
new ZUGFeRDTransactionModelConverter(transaction).convertToModel();
|
new ZUGFeRDTransactionModelConverter(transaction).convertToModel();
|
||||||
|
|
||||||
// evaluation
|
// evaluation
|
||||||
ZUGFeRDXMLAssert.assertValidZugferd(actual);
|
ZUGFeRDXMLAssert.assertValidZugferd(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Date createDate(int year, int month, int day) {
|
private static Date createDate(int year, int month, int day) {
|
||||||
final GregorianCalendar calendar = new GregorianCalendar();
|
final GregorianCalendar calendar = new GregorianCalendar();
|
||||||
calendar.set(year, month-1, day);
|
calendar.set(year, month - 1, day);
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,27 +30,27 @@ import javax.xml.bind.JAXBElement;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
public class ZUGFeRDXMLAssert {
|
public class ZUGFeRDXMLAssert {
|
||||||
private static final ISchematronResource SCHEMATRON = loadSchematron();
|
private static final ISchematronResource SCHEMATRON = loadSchematron();
|
||||||
|
|
||||||
public static void assertValidZugferd(JAXBElement<CrossIndustryDocumentType> xml) throws Exception {
|
public static void assertValidZugferd(JAXBElement<CrossIndustryDocumentType> xml) throws Exception {
|
||||||
assertValidZugferd(toDocument(xml));
|
assertValidZugferd(toDocument(xml));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertValidZugferd(Node xml) throws Exception {
|
public static void assertValidZugferd(Node xml) throws Exception {
|
||||||
Assert.assertTrue("schema valid", SCHEMATRON.getSchematronValidity(xml, null).isValid());
|
Assert.assertTrue("schema valid", SCHEMATRON.getSchematronValidity(xml, null).isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Document toDocument(Object jaxbElement) throws Exception {
|
private static Document toDocument(Object jaxbElement) throws Exception {
|
||||||
final Document result = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
final Document result = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||||
JAXBContext.newInstance("org.mustangproject.ZUGFeRD.model").createMarshaller().marshal(jaxbElement, result);
|
JAXBContext.newInstance("org.mustangproject.ZUGFeRD.model").createMarshaller().marshal(jaxbElement, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SchematronResourcePure loadSchematron() {
|
private static SchematronResourcePure loadSchematron() {
|
||||||
final SchematronResourcePure result = SchematronResourcePure.fromClassPath("/ZUGFeRD_1p0.scmt");
|
final SchematronResourcePure result = SchematronResourcePure.fromClassPath("/ZUGFeRD_1p0.scmt");
|
||||||
if (!result.isValidSchematron ()) {
|
if (!result.isValidSchematron()) {
|
||||||
throw new IllegalArgumentException("Invalid Schematron!");
|
throw new IllegalArgumentException("Invalid Schematron!");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user