use .editorconfig for java

This commit is contained in:
Andre Kemper
2019-04-06 22:05:23 +02:00
parent d67a3058f3
commit a1732f4833
48 changed files with 4207 additions and 4208 deletions

View File

@@ -19,5 +19,5 @@
package org.mustangproject.ZUGFeRD;
public final class Version {
public static final String VERSION = "${project.version}";
public static final String VERSION = "${project.version}";
}

View File

@@ -28,12 +28,12 @@ public class CustomXMLProvider implements IXMLProvider {
}
public void setXML(byte[] newData) {
String zf=new String(newData);
String zf = new String(newData);
if (!zf.contains("<rsm:CrossIndustry")) {
throw new RuntimeException("ZUGFeRD XML does not contain <rsm:CrossIndustry and can thus not be valid");
}
zugferdData=newData;
zugferdData = newData;
}
@Override

View File

@@ -23,29 +23,34 @@ import java.io.InputStream;
public interface IExporterFactory {
public ZUGFeRDExporter load(String pdfFilename) throws IOException;
/**
* 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)
*
* @param pdfBinary
* binary of a PDF/A1 compliant document
* @param pdfBinary binary of a PDF/A1 compliant document
*/
public ZUGFeRDExporter load(byte[] pdfBinary) throws IOException;
/**
* 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)
*
* @param pdfSource
* source to read a PDF/A1 compliant document from
* @param pdfSource source to read a PDF/A1 compliant document from
* @throws IOException
*/
public ZUGFeRDExporter load(InputStream pdfSource) throws IOException;
public IExporterFactory setCreator(String creator);
public IExporterFactory setConformanceLevel(PDFAConformanceLevel newLevel);
public IExporterFactory setProducer(String producer) ;
public IExporterFactory setProducer(String producer);
public IExporterFactory setZUGFeRDVersion(int version);
public IExporterFactory ignorePDFAErrors();
public IExporterFactory setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel zugferdConformanceLevel);
}

View File

@@ -21,6 +21,7 @@ package org.mustangproject.ZUGFeRD;
public interface IXMLProvider {
public byte[] getXML();
public void setTest();
public void generateXML(IZUGFeRDExportableTransaction trans);

View File

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

View File

@@ -17,50 +17,58 @@
*
*********************************************************************** */
package org.mustangproject.ZUGFeRD;
/**
* Mustangproject's ZUGFeRD implementation
* Neccessary interface for ZUGFeRD exporter
* Licensed under the APLv2
* @date 2014-05-10
* @version 1.2.0
*
* @author jstaerk
* */
* @version 1.2.0
* @date 2014-05-10
*/
public interface IZUGFeRDExportableContact {
/**
* First and last name of the recipient
*
* @return First and last name of the recipient
*/
String getName();
/**
* Postal code of the recipient
*
* @return Postal code of the recipient
*/
String getZIP();
/**
* VAT ID (Umsatzsteueridentifikationsnummer) of the contact
*
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the contact
*/
String getVATID();
/**
* two-letter country code of the contact
*
* @return two-letter iso country code of the contact
*/
String getCountry();
/***
/**
* Returns the city of the contact
*
* @return Returns the city of the recipient
*/
String getLocation();
/***
/**
* Returns the street address (street+number) of the contact
*
* @return street address (street+number) of the contact
*/
String getStreet();

View File

@@ -31,22 +31,25 @@ import java.math.BigDecimal;
public interface IZUGFeRDExportableItem {
IZUGFeRDExportableProduct getProduct();
IZUGFeRDAllowanceCharge[] getItemAllowances();
IZUGFeRDAllowanceCharge[] getItemCharges();
IZUGFeRDAllowanceCharge[] getItemAllowances();
IZUGFeRDAllowanceCharge[] getItemCharges();
/**
* The price of one item excl. taxes
*
* @return The price of one item excl. taxes
*/
BigDecimal getPrice();
/***
/**
* how many
*
* @return the quantity of the item
*/
BigDecimal getQuantity();
}

View File

@@ -17,61 +17,67 @@
*
*********************************************************************** */
package org.mustangproject.ZUGFeRD;
import java.math.BigDecimal;
/**
* Mustangproject's ZUGFeRD implementation
* Necessary interface for ZUGFeRD exporter
* Licensed under the APLv2
* @date 2014-05-10
* @version 1.2.0
*
* @author jstaerk
* */
* @version 1.2.0
* @date 2014-05-10
*/
public interface IZUGFeRDExportableProduct {
/**
* Unit code of the product
* Most common ones are
C62 one (piece)
DAY day
HAR hectare
HUR hour
KGM kilogram
KTM kilometre
KWH kilowatt hour
LS lump sum
LTR litre
MIN minute
MMK square millimetre
MMT millimetre
MTK square metre
MTQ cubic metre
MTR metre
NAR number of articles
NPR number of pairs
P1 percent
SET set
TNE tonne (metric ton)
WEE week
* C62 one (piece)
* DAY day
* HAR hectare
* HUR hour
* KGM kilogram
* KTM kilometre
* KWH kilowatt hour
* LS lump sum
* LTR litre
* MIN minute
* MMK square millimetre
* MMT millimetre
* MTK square metre
* MTQ cubic metre
* MTR metre
* NAR number of articles
* NPR number of pairs
* P1 percent
* SET set
* TNE tonne (metric ton)
* WEE week
*
* @return a UN/ECE rec 20 unit code see https://www.unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex2e.pdf
*/
String getUnit();
/**
* Short name of the product
*
* @return Short name of the product
*/
String getName();
/**
* long description of the product
*
* @return long description of the product
*/
String getDescription();
/**
* VAT percent of the product (e.g. 19, or 5.1 if you like)
*
* @return VAT percent of the product
*/
BigDecimal getVATPercent();

View File

@@ -27,19 +27,20 @@ package org.mustangproject.ZUGFeRD;
* */
import java.util.Date;
public interface IZUGFeRDExportableTransaction {
/**
* Number, typically invoice number of the invoice
*
* @return invoice number
*/
String getNumber();
/**
* the date when the invoice was created
*
* @return when the invoice was created
*/
Date getIssueDate();
@@ -48,138 +49,160 @@ public interface IZUGFeRDExportableTransaction {
* this should be the full sender institution name, details, manager and tax registration.
* It is one of the few functions which may return null.
* e.g.
* <p/>
* 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
*/
String getOwnOrganisationFullPlaintextInfo();
/**
* when the invoice is to be paid
*
* @return when the invoice is to be paid
*/
Date getDueDate();
IZUGFeRDAllowanceCharge[] getZFAllowances();
IZUGFeRDAllowanceCharge[] getZFCharges();
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
IZUGFeRDAllowanceCharge[] getZFAllowances();
IZUGFeRDAllowanceCharge[] getZFCharges();
IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges();
IZUGFeRDExportableItem[] getZFItems();
/***
/**
* the recipient
*
* @return the recipient of the invoice
*/
IZUGFeRDExportableContact getRecipient();
/***
/**
* BIC of the sender
*
* @return the BIC code of the recipient sender's bank
*/
String getOwnBIC();
/***
* BLZ of the sender
* @return the BLZ code of the recipient sender's bank
*/
String getOwnBLZ();
/**
* BLZ of the sender
*
* @return the BLZ code of the recipient sender's bank
*/
String getOwnBLZ();
/***
/**
* Bank name of the sender
*
* @return the name of the sender's bank
*/
String getOwnBankName();
/**
* 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();
/**
* IBAN of the sender
* @return the Account Number of the invoice sender's bank account
*/
String getOwnKto();
/**
* IBAN of the sender
*
* @return the Account Number of the invoice sender's bank account
*/
String getOwnKto();
/**
/**
* 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();
/**
* VAT ID (Umsatzsteueridentifikationsnummer) of the sender
*
* @return VAT ID (Umsatzsteueridentifikationsnummer) of the sender
*/
String getOwnVATID();
/**
* own name
*
* @return the sender's organisation name
*/
String getOwnOrganisationName();
/**
* own street address
*
* @return sender street address
*/
String getOwnStreet();
/**
* own street postal code
*
* @return sender postal code
*/
String getOwnZIP();
/**
* own city
*
* @return the invoice sender's city
*/
String getOwnLocation();
/**
* own two digit country code
*
* @return the invoice senders two character country iso code
*/
String getOwnCountry();
/**
* get delivery date
*
* @return the day the goods have been delivered
*/
Date getDeliveryDate();
/**
/**
* get main invoice currency used on the invoice
*
* @return three character currency of this invoice
*/
String getCurrency();
String getCurrency();
/**
/**
* get payment information text. e.g. Bank transfer
*
* @return payment information text
*/
String getOwnPaymentInfoText();
String getOwnPaymentInfoText();
/**
/**
* 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
*/
String getPaymentTermDescription();
String getPaymentTermDescription();
/**
* get reference document number
* typically used for Invoice Corrections
* Will be added as IncludedNote in comfort profile
* @return the ID of the document this document refers to
*/
String getReferenceNumber();
/**
* get reference document number
* typically used for Invoice Corrections
* Will be added as IncludedNote in comfort profile
*
* @return the ID of the document this document refers to
*/
String getReferenceNumber();
}

View File

@@ -19,24 +19,24 @@
package org.mustangproject.ZUGFeRD;
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) {
this.letter = letter;
}
PDFAConformanceLevel(String letter) {
this.letter = letter;
}
public String getLetter() {
return letter;
}
public String getLetter() {
return letter;
}
public static PDFAConformanceLevel findByLetter(String letter) {
for (PDFAConformanceLevel candidate : values()) {
if (candidate.letter.equals(letter)) {
return candidate;
}
}
throw new IllegalArgumentException("PDF conformance level <" + letter + "> is unknown.");
}
public static PDFAConformanceLevel findByLetter(String letter) {
for (PDFAConformanceLevel candidate : values()) {
if (candidate.letter.equals(letter)) {
return candidate;
}
}
throw new IllegalArgumentException("PDF conformance level <" + letter + "> is unknown.");
}
}

View File

@@ -19,46 +19,48 @@
package org.mustangproject.ZUGFeRD;
import java.math.BigDecimal;
/**
* Mustangproject's ZUGFeRD implementation
* ZUGFeRD exporter helper class
* Licensed under the APLv2
* @date 2015-10-29
* @version 1.2.0
*
* @author jstaerk
* */
* @version 1.2.0
* @date 2015-10-29
*/
public class VATAmount {
public VATAmount(BigDecimal basis, BigDecimal calculated) {
super();
this.basis = basis;
this.calculated = calculated;
}
public VATAmount(BigDecimal basis, BigDecimal calculated) {
super();
this.basis = basis;
this.calculated = calculated;
}
BigDecimal basis, calculated;
BigDecimal basis, calculated;
public BigDecimal getBasis() {
return basis;
}
public BigDecimal getBasis() {
return basis;
}
public void setBasis(BigDecimal basis) {
this.basis = basis;
}
public void setBasis(BigDecimal basis) {
this.basis = basis;
}
public BigDecimal getCalculated() {
return calculated;
}
public BigDecimal getCalculated() {
return calculated;
}
public void setCalculated(BigDecimal calculated) {
this.calculated = calculated;
}
public void setCalculated(BigDecimal calculated) {
this.calculated = calculated;
}
public VATAmount add(VATAmount v) {
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()));
}
public VATAmount add(VATAmount v) {
return new VATAmount(basis.add(v.getBasis()), calculated.add(v.getCalculated()));
}
public VATAmount subtract(VATAmount v) {
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()));
}
public VATAmount subtract(VATAmount v) {
return new VATAmount(basis.subtract(v.getBasis()), calculated.subtract(v.getCalculated()));
}
}

View File

@@ -55,13 +55,13 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
protected void setZUGFeRDVersion(int ver) {
namespace=ZUGFeRDExporter.getNamespaceForVersion(ver);
prefix=ZUGFeRDExporter.getPrefixForVersion(ver);
namespace = ZUGFeRDExporter.getNamespaceForVersion(ver);
prefix = ZUGFeRDExporter.getPrefixForVersion(ver);
}
private DefinedStructuredType addProperty(ArrayProperty parent, String name, String type, String category,
String description) {
String description) {
XMPMetadata metadata = getMetadata();
DefinedStructuredType li = new DefinedStructuredType(metadata, getNamespace(), getPrefix(),
@@ -133,4 +133,4 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
"The selected ZUGFeRD profile completeness");
}
}
}
}

View File

@@ -25,28 +25,29 @@ package org.mustangproject.ZUGFeRD;
* @version 1.2.0s
* @author jstaerk
* */
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.schema.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
*/
public XMPSchemaZugferd(XMPMetadata metadata, ZUGFeRDConformanceLevel conformanceLevel, String URN, String prefix, String filename) {
super(metadata, URN, prefix, "ZUGFeRD Schema");
/**
* 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) {
super(metadata, URN, prefix, "ZUGFeRD Schema");
setAboutAsSimple("");
setAboutAsSimple("");
String conformanceLevelValue=conformanceLevel.name();
if (conformanceLevelValue.equals("BASICWL")) {
conformanceLevelValue="BASIC WL";
} else if (conformanceLevelValue.equals("EN16931")) {
conformanceLevelValue="EN 16931";
}
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
setTextPropertyValue("DocumentType", "INVOICE");
setTextPropertyValue("DocumentFileName", filename);
setTextPropertyValue("Version", "1.0");
}
String conformanceLevelValue = conformanceLevel.name();
if (conformanceLevelValue.equals("BASICWL")) {
conformanceLevelValue = "BASIC WL";
} else if (conformanceLevelValue.equals("EN16931")) {
conformanceLevelValue = "EN 16931";
}
setTextPropertyValue("ConformanceLevel", conformanceLevelValue);
setTextPropertyValue("DocumentType", "INVOICE");
setTextPropertyValue("DocumentFileName", filename);
setTextPropertyValue("Version", "1.0");
}
}

View File

@@ -36,14 +36,13 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
private boolean isTest;
/**
* enables the flag to indicate a test invoice in the XML structure
*
*/
public void setTest() {
isTest = true;
}
public ZUGFeRD1PullProvider() {
// TODO Auto-generated constructor stub
try {
@@ -51,16 +50,16 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new ZFNamespacePrefixMapper());
} catch (JAXBException e) {
throw new ZUGFeRDExportException("Could not initialize JAXB", e);
}
} catch (JAXBException e) {
throw new ZUGFeRDExportException("Could not initialize JAXB", e);
}
}
private String createZugferdXMLForTransaction(IZUGFeRDExportableTransaction trans) {
JAXBElement<CrossIndustryDocumentType> jaxElement =
new ZUGFeRDTransactionModelConverter(trans).withTest(isTest).convertToModel();
new ZUGFeRDTransactionModelConverter(trans).withTest(isTest).convertToModel();
try {
return marshalJaxToXMLString(jaxElement);
@@ -84,23 +83,22 @@ public class ZUGFeRD1PullProvider implements IXMLProvider {
@Override
public void generateXML(IZUGFeRDExportableTransaction trans) {
// create a dummy file stream, this would probably normally be a
// FileInputStream
// create a dummy file stream, this would probably normally be a
// FileInputStream
byte[] zugferdRaw = createZugferdXMLForTransaction(trans).getBytes(); //$NON-NLS-1$
byte[] zugferdRaw = createZugferdXMLForTransaction(trans).getBytes(); //$NON-NLS-1$
if ((zugferdRaw[0] == (byte) 0xEF)
&& (zugferdRaw[1] == (byte) 0xBB)
&& (zugferdRaw[2] == (byte) 0xBF)) {
// I don't like BOMs, lets remove it
zugferdData = new byte[zugferdRaw.length - 3];
System.arraycopy(zugferdRaw, 3, zugferdData, 0,
zugferdRaw.length - 3);
} else {
zugferdData = zugferdRaw;
}
if ((zugferdRaw[0] == (byte) 0xEF)
&& (zugferdRaw[1] == (byte) 0xBB)
&& (zugferdRaw[2] == (byte) 0xBF)) {
// I don't like BOMs, lets remove it
zugferdData = new byte[zugferdRaw.length - 3];
System.arraycopy(zugferdRaw, 3, zugferdData, 0,
zugferdRaw.length - 3);
} else {
zugferdData = zugferdRaw;
}
}
}

View File

@@ -29,18 +29,18 @@ import java.util.HashMap;
public class ZUGFeRD2PullProvider implements IXMLProvider {
private class LineCalc {
private IZUGFeRDExportableItem currentItem=null;
private IZUGFeRDExportableItem currentItem = null;
private BigDecimal totalGross;
private BigDecimal itemTotalNetAmount;
private BigDecimal itemTotalVATAmount;
public LineCalc(IZUGFeRDExportableItem currentItem) {
this.currentItem=currentItem;
BigDecimal multiplicator=currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
this.currentItem = currentItem;
BigDecimal multiplicator = currentItem.getProduct().getVATPercent().divide(new BigDecimal(100)).add(new BigDecimal(1));
// priceGross=currentItem.getPrice().multiply(multiplicator);
totalGross=currentItem.getPrice().multiply(multiplicator).multiply(currentItem.getQuantity());
itemTotalNetAmount=currentItem.getQuantity().multiply(currentItem.getPrice()).setScale(2,BigDecimal.ROUND_HALF_UP);
itemTotalVATAmount=totalGross.subtract(itemTotalNetAmount);
totalGross = currentItem.getPrice().multiply(multiplicator).multiply(currentItem.getQuantity());
itemTotalNetAmount = currentItem.getQuantity().multiply(currentItem.getPrice()).setScale(2, BigDecimal.ROUND_HALF_UP);
itemTotalVATAmount = totalGross.subtract(itemTotalNetAmount);
}
public BigDecimal getItemTotalNetAmount() {
@@ -54,7 +54,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
}
//// MAIN CLASS
protected byte[] zugferdData;
@@ -63,7 +62,6 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
/**
* enables the flag to indicate a test invoice in the XML structure
*
*/
public void setTest() {
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
*/
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];
Arrays.fill(repeat, '0');
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols();
otherSymbols.setDecimalSeparator('.');
DecimalFormat dec = new DecimalFormat("0."+new String(repeat), otherSymbols);
DecimalFormat dec = new DecimalFormat("0." + new String(repeat), otherSymbols);
return dec.format(value);
}
@@ -118,6 +116,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
private String priceFormat(BigDecimal value) {
return nDigitFormat(value, 4);
}
private String quantityFormat(BigDecimal value) {
return nDigitFormat(value, 4);
}
@@ -129,11 +128,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
private BigDecimal getTotalGross() {
BigDecimal res=getTotal();
HashMap<BigDecimal, VATAmount> VATPercentAmountMap=getVATPercentAmountMap();
BigDecimal res = getTotal();
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
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() {
BigDecimal res=new BigDecimal(0);
BigDecimal res = new BigDecimal(0);
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
LineCalc lc=new LineCalc(currentItem);
res=res.add(lc.getItemTotalNetAmount());
LineCalc lc = new LineCalc(currentItem);
res = res.add(lc.getItemTotalNetAmount());
}
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
* to 19% VAT (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT)
* 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() {
HashMap<BigDecimal, VATAmount> hm=new HashMap<BigDecimal, VATAmount> ();
HashMap<BigDecimal, VATAmount> hm = new HashMap<BigDecimal, VATAmount>();
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
BigDecimal percent=currentItem.getProduct().getVATPercent();
LineCalc lc=new LineCalc(currentItem);
VATAmount itemVATAmount=new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount() ) ;
VATAmount current=hm.get(percent);
if (current==null) {
BigDecimal percent = currentItem.getProduct().getVATPercent();
LineCalc lc = new LineCalc(currentItem);
VATAmount itemVATAmount = new VATAmount(lc.getItemTotalNetAmount(), lc.getItemTotalVATAmount());
VATAmount current = hm.get(percent);
if (current == null) {
hm.put(percent, itemVATAmount);
} else {
hm.put(percent, current.add(itemVATAmount));
@@ -180,17 +179,17 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
@Override
public void generateXML(IZUGFeRDExportableTransaction trans) {
this.trans=trans;
this.trans = trans;
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy"); //$NON-NLS-1$
SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
String testBooleanStr="false";
String testBooleanStr = "false";
if (isTest) {
testBooleanStr="true";
testBooleanStr = "true";
}
String senderReg="";
if (trans.getOwnOrganisationFullPlaintextInfo()!=null) {
senderReg=""
String senderReg = "";
if (trans.getOwnOrganisationFullPlaintextInfo() != null) {
senderReg = ""
+ "<ram:IncludedCINote>\n"
+ " <ram:Content>\n"
+ 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\""
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\""
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" //$NON-NLS-1$
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
+ " xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\""
+ " xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" //$NON-NLS-1$
+ " <rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
// + " <ram:TestIndicator><udt:Indicator>"+testBooleanStr+"</udt:Indicator></ram:TestIndicator>\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:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
+ " <ram:ID>"+trans.getNumber()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " <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:GuidelineSpecifiedDocumentContextParameter>\n" //$NON-NLS-1$
+ " </rsm:ExchangedDocumentContext>\n" //$NON-NLS-1$
+ " <rsm:ExchangedDocument>\n" //$NON-NLS-1$
+ " <ram:ID>" + trans.getNumber() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
// + " <ram:Name>RECHNUNG</ram:Name>\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$
+ senderReg
+ " <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$
+ senderReg
// + " <IncludedNote>\n"
// + " <Content>\n"
// + "Rechnung gemäß Bestellung Nr. 2013-471331 vom 01.03.2013.\n"
@@ -232,145 +230,142 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
// + " </Content>\n"
// + " <SubjectCode>AAK</SubjectCode>\n"
// + " </IncludedNote>\n"
+ " </rsm:ExchangedDocument>\n" //$NON-NLS-1$
+ " <rsm:SupplyChainTradeTransaction>\n"; //$NON-NLS-1$
int lineID=0;
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
lineID++;
+ " </rsm:ExchangedDocument>\n" //$NON-NLS-1$
+ " <rsm:SupplyChainTradeTransaction>\n"; //$NON-NLS-1$
int lineID = 0;
for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) {
lineID++;
LineCalc lc=new LineCalc(currentItem);
xml=xml+ " <ram:IncludedSupplyChainTradeLineItem>\n"+ //$NON-NLS-1$
" <ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
+ " <ram:LineID>"+lineID+"</ram:LineID>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
+ " <ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
LineCalc lc = new LineCalc(currentItem);
xml = xml + " <ram:IncludedSupplyChainTradeLineItem>\n" + //$NON-NLS-1$
" <ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
+ " <ram:LineID>" + lineID + "</ram:LineID>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:AssociatedDocumentLineDocument>\n" //$NON-NLS-1$
+ " <ram:SpecifiedTradeProduct>\n" //$NON-NLS-1$
// + " <GlobalID schemeID=\"0160\">4012345001235</GlobalID>\n"
// + " <SellerAssignedID>KR3M</SellerAssignedID>\n"
// + " <BuyerAssignedID>55T01</BuyerAssignedID>\n"
+ " <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:SpecifiedTradeProduct>\n" //$NON-NLS-1$
+ " <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:SpecifiedTradeProduct>\n" //$NON-NLS-1$
+ " <ram:SpecifiedLineTradeAgreement>\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:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " <ram:SpecifiedLineTradeAgreement>\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:BasisQuantity unitCode=\"" + currentItem.getProduct().getUnit() + "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
// + " <AppliedTradeAllowanceCharge>\n"
// + " <ChargeIndicator>false</ChargeIndicator>\n"
// + " <ActualAmount currencyID=\"EUR\">0.6667</ActualAmount>\n"
// + " <Reason>Rabatt</Reason>\n"
// + " </AppliedTradeAllowanceCharge>\n"
+ " </ram:GrossPriceProductTradePrice>\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:BasisQuantity unitCode=\""+currentItem.getProduct().getUnit()+"\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
+ " </ram:SpecifiedLineTradeAgreement>\n" //$NON-NLS-1$
+ " </ram:GrossPriceProductTradePrice>\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:BasisQuantity unitCode=\"" + currentItem.getProduct().getUnit() + "\">1.0000</ram:BasisQuantity>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:NetPriceProductTradePrice>\n" //$NON-NLS-1$
+ " </ram:SpecifiedLineTradeAgreement>\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:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
+ " <ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
+ " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
+ " <ram:TypeCode>VAT</ram:TypeCode>\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:ApplicableTradeTax>\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:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
+ " </ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
+ " </ram:IncludedSupplyChainTradeLineItem>\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:SpecifiedLineTradeDelivery>\n" //$NON-NLS-1$
+ " <ram:SpecifiedLineTradeSettlement>\n" //$NON-NLS-1$
+ " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
+ " <ram:TypeCode>VAT</ram:TypeCode>\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:ApplicableTradeTax>\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:SpecifiedTradeSettlementLineMonetarySummation>\n" //$NON-NLS-1$
+ " </ram:SpecifiedLineTradeSettlement>\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"
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
+ " <ram:SellerTradeParty>\n" //$NON-NLS-1$
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
+ " <ram:Name>"+trans.getOwnOrganisationName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " <ram:PostalTradeAddress>\n"
+ " <ram:PostcodeCode>"+trans.getOwnZIP()+"</ram:PostcodeCode>\n"
+ " <ram:LineOne>"+trans.getOwnStreet()+"</ram:LineOne>\n"
+ " <ram:CityName>"+trans.getOwnLocation()+"</ram:CityName>\n"
+ " <ram:CountryID>"+trans.getOwnCountry()+"</ram:CountryID>\n"
+ " </ram:PostalTradeAddress>\n"
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
+ " <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:ID schemeID=\"VA\">"+trans.getOwnVATID()+"</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
+ " </ram:SellerTradeParty>\n" //$NON-NLS-1$
+ " <ram:BuyerTradeParty>\n" //$NON-NLS-1$
+ " <ram:Name>" + trans.getOwnOrganisationName() + "</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " <ram:PostalTradeAddress>\n"
+ " <ram:PostcodeCode>" + trans.getOwnZIP() + "</ram:PostcodeCode>\n"
+ " <ram:LineOne>" + trans.getOwnStreet() + "</ram:LineOne>\n"
+ " <ram:CityName>" + trans.getOwnLocation() + "</ram:CityName>\n"
+ " <ram:CountryID>" + trans.getOwnCountry() + "</ram:CountryID>\n"
+ " </ram:PostalTradeAddress>\n"
+ " <ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
+ " <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:ID schemeID=\"VA\">" + trans.getOwnVATID() + "</ram:ID>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
+ " </ram:SellerTradeParty>\n" //$NON-NLS-1$
+ " <ram:BuyerTradeParty>\n" //$NON-NLS-1$
// + " <ID>GE2020211</ID>\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"
// + " <PersonName>xxx</PersonName>\n"
// + " </DefinedTradeContact>\n"
+ " <ram:PostalTradeAddress>\n" //$NON-NLS-1$
+ " <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: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:PostalTradeAddress>\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:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
+ " </ram:BuyerTradeParty>\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: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:CountryID>" + trans.getRecipient().getCountry() + "</ram:CountryID>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:PostalTradeAddress>\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:SpecifiedTaxRegistration>\n" //$NON-NLS-1$
+ " </ram:BuyerTradeParty>\n" //$NON-NLS-1$
// + " <BuyerOrderReferencedDocument>\n"
// + " <IssueDateTime format=\"102\">20130301</IssueDateTime>\n"
// + " <ID>2013-471331</ID>\n"
// + " </BuyerOrderReferencedDocument>\n"
+ " </ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
+ " <ram:ApplicableHeaderTradeDelivery>\n"
+ " <ram:ActualDeliverySupplyChainEvent>\n"
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">"+zugferdDateFormat.format(trans.getDeliveryDate())+"</udt:DateTimeString></ram:OccurrenceDateTime>\n"
+ " </ram:ActualDeliverySupplyChainEvent>\n"
+ " </ram:ApplicableHeaderTradeAgreement>\n" //$NON-NLS-1$
+ " <ram:ApplicableHeaderTradeDelivery>\n"
+ " <ram:ActualDeliverySupplyChainEvent>\n"
+ " <ram:OccurrenceDateTime><udt:DateTimeString format=\"102\">" + zugferdDateFormat.format(trans.getDeliveryDate()) + "</udt:DateTimeString></ram:OccurrenceDateTime>\n"
+ " </ram:ActualDeliverySupplyChainEvent>\n"
/*
+ " <DeliveryNoteReferencedDocument>\n"
+ " <IssueDateTime format=\"102\">20130603</IssueDateTime>\n"
+ " <ID>2013-51112</ID>\n"
+ " </DeliveryNoteReferencedDocument>\n" */
+ " </ram:ApplicableHeaderTradeDelivery>\n"
+ " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-1$
+ " <ram:PaymentReference>"+trans.getNumber()+"</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
+ " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$
+ " <ram:TypeCode>42</ram:TypeCode>\n" //$NON-NLS-1$
+ " <ram:Information>Überweisung</ram:Information>\n" //$NON-NLS-1$
+ " <ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
+ " <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:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
+ " <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:ApplicableHeaderTradeDelivery>\n"
+ " <ram:ApplicableHeaderTradeSettlement>\n" //$NON-NLS-1$
+ " <ram:PaymentReference>" + trans.getNumber() + "</ram:PaymentReference>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " <ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>\n" //$NON-NLS-1$
+ " <ram:SpecifiedTradeSettlementPaymentMeans>\n" //$NON-NLS-1$
+ " <ram:TypeCode>42</ram:TypeCode>\n" //$NON-NLS-1$
+ " <ram:Information>Überweisung</ram:Information>\n" //$NON-NLS-1$
+ " <ram:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
+ " <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:PayeePartyCreditorFinancialAccount>\n" //$NON-NLS-1$
+ " <ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
+ " <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:Name>"+trans.getOwnBankName()+"</ram:Name>\n" //$NON-NLS-1$ //$NON-NLS-2$
+ " </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
+ " </ram:SpecifiedTradeSettlementPaymentMeans>\n"; //$NON-NLS-1$
+ " </ram:PayeeSpecifiedCreditorFinancialInstitution>\n" //$NON-NLS-1$
+ " </ram:SpecifiedTradeSettlementPaymentMeans>\n"; //$NON-NLS-1$
HashMap<BigDecimal, VATAmount> VATPercentAmountMap=getVATPercentAmountMap();
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
if (amount != null) {
xml += " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
+ " <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:BasisAmount>"+currencyFormat(amount.getBasis())+"</ram:BasisAmount>\n" // currencyID=\"EUR\"
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
+ " <ram:RateApplicablePercent>"+vatFormat(currentTaxPercent)+"</ram:RateApplicablePercent>\n" //$NON-NLS-1$
+ " </ram:ApplicableTradeTax>\n"; //$NON-NLS-1$
HashMap<BigDecimal, VATAmount> VATPercentAmountMap = getVATPercentAmountMap();
for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) {
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
if (amount != null) {
xml += " <ram:ApplicableTradeTax>\n" //$NON-NLS-1$
+ " <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:BasisAmount>" + currencyFormat(amount.getBasis()) + "</ram:BasisAmount>\n" // currencyID=\"EUR\"
+ " <ram:CategoryCode>S</ram:CategoryCode>\n" //$NON-NLS-1$
+ " <ram:RateApplicablePercent>" + vatFormat(currentTaxPercent) + "</ram:RateApplicablePercent>\n" //$NON-NLS-1$
+ " </ram:ApplicableTradeTax>\n"; //$NON-NLS-1$
}
}
}
/* xml+= "
+ " <SpecifiedTradeAllowanceCharge>\n"
+ " <ChargeIndicator>false</ChargeIndicator>\n"
@@ -404,23 +399,23 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
+ " </AppliedTradeTax>\n"
+ " </SpecifiedLogisticsServiceCharge>\n"*/
xml=xml+ " <ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
+ " <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:SpecifiedTradePaymentTerms>\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:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\n" //$NON-NLS-1$ currencyID=\"EUR\"
+ " <ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>\n" //$NON-NLS-1$ // currencyID=\"EUR\"
xml = xml + " <ram:SpecifiedTradePaymentTerms>\n" //$NON-NLS-1$
+ " <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:SpecifiedTradePaymentTerms>\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:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>\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"
// + " <AllowanceTotalAmount currencyID=\"EUR\">14.73</AllowanceTotalAmount>\n"
+ " <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:GrandTotalAmount>"+currencyFormat(getTotalGross())+"</ram:GrandTotalAmount>\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:GrandTotalAmount>" + currencyFormat(getTotalGross()) + "</ram:GrandTotalAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
// + " <TotalPrepaidAmount currencyID=\"EUR\">0.00</TotalPrepaidAmount>\n"
+ " <ram:DuePayableAmount>"+currencyFormat(getTotalGross())+"</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
+ " </ram:ApplicableHeaderTradeSettlement>\n"; //$NON-NLS-1$
+ " <ram:DuePayableAmount>" + currencyFormat(getTotalGross()) + "</ram:DuePayableAmount>\n" //$NON-NLS-1$ //$NON-NLS-2$ // currencyID=\"EUR\"
+ " </ram:SpecifiedTradeSettlementHeaderMonetarySummation>\n" //$NON-NLS-1$
+ " </ram:ApplicableHeaderTradeSettlement>\n"; //$NON-NLS-1$
// + " <IncludedSupplyChainTradeLineItem>\n"
// + " <AssociatedDocumentLineDocument>\n"
// + " <IncludedNote>\n"
@@ -430,26 +425,24 @@ public class ZUGFeRD2PullProvider implements IXMLProvider {
// + " </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$
+ "</rsm:CrossIndustryInvoice>"; //$NON-NLS-1$
byte[] zugferdRaw;
try {
zugferdRaw = xml.getBytes("UTF-8");
if ((zugferdRaw[0]==(byte)0xEF)&&(zugferdRaw[1]==(byte)0xBB)&&(zugferdRaw[2]==(byte)0xBF)) {
// I don't like BOMs, lets remove it
zugferdData=new byte[zugferdRaw.length-3];
System.arraycopy(zugferdRaw,3,zugferdData,0,zugferdRaw.length-3);
} else {
zugferdData=zugferdRaw;
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //$NON-NLS-1$
if ((zugferdRaw[0] == (byte) 0xEF) && (zugferdRaw[1] == (byte) 0xBB) && (zugferdRaw[2] == (byte) 0xBF)) {
// I don't like BOMs, lets remove it
zugferdData = new byte[zugferdRaw.length - 3];
System.arraycopy(zugferdRaw, 3, zugferdData, 0, zugferdRaw.length - 3);
} else {
zugferdData = zugferdRaw;
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //$NON-NLS-1$
}
}

View File

@@ -19,6 +19,5 @@
package org.mustangproject.ZUGFeRD;
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;
}

View File

@@ -19,23 +19,23 @@
package org.mustangproject.ZUGFeRD;
public class ZUGFeRDExportException extends RuntimeException {
/**
/**
*
*/
private static final long serialVersionUID = 1L;
public ZUGFeRDExportException() {
}
}
public ZUGFeRDExportException(String message) {
super(message);
}
public ZUGFeRDExportException(String message) {
super(message);
}
public ZUGFeRDExportException(String message, Throwable cause) {
super(message, cause);
}
public ZUGFeRDExportException(String message, Throwable cause) {
super(message, cause);
}
public ZUGFeRDExportException(Throwable cause) {
super(cause);
}
public ZUGFeRDExportException(Throwable cause) {
super(cause);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,9 +19,9 @@
package org.mustangproject.ZUGFeRD;
public class ZUGFeRDExporterFromA1Factory extends ZUGFeRDExporterFromA3Factory implements IExporterFactory {
public class ZUGFeRDExporterFromA1Factory extends ZUGFeRDExporterFromA3Factory implements IExporterFactory {
public ZUGFeRDExporterFromA1Factory() {
ensurePDFisUpgraded=true;
ensurePDFisUpgraded = true;
}

View File

@@ -34,25 +34,31 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
protected boolean ignorePDFAErrors = false;
protected ZUGFeRDConformanceLevel zugferdConformanceLevel = ZUGFeRDConformanceLevel.EXTENDED;
protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE;
/** Producer (attribute for PDF */
/**
* Producer (attribute for PDF
*/
protected String producer = "mustangproject";
/** Human creator (attribute for PDF) */
/**
* Human creator (attribute for PDF)
*/
protected String creator = "mustangproject";
/** Creator tool (attribute for PDF) */
/**
* Creator tool (attribute for PDF)
*/
protected String creatorTool = null;
private HashMap<String,byte[]> additionalXMLs=new HashMap<String,byte[]>();
protected int ZFVersion=ZUGFeRDExporter.DefaultZUGFeRDVersion;
protected boolean ensurePDFisUpgraded=false;
private boolean attachZUGFeRDHeaders=true;
private HashMap<String, byte[]> additionalXMLs = new HashMap<String, byte[]>();
protected int ZFVersion = ZUGFeRDExporter.DefaultZUGFeRDVersion;
protected boolean ensurePDFisUpgraded = false;
private boolean attachZUGFeRDHeaders = true;
/**
* 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)
*
* @param pdfFilename
* filename of an PDF/A1 compliant document
* @param pdfFilename filename of an PDF/A1 compliant document
*/
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
* metadata level, this will not e.g. convert graphics to JPG-2000)
*
* @param pdfBinary
* binary of a PDF/A1 compliant document
* @param pdfBinary binary of a PDF/A1 compliant document
*/
public ZUGFeRDExporter load(byte[] pdfBinary) throws IOException {
ensurePDFIsValidPDFA(new ByteArrayDataSource(new ByteArrayInputStream(pdfBinary)));
@@ -97,17 +101,16 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
return zugFeRDExporter;
}
public ZUGFeRDExporterFromA3Factory () {
public ZUGFeRDExporterFromA3Factory() {
ensurePDFisUpgraded=false;
ensurePDFisUpgraded = false;
}
/**
* 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)
*
* @param pdfSource
* source to read a PDF/A1 compliant document from
* @param pdfSource source to read a PDF/A1 compliant document from
*/
public ZUGFeRDExporter load(InputStream pdfSource) throws IOException {
return load(readAllBytes(pdfSource));
@@ -124,6 +127,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
IOUtils.copy(in, buffer);
return buffer.toByteArray();
}
private static boolean isValidA1(DataSource dataSource) throws IOException {
return getPDFAParserValidationResult(new PreflightParser(dataSource));
}
@@ -131,8 +135,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
/**
* Sets the ZUGFeRD conformance level (override).
*
* @param zugferdConformanceLevel
* the new conformance level
* @param zugferdConformanceLevel the new conformance level
*/
public IExporterFactory setZUGFeRDConformanceLevel(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.
*
* <p/>
* 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-
* means visually and unicode preservable and A means full compliance, i.e.
* visually, unicode and structurally preservable and tagged PDF, i.e. useful
* metainformation for blind people.
*
* <p/>
* Feel free to pass "A" as new level if you know what you are doing :-)
*
*
*/
public IExporterFactory setConformanceLevel(PDFAConformanceLevel newLevel) {
conformanceLevel = newLevel;
@@ -197,7 +198,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
this.creator = creator;
return this;
}
public IExporterFactory setCreatorTool(String creatorTool) {
this.creatorTool = creatorTool;
return this;
@@ -207,6 +208,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
this.producer = producer;
return this;
}
public IExporterFactory setAttachZUGFeRDHeaders(boolean attachHeaders) {
this.attachZUGFeRDHeaders = attachHeaders;
return this;
@@ -215,7 +217,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory {
@Override
public IExporterFactory setZUGFeRDVersion(int version) {
this.ZFVersion=version;
this.ZFVersion = version;
return this;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -27,10 +27,10 @@ import java.util.logging.Logger;
public class ZUGFeRDMigrator {
static final ClassLoader CLASS_LOADER = ZUGFeRDMigrator.class.getClassLoader();
private static final String RESOURCE_PATH = ""; //$NON-NLS-1$
private static final Logger LOG = Logger.getLogger(ZUGFeRDMigrator.class.getName());
// private static File createTempFileResult(final Transformer transformer, final StreamSource toTransform,
static final ClassLoader CLASS_LOADER = ZUGFeRDMigrator.class.getClassLoader();
private static final String RESOURCE_PATH = ""; //$NON-NLS-1$
private static final Logger LOG = Logger.getLogger(ZUGFeRDMigrator.class.getName());
// private static File createTempFileResult(final Transformer transformer, final StreamSource toTransform,
// final String suffix) throws TransformerException, IOException {
// File result = File.createTempFile("ZUV_", suffix); //$NON-NLS-1$
// result.deleteOnExit();
@@ -40,48 +40,48 @@ public class ZUGFeRDMigrator {
// }
// return result;
// }
private TransformerFactory mFactory = null;
private Templates mXsltTemplate = null;
private TransformerFactory mFactory = null;
private Templates mXsltTemplate = null;
public ZUGFeRDMigrator() {
mFactory = new net.sf.saxon.TransformerFactoryImpl();
//fact = TransformerFactory.newInstance();
mFactory.setURIResolver(new ClasspathResourceURIResolver());
try {
mXsltTemplate = mFactory.newTemplates(new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "COMFORTtoEN16931.xsl")));
} catch (TransformerConfigurationException ex) {
LOG.log(Level.SEVERE, null, ex);
}
}
public ZUGFeRDMigrator() {
mFactory = new net.sf.saxon.TransformerFactoryImpl();
//fact = TransformerFactory.newInstance();
mFactory.setURIResolver(new ClasspathResourceURIResolver());
try {
mXsltTemplate = mFactory.newTemplates(new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "COMFORTtoEN16931.xsl")));
} catch (TransformerConfigurationException ex) {
LOG.log(Level.SEVERE, null, ex);
}
}
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.ferd-net.de/upload/Dokumente/FACTUR-X_ZUGFeRD_2p0_Teil1_Profil_EN16931_1p03.pdf
* http://countwordsfree.com/xmlviewer
*/
ByteArrayOutputStream baos = new ByteArrayOutputStream();
applySchematronXsl(new FileInputStream(xmlFilename), baos);
String res = null;
res = baos.toString("UTF-8");
return res;
}
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.ferd-net.de/upload/Dokumente/FACTUR-X_ZUGFeRD_2p0_Teil1_Profil_EN16931_1p03.pdf
* http://countwordsfree.com/xmlviewer
*/
ByteArrayOutputStream baos = new ByteArrayOutputStream();
applySchematronXsl(new FileInputStream(xmlFilename), baos);
String res = null;
res = baos.toString("UTF-8");
return res;
}
public void applySchematronXsl(final InputStream xmlFile,
final OutputStream EN16931Outstream) throws TransformerException {
Transformer transformer = mXsltTemplate.newTransformer();
transformer.transform(new StreamSource(xmlFile), new StreamResult(EN16931Outstream));
}
public void applySchematronXsl(final InputStream xmlFile,
final OutputStream EN16931Outstream) throws TransformerException {
Transformer transformer = mXsltTemplate.newTransformer();
transformer.transform(new StreamSource(xmlFile), new StreamResult(EN16931Outstream));
}
private static class ClasspathResourceURIResolver implements URIResolver {
ClasspathResourceURIResolver() {
// Do nothing, just prevents synthetic access warning.
}
private static class ClasspathResourceURIResolver implements URIResolver {
ClasspathResourceURIResolver() {
// Do nothing, just prevents synthetic access warning.
}
@Override
public Source resolve(String href, String base) throws TransformerException {
return new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + href));
}
}
@Override
public Source resolve(String href, String base) throws TransformerException {
return new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + href));
}
}
}

View File

@@ -19,7 +19,7 @@
package org.mustangproject.ZUGFeRD.model;
public class DateTimeTypeConstants {
public static final String DATE = "102";
public static final String MONTH = "610";
public static final String WEEK = "616";
public static final String DATE = "102";
public static final String MONTH = "610";
public static final String WEEK = "616";
}

View File

@@ -19,7 +19,7 @@
package org.mustangproject.ZUGFeRD.model;
public class DocumentCodeTypeConstants {
public static final String INVOICE = "380";
public static final String DEBITNOTE = "84";
public static final String CREDITNOTE = "389";
public static final String INVOICE = "380";
public static final String DEBITNOTE = "84";
public static final String CREDITNOTE = "389";
}

View File

@@ -19,9 +19,9 @@
package org.mustangproject.ZUGFeRD.model;
public class NoteTypeConstants {
public static final String GENERAL = "";
public static final String REGULARINFO = "REG";
public static final String PRICECONDITION = "AAK";
public static final String CONDITIONS = "AAJ";
public static final String PAYMENTINFO = "PMT";
public static final String GENERAL = "";
public static final String REGULARINFO = "REG";
public static final String PRICECONDITION = "AAK";
public static final String CONDITIONS = "AAJ";
public static final String PAYMENTINFO = "PMT";
}

View File

@@ -19,13 +19,13 @@
package org.mustangproject.ZUGFeRD.model;
public class PaymentMeansCodeTypeConstants {
public static final String BANKACCOUNT = "42";
public static final String NOTSPECIFIED = "1";
public static final String AUTOMATICCLEARING = "3";
public static final String CASH = "10";
public static final String CHECK = "20";
public static final String DEBITADVICE = "31";
public static final String CREDITCARD = "48";
public static final String DEBIT = "49";
public static final String COMPENSATION = "97";
public static final String BANKACCOUNT = "42";
public static final String NOTSPECIFIED = "1";
public static final String AUTOMATICCLEARING = "3";
public static final String CASH = "10";
public static final String CHECK = "20";
public static final String DEBITADVICE = "31";
public static final String CREDITCARD = "48";
public static final String DEBIT = "49";
public static final String COMPENSATION = "97";
}

View File

@@ -19,25 +19,25 @@
package org.mustangproject.ZUGFeRD.model;
public class QuantityTypeConstants {
public static final String PIECE = "C62";
public static final String DAY = "DAY";
public static final String HECTARE = "HAR";
public static final String HOUR = "HUR";
public static final String KILOGRAM = "KGM";
public static final String KILOMETER = "KTM";
public static final String KILOWATTHOUR = "KWH";
public static final String FIXEDRATE = "LS";
public static final String LITRE = "LTR";
public static final String MINUTE = "MIN";
public static final String SQUAREMILLIMETER = "MMK";
public static final String MILLIMETER = "MMT";
public static final String SQUAREMETER = "MTK";
public static final String CUBICMETER = "MTQ";
public static final String METER = "MTR";
public static final String PRODUCTCOUNT = "NAR";
public static final String PRODUCTPAIR = "NPR";
public static final String PERCENT = "P1";
public static final String SET = "SET";
public static final String TON = "TNE";
public static final String WEEK = "WEE";
public static final String PIECE = "C62";
public static final String DAY = "DAY";
public static final String HECTARE = "HAR";
public static final String HOUR = "HUR";
public static final String KILOGRAM = "KGM";
public static final String KILOMETER = "KTM";
public static final String KILOWATTHOUR = "KWH";
public static final String FIXEDRATE = "LS";
public static final String LITRE = "LTR";
public static final String MINUTE = "MIN";
public static final String SQUAREMILLIMETER = "MMK";
public static final String MILLIMETER = "MMT";
public static final String SQUAREMETER = "MTK";
public static final String CUBICMETER = "MTQ";
public static final String METER = "MTR";
public static final String PRODUCTCOUNT = "NAR";
public static final String PRODUCTPAIR = "NPR";
public static final String PERCENT = "P1";
public static final String SET = "SET";
public static final String TON = "TNE";
public static final String WEEK = "WEE";
}

View File

@@ -19,10 +19,10 @@
package org.mustangproject.ZUGFeRD.model;
public class TaxCategoryCodeTypeConstants {
public static final String STANDARDRATE = "S";
public static final String REVERSECHARGE = "AE";
public static final String TAXEXEMPT = "E";
public static final String ZEROTAXPRODUCTS = "Z";
public static final String UNTAXEDSERVICE = "O";
public static final String INTRACOMMUNITY = "IC";
public static final String STANDARDRATE = "S";
public static final String REVERSECHARGE = "AE";
public static final String TAXEXEMPT = "E";
public static final String ZEROTAXPRODUCTS = "Z";
public static final String UNTAXEDSERVICE = "O";
public static final String INTRACOMMUNITY = "IC";
}

View File

@@ -19,6 +19,6 @@
package org.mustangproject.ZUGFeRD.model;
public class TaxRegistrationTypeConstants {
public static final String USTID = "VA";
public static final String TAXID = "FC";
public static final String USTID = "VA";
public static final String TAXID = "FC";
}

View File

@@ -19,7 +19,7 @@
package org.mustangproject.ZUGFeRD.model;
public class TaxTypeCodeTypeConstants {
public static final String SALESTAX = "VAT";
public static final String INSURANCETAX = "ZF_INSURANCE_TAX";
public static final String OLDPART = "AAJ";
public static final String SALESTAX = "VAT";
public static final String INSURANCETAX = "ZF_INSURANCE_TAX";
public static final String OLDPART = "AAJ";
}

View File

@@ -23,18 +23,18 @@ import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
public class FileChecker {
String filename;
StatRun thisRun;
boolean isPDF=false;
boolean isPDF = false;
public FileChecker(String filename, StatRun statistics) {
this.filename=filename;
thisRun=statistics;
this.filename = filename;
thisRun = statistics;
thisRun.incFileCount();
String extension = "";
if (!thisRun.shallIgnoreFileExt()) {
int extIndex = filename.lastIndexOf(".");
if (extIndex >= 0) {
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) {
thisRun.incPDFCount();
}
@@ -46,10 +46,10 @@ public class FileChecker {
}
public boolean checkForZUGFeRD() {
if ((!isPDF)&&(!thisRun.shallIgnoreFileExt())) {
if ((!isPDF) && (!thisRun.shallIgnoreFileExt())) {
return false;
}
ZUGFeRDImporter zi=new ZUGFeRDImporter();
ZUGFeRDImporter zi = new ZUGFeRDImporter();
try {
zi.extract(filename);
if (zi.canParse()) {
@@ -62,10 +62,10 @@ public class FileChecker {
// something really rare happened -- corrupted ZF?
/***
* e.g. Exception in thread "main" java.lang.NullPointerException
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extractLowLevel(ZUGFeRDImporter.java:90)
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extract(ZUGFeRDImporter.java:64)
at toecount.FileChecker.checkForZUGFeRD(FileChecker.java:33)
at toecount.Toecount.main(Toecount.java:111)
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extractLowLevel(ZUGFeRDImporter.java:90)
at org.mustangproject.ZUGFeRD.ZUGFeRDImporter.extract(ZUGFeRDImporter.java:64)
at toecount.FileChecker.checkForZUGFeRD(FileChecker.java:33)
at toecount.Toecount.main(Toecount.java:111)
*
*/
// Ignore nevertheless, most likely we're batch processing
@@ -73,10 +73,10 @@ public class FileChecker {
} catch (Exception e2) {
/**
* probably thrown up from
AM org.apache.pdfbox.pdfparser.PDFParser parse, most likely
INFORMATION: Document is encrypted
but also other internal PDF errors possible like
..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref
AM org.apache.pdfbox.pdfparser.PDFParser parse, most likely
INFORMATION: Document is encrypted
but also other internal PDF errors possible like
..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref
*/
return false;
}

View File

@@ -30,11 +30,12 @@ public class FileTraverser extends SimpleFileVisitor<Path> {
private StatRun thisRun;
public FileTraverser(StatRun statistics) {
this.thisRun=statistics;
this.thisRun = statistics;
}
/***
/**
* check each file
*/
@Override
@@ -51,7 +52,7 @@ public class FileTraverser extends SimpleFileVisitor<Path> {
return CONTINUE;
}
/***
/**
* for each directory
*/
@Override
@@ -62,7 +63,7 @@ public class FileTraverser extends SimpleFileVisitor<Path> {
}
/***
/**
* show errors like file permission stacktraces
*/
@Override

View File

@@ -23,60 +23,64 @@ public class StatRun {
private int horseCount = 0;
private int fileCount = 0;
private int dirCount = 0;
private boolean checkFileExt=true;
private boolean checkFileExt = true;
public void ignoreFileExtension() {
checkFileExt=false;
checkFileExt = false;
}
public boolean shallIgnoreFileExt() {
return !checkFileExt;
}
public void incFileCount(){
public void incFileCount() {
fileCount++;
}
public void incPDFCount(){
public void incPDFCount() {
pdfCount++;
}
public void incZUGFeRDCount(){
public void incZUGFeRDCount() {
horseCount++;
}
public void incDirCount(){
public void incDirCount() {
dirCount++;
}
public int getFileCount(){
public int getFileCount() {
return fileCount;
}
public int getPDFCount(){
public int getPDFCount() {
return pdfCount;
}
public int getZUGFeRDCount(){
public int getZUGFeRDCount() {
return horseCount;
}
public int getDirCount(){
public int getDirCount() {
return dirCount;
}
/***
/**
* returns final statistics
*
* @return english string with linefeeds detailling number of files, directories, number of pdfs and of zugferd files
*/
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",
getFileCount(), getDirCount(), getPDFCount(), getZUGFeRDCount());
}
/***
/**
* show that something is happening
*
* @return String, usually a dot
*/
public String getOutputLine() {

View File

@@ -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");
}
/***
/**
* Asks the user (repeatedly, if neccessary) on the command line for a String
* (offering a defaultValue) conforming to a Regex pattern
*
* @param prompt
* the question to be asked to the user
* @param defaultValue
* the default return value if user hits enter
* @param pattern
* a regex of acceptable values
* @param prompt the question to be asked to the user
* @param defaultValue the default return value if user hits enter
* @param pattern a regex of acceptable values
* @return the user answer conforming to pattern
* @throws Exception
* if pattern not compielable or IOexception on input
* @throws Exception if pattern not compielable or IOexception on input
*/
protected static String getStringFromUser(String prompt, String defaultValue, String pattern) throws Exception {
String input = "";
@@ -156,24 +152,18 @@ public class Toecount {
return input;
}
/***
/**
* Prompts the user for a input or output filename
*
* @param the
* text the user is asked
* @param a
* default Filename
* @param expectedExtension
* 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)
*
* @param the text the user is asked
* @param a default Filename
* @param expectedExtension 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
*/
protected static String getFilenameFromUser(String prompt, String defaultFilename, String expectedExtension,
boolean ensureFileExists, boolean ensureFileNotExists) {
boolean ensureFileExists, boolean ensureFileNotExists) {
boolean fileExistenceOK = false;
String selectedName = "";
do {
@@ -316,9 +306,7 @@ public class Toecount {
if (helpRequested) {
printHelp();
}
else if (((directoryName != null) && (directoryName.length() > 0)) || filesFromStdIn.booleanValue()) {
} else if (((directoryName != null) && (directoryName.length() > 0)) || filesFromStdIn.booleanValue()) {
performMetrics(directoryName, filesFromStdIn, ignoreFileExt);
} else if (combineRequested) {
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,
String zfProfile) throws Exception {
String zfProfile) throws Exception {
/*
* ZUGFeRDExporter ze= new ZUGFeRDExporterFromA1Factory()
* .setProducer("toecount") .setCreator(System.getProperty("user.name"))