From d0196d252cf12a3298aae87af2aaa31ceaf405d1 Mon Sep 17 00:00:00 2001 From: Svante Schubert Date: Tue, 1 May 2018 11:40:40 +0200 Subject: [PATCH] Adding AL2 copyright header to Java and XML files with Jochen's copyright --- .../org/mustangproject/ZUGFeRD/Version.java | 18 +++++++ .../ZUGFeRD/CustomXMLProvider.java | 26 +++++++-- .../ZUGFeRD/IExporterFactory.java | 26 +++++++-- .../mustangproject/ZUGFeRD/IXMLProvider.java | 20 ++++++- .../ZUGFeRD/IZUGFeRDExportableContact.java | 24 +++++++-- .../ZUGFeRD/IZUGFeRDExportableItem.java | 18 +++++++ .../ZUGFeRD/IZUGFeRDExportableProduct.java | 18 +++++++ .../IZUGFeRDExportableTransaction.java | 46 +++++++++++----- .../ZUGFeRD/PDFAConformanceLevel.java | 18 +++++++ .../org/mustangproject/ZUGFeRD/VATAmount.java | 18 +++++++ .../ZUGFeRD/XMPSchemaPDFAExtensions.java | 26 +++++++-- .../ZUGFeRD/XMPSchemaZugferd.java | 18 +++++++ .../ZUGFeRD/ZUGFeRD1PullProvider.java | 25 +++++++-- .../ZUGFeRD/ZUGFeRD2PullProvider.java | 54 ++++++++++++------- .../ZUGFeRD/ZUGFeRDConformanceLevel.java | 18 +++++++ .../ZUGFeRD/ZUGFeRDExportException.java | 18 +++++++ .../ZUGFeRD/ZUGFeRDExporter.java | 48 +++++++++++------ .../ZUGFeRD/ZUGFeRDExporterFromA1Factory.java | 20 ++++++- .../ZUGFeRD/ZUGFeRDExporterFromA3Factory.java | 48 +++++++++++------ .../ZUGFeRD/ZUGFeRDImporter.java | 36 +++++++++---- .../ZUGFeRDTransactionModelConverter.java | 47 ++++++++++------ .../ZUGFeRD/model/DateTimeTypeConstants.java | 18 +++++++ .../model/DocumentCodeTypeConstants.java | 18 +++++++ ...DocumentContextParameterTypeConstants.java | 18 +++++++ .../ZUGFeRD/model/NoteTypeConstants.java | 18 +++++++ .../model/PaymentMeansCodeTypeConstants.java | 18 +++++++ .../ZUGFeRD/model/QuantityTypeConstants.java | 18 +++++++ .../model/TaxCategoryCodeTypeConstants.java | 18 +++++++ .../model/TaxRegistrationTypeConstants.java | 18 +++++++ .../model/TaxTypeCodeTypeConstants.java | 18 +++++++ .../model/ZFNamespacePrefixMapper.java | 25 +++++++-- .../mustangproject/toecount/FileChecker.java | 36 +++++++++---- .../toecount/FileTraverser.java | 23 ++++++-- .../org/mustangproject/toecount/StatRun.java | 26 +++++++-- .../org/mustangproject/toecount/Toecount.java | 18 +++++++ src/main/resources/COMFORTtoEN16931.xsl | 16 ++++++ .../ZUGFeRD/IZUGFeRDAllowanceChargeImpl.java | 18 +++++++ .../IZUGFeRDExportableContactImpl.java | 18 +++++++ .../ZUGFeRD/IZUGFeRDExportableItemImpl.java | 18 +++++++ .../IZUGFeRDExportableProductImpl.java | 18 +++++++ .../IZUGFeRDExportableTransactionImpl.java | 18 +++++++ .../MustangReaderWriterCustomXMLTest.java | 22 ++++++-- .../ZUGFeRD/MustangReaderWriterEdgeTest.java | 22 ++++++-- .../ZUGFeRD/MustangReaderWriterTest.java | 26 +++++++-- .../ZUGFeRDTransactionModelConverterTest.java | 31 ++++++++--- .../ZUGFeRD/ZUGFeRDXMLAssert.java | 25 +++++++-- .../input/ZUGFeRD1-invoice-adjusted.xml | 16 ++++++ .../migration/input/ZUGFeRD1-invoice.xml | 16 ++++++ .../migration/reference/ZUGFeRD2-invoice.xml | 16 ++++++ 49 files changed, 1007 insertions(+), 153 deletions(-) diff --git a/src/main/java-templates/org/mustangproject/ZUGFeRD/Version.java b/src/main/java-templates/org/mustangproject/ZUGFeRD/Version.java index 20c918cb..a85d0222 100644 --- a/src/main/java-templates/org/mustangproject/ZUGFeRD/Version.java +++ b/src/main/java-templates/org/mustangproject/ZUGFeRD/Version.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; public final class Version { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java b/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java index 44494ad6..f5b9825c 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/CustomXMLProvider.java @@ -1,9 +1,27 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; public class CustomXMLProvider implements IXMLProvider { protected byte[] zugferdData; - + @Override public byte[] getXML() { return zugferdData; @@ -14,20 +32,20 @@ public class CustomXMLProvider implements IXMLProvider { if (!zf.contains(" VATPercentAmountMap=getVATPercentAmountMap(); for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) { VATAmount amount = VATPercentAmountMap.get(currentTaxPercent); - res=res.add(amount.getCalculated()); + res=res.add(amount.getCalculated()); } - + return res; } @@ -135,13 +153,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { * which taxes have been used with which amounts in this transaction, * empty for no taxes, or e.g. 19=>190 and 7=>14 if 1000 Eur were applicable * to 19% VAT (=>190 EUR VAT) and 200 EUR were applicable to 7% (=>14 EUR VAT) - * 190 Eur + * 190 Eur * @return * */ private HashMap getVATPercentAmountMap() { HashMap hm=new HashMap (); - + for (IZUGFeRDExportableItem currentItem : trans.getZFItems()) { BigDecimal percent=currentItem.getProduct().getVATPercent(); LineCalc lc=new LineCalc(currentItem); @@ -151,14 +169,14 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { hm.put(percent, itemVATAmount); } else { hm.put(percent, current.add(itemVATAmount)); - + } } return hm; } - + @Override public void generateXML(IZUGFeRDExportableTransaction trans) { @@ -168,7 +186,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { String testBooleanStr="false"; if (isTest) { testBooleanStr="true"; - + } String senderReg=""; if (trans.getOwnOrganisationFullPlaintextInfo()!=null) { @@ -179,11 +197,11 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { + " \n" + "REG\n" + "\n"; - + } - - - + + + String xml= "\n" //$NON-NLS-1$ + "\n"; //$NON-NLS-1$ - + HashMap VATPercentAmountMap=getVATPercentAmountMap(); for (BigDecimal currentTaxPercent : VATPercentAmountMap.keySet()) { VATAmount amount = VATPercentAmountMap.get(currentTaxPercent); @@ -414,7 +432,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider { xml=xml + " \n" //$NON-NLS-1$ + ""; //$NON-NLS-1$ - + byte[] zugferdRaw; try { zugferdRaw = xml.getBytes("UTF-8"); diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDConformanceLevel.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDConformanceLevel.java index 24acf263..432c24c6 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDConformanceLevel.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDConformanceLevel.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; public enum ZUGFeRDConformanceLevel { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExportException.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExportException.java index 232223a4..f5b493c0 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExportException.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExportException.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; public class ZUGFeRDExportException extends RuntimeException { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java index 2ad16e83..76d54fa7 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java @@ -1,3 +1,22 @@ + +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; /* @@ -10,6 +29,18 @@ package org.mustangproject.ZUGFeRD; * */ +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Map; +import javax.xml.transform.TransformerException; import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSBase; import org.apache.pdfbox.cos.COSDictionary; @@ -30,19 +61,6 @@ import org.apache.xmpbox.schema.XMPBasicSchema; import org.apache.xmpbox.type.BadFieldValueException; import org.apache.xmpbox.xml.XmpSerializer; -import javax.xml.transform.TransformerException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Map; - public class ZUGFeRDExporter implements Closeable { public static final int DefaultZUGFeRDVersion = 1; @@ -424,7 +442,7 @@ public class ZUGFeRDExporter implements Closeable { * * @param zUGFeRDConformanceLevel * the new conformance level - * + * * @deprecated Use {@link ZUGFeRDExporterFromA1Factory} instead */ @Deprecated @@ -579,7 +597,7 @@ public class ZUGFeRDExporter implements Closeable { public void setPDFA3(boolean ensurePDFisUpgraded) { this.ensurePDFisUpgraded = ensurePDFisUpgraded; } - + public void setAttachZUGFeRDHeaders(boolean attachZUGFeRDHeaders) { this.attachZUGFeRDHeaders=attachZUGFeRDHeaders; } diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1Factory.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1Factory.java index e55497f7..7862f53e 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1Factory.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA1Factory.java @@ -1,10 +1,28 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; public class ZUGFeRDExporterFromA1Factory extends ZUGFeRDExporterFromA3Factory implements IExporterFactory { public ZUGFeRDExporterFromA1Factory() { ensurePDFisUpgraded=true; - + } } diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java index 4c07dafb..4062be0f 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporterFromA3Factory.java @@ -1,5 +1,30 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import javax.activation.DataSource; +import javax.activation.FileDataSource; import org.apache.pdfbox.io.IOUtils; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.preflight.PreflightDocument; @@ -7,22 +32,13 @@ import org.apache.pdfbox.preflight.exception.ValidationException; import org.apache.pdfbox.preflight.parser.PreflightParser; import org.apache.pdfbox.preflight.utils.ByteArrayDataSource; - -import javax.activation.DataSource; -import javax.activation.FileDataSource; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { protected boolean ignorePDFAErrors = false; protected ZUGFeRDConformanceLevel zugferdConformanceLevel = ZUGFeRDConformanceLevel.EXTENDED; protected PDFAConformanceLevel conformanceLevel = PDFAConformanceLevel.UNICODE; protected String producer = "mustangproject"; protected String creator = "mustangproject"; - + protected int ZFVersion=ZUGFeRDExporter.DefaultZUGFeRDVersion; protected boolean ensurePDFisUpgraded=false; private boolean attachZUGFeRDHeaders=true; @@ -34,7 +50,7 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { * filename of an PDF/A1 compliant document */ public ZUGFeRDExporter load(String pdfFilename) throws IOException { - + ensurePDFIsValidPDFA(new FileDataSource(pdfFilename)); ZUGFeRDExporter zugFeRDExporter; PDDocument doc = PDDocument.load(new File(pdfFilename)); @@ -45,12 +61,12 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { zugFeRDExporter.setProducer(producer); zugFeRDExporter.setAttachZUGFeRDHeaders(attachZUGFeRDHeaders); zugFeRDExporter.setPDFA3(ensurePDFisUpgraded); - + return zugFeRDExporter; } - - + + /** * Makes A PDF/A3a-compliant document from a PDF-A1 compliant document (on the @@ -70,10 +86,10 @@ public class ZUGFeRDExporterFromA3Factory implements IExporterFactory { zugFeRDExporter.setProducer(producer); zugFeRDExporter.setAttachZUGFeRDHeaders(attachZUGFeRDHeaders); zugFeRDExporter.setPDFA3(ensurePDFisUpgraded); - + return zugFeRDExporter; } - + public ZUGFeRDExporterFromA3Factory () { ensurePDFisUpgraded=false; diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index 8f8ce19c..3089e679 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; /** * Mustangproject's ZUGFeRD implementation @@ -14,11 +32,9 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Map; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; - import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary; import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode; @@ -35,7 +51,7 @@ public class ZUGFeRDImporter { /* * call extract(importFilename). containsMeta() will return if ZUGFeRD data has * been found, afterwards you can call getBIC(), getIBAN() etc. - * + * */ /** @var if metadata has been found */ @@ -64,7 +80,7 @@ public class ZUGFeRDImporter { bis.close(); } catch (IOException ioe) { ioe.printStackTrace(); - } + } } /** @@ -153,25 +169,25 @@ public class ZUGFeRDImporter { /* * ndList = document .getElementsByTagName("GermanBankleitzahlID"); * //$NON-NLS-1$ - * + * * for (int bookingIndex = 0; bookingIndex < ndList .getLength(); * bookingIndex++) { Node booking = ndList.item(bookingIndex); // if there is a * attribute in the tag number:value setBIC(booking.getTextContent()); - * + * * } - * + * * ndList = document.getElementsByTagName("ProprietaryID"); //$NON-NLS-1$ - * + * * for (int bookingIndex = 0; bookingIndex < ndList .getLength(); * bookingIndex++) { Node booking = ndList.item(bookingIndex); // if there is a * attribute in the tag number:value setIBAN(booking.getTextContent()); - * + * * } DE1234 * * * DE5656565 Commerzbank * - * + * */ ndList = document.getElementsByTagNameNS("*", "PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$ diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java index ac31953f..a892d746 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverter.java @@ -1,5 +1,33 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import javax.xml.bind.JAXBElement; import org.mustangproject.ZUGFeRD.model.AmountType; import org.mustangproject.ZUGFeRD.model.CodeType; import org.mustangproject.ZUGFeRD.model.CountryIDType; @@ -48,17 +76,6 @@ import org.mustangproject.ZUGFeRD.model.TradeSettlementMonetarySummationType; import org.mustangproject.ZUGFeRD.model.TradeSettlementPaymentMeansType; import org.mustangproject.ZUGFeRD.model.TradeTaxType; -import javax.xml.bind.JAXBElement; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - class ZUGFeRDTransactionModelConverter { private static final SimpleDateFormat zugferdDateFormat = new SimpleDateFormat("yyyyMMdd"); private static final ObjectFactory xmlFactory = new ObjectFactory(); @@ -827,12 +844,12 @@ class ZUGFeRDTransactionModelConverter { * DecimalFormatSymbols(); symbols.setDecimalSeparator(','); * symbols.setGroupingSeparator(' '); * df.setDecimalFormatSymbols(symbols); - * + * * but that would not switch off grouping. Although I liked very much * the (incomplete) "BNF diagram" in * http://docs.oracle.com/javase/tutorial/i18n/format/decimalFormat.html * in the end I decided to calculate myself and take eur+sparator+cents - * + * * This function will cut off, i.e. floor() subcent values Tests: * System.err.println(utils.currencyFormat(new BigDecimal(0), * ".")+"\n"+utils.currencyFormat(new BigDecimal("-1.10"), @@ -841,7 +858,7 @@ class ZUGFeRDTransactionModelConverter { * ",")+"\n"+utils.currencyFormat(new BigDecimal("20000123.3489"), * ",")+"\n"+utils.currencyFormat(new BigDecimal("20000123.3419"), * ",")+"\n"+utils.currencyFormat(new BigDecimal("12"), ",")); - * + * * 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 @@ -944,7 +961,7 @@ class ZUGFeRDTransactionModelConverter { return hm; } - + ZUGFeRDTransactionModelConverter withTest(boolean isTest) { this.isTest = isTest; return this; diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/DateTimeTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/DateTimeTypeConstants.java index ee3dac32..7928a843 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/DateTimeTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/DateTimeTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class DateTimeTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentCodeTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentCodeTypeConstants.java index e3aa9c73..bf1077b8 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentCodeTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentCodeTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class DocumentCodeTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentContextParameterTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentContextParameterTypeConstants.java index 4dfd44fa..57033f6d 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentContextParameterTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/DocumentContextParameterTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class DocumentContextParameterTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/NoteTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/NoteTypeConstants.java index ac01c71d..dae6317c 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/NoteTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/NoteTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class NoteTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/PaymentMeansCodeTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/PaymentMeansCodeTypeConstants.java index 6cd01ddc..c3d52cfa 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/PaymentMeansCodeTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/PaymentMeansCodeTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class PaymentMeansCodeTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/QuantityTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/QuantityTypeConstants.java index f7a2c8c1..bc05313d 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/QuantityTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/QuantityTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class QuantityTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/TaxCategoryCodeTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/TaxCategoryCodeTypeConstants.java index c11c53ac..2fba730a 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/TaxCategoryCodeTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/TaxCategoryCodeTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class TaxCategoryCodeTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/TaxRegistrationTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/TaxRegistrationTypeConstants.java index 37563fc6..ad48e97b 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/TaxRegistrationTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/TaxRegistrationTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class TaxRegistrationTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/TaxTypeCodeTypeConstants.java b/src/main/java/org/mustangproject/ZUGFeRD/model/TaxTypeCodeTypeConstants.java index 804f5cd3..4bf81037 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/TaxTypeCodeTypeConstants.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/TaxTypeCodeTypeConstants.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; public class TaxTypeCodeTypeConstants { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/model/ZFNamespacePrefixMapper.java b/src/main/java/org/mustangproject/ZUGFeRD/model/ZFNamespacePrefixMapper.java index 37c93585..18e48432 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/model/ZFNamespacePrefixMapper.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/model/ZFNamespacePrefixMapper.java @@ -1,14 +1,31 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.model; +import com.sun.xml.bind.marshaller.NamespacePrefixMapper; import java.util.HashMap; import java.util.Map; -import com.sun.xml.bind.marshaller.NamespacePrefixMapper; - public class ZFNamespacePrefixMapper extends NamespacePrefixMapper { private Map namespaceMap = new HashMap<>(); - + /** * Create mappings. */ @@ -18,7 +35,7 @@ public class ZFNamespacePrefixMapper extends NamespacePrefixMapper { namespaceMap.put("urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15", "udt"); namespaceMap.put("urn:ferd:CrossIndustryDocument:invoice:1p0", "rsm"); } - + /* (non-Javadoc) * Returning null when not found based on spec. * @see com.sun.xml.bind.marshaller.NamespacePrefixMapper#getPreferredPrefix(java.lang.String, java.lang.String, boolean) diff --git a/src/main/java/org/mustangproject/toecount/FileChecker.java b/src/main/java/org/mustangproject/toecount/FileChecker.java index e0497b41..f7852cf5 100755 --- a/src/main/java/org/mustangproject/toecount/FileChecker.java +++ b/src/main/java/org/mustangproject/toecount/FileChecker.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.toecount; import org.mustangproject.ZUGFeRD.ZUGFeRDImporter; @@ -6,7 +24,7 @@ public class FileChecker { String filename; StatRun thisRun; boolean isPDF=false; - + public FileChecker(String filename, StatRun statistics) { this.filename=filename; thisRun=statistics; @@ -21,12 +39,12 @@ public class FileChecker { thisRun.incPDFCount(); } } - + } else { - thisRun.incPDFCount(); + thisRun.incPDFCount(); } } - + public boolean checkForZUGFeRD() { if ((!isPDF)&&(!thisRun.shallIgnoreFileExt())) { return false; @@ -48,22 +66,22 @@ public class FileChecker { 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 return false; } catch (Exception e2) { /** - * probably thrown up from + * 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 + but also other internal PDF errors possible like ..Okt 23, 2015 11:17:53 AM org.apache.pdfbox.pdfparser.XrefTrailerResolver setStartxref */ return false; } } - + public boolean isPDF() { return isPDF; } @@ -71,5 +89,5 @@ public class FileChecker { public String getOutputLine() { return thisRun.getOutputLine(); } - + } diff --git a/src/main/java/org/mustangproject/toecount/FileTraverser.java b/src/main/java/org/mustangproject/toecount/FileTraverser.java index 5bae999a..aa773318 100755 --- a/src/main/java/org/mustangproject/toecount/FileTraverser.java +++ b/src/main/java/org/mustangproject/toecount/FileTraverser.java @@ -1,9 +1,26 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.toecount; -import static java.nio.file.FileVisitResult.CONTINUE; - import java.io.IOException; import java.nio.file.FileVisitResult; +import static java.nio.file.FileVisitResult.CONTINUE; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; @@ -29,7 +46,7 @@ public class FileTraverser extends SimpleFileVisitor { fc.checkForZUGFeRD(); System.out.print(fc.getOutputLine()); - } + } return CONTINUE; } diff --git a/src/main/java/org/mustangproject/toecount/StatRun.java b/src/main/java/org/mustangproject/toecount/StatRun.java index 04769479..eaa82683 100755 --- a/src/main/java/org/mustangproject/toecount/StatRun.java +++ b/src/main/java/org/mustangproject/toecount/StatRun.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.toecount; public class StatRun { @@ -10,7 +28,7 @@ public class StatRun { public void ignoreFileExtension() { checkFileExt=false; } - + public boolean shallIgnoreFileExt() { return !checkFileExt; } @@ -51,11 +69,11 @@ public class StatRun { * @return */ public String getSummaryLine() { - + 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 @@ -65,5 +83,5 @@ public class StatRun { return "."; } - + } diff --git a/src/main/java/org/mustangproject/toecount/Toecount.java b/src/main/java/org/mustangproject/toecount/Toecount.java index 1f10c108..31de9a2c 100755 --- a/src/main/java/org/mustangproject/toecount/Toecount.java +++ b/src/main/java/org/mustangproject/toecount/Toecount.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.toecount; /*** diff --git a/src/main/resources/COMFORTtoEN16931.xsl b/src/main/resources/COMFORTtoEN16931.xsl index 5dfee4f3..d6eb2e03 100644 --- a/src/main/resources/COMFORTtoEN16931.xsl +++ b/src/main/resources/COMFORTtoEN16931.xsl @@ -1,3 +1,19 @@ + \n" + "\n" + "\n" + ""; zea1.setZUGFeRDXMLData(ownZUGFeRDXML.getBytes("UTF-8")); - + ByteArrayOutputStream baos=new ByteArrayOutputStream(); zea1.disableAutoClose(true); zea1.export(TARGET_PDF); diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java index c1c2d44b..288a0d81 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.io.IOException; @@ -7,11 +25,9 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; - import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; - import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -403,7 +419,7 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp try(InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf"); - + ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory() .setProducer("My Application") .setCreator(System.getProperty("user.name")) diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java index bf07283d..d8cde149 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterTest.java @@ -1,3 +1,21 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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.io.ByteArrayOutputStream; @@ -8,13 +26,11 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; - -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExportableTransaction { @@ -367,7 +383,7 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta .getResourceAsStream("/MustangGnuaccountingBeispielRE-20171118_506blanko.pdf"); ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().setZUGFeRDVersion(2).load(SOURCE_PDF)) { - + ze.PDFattachZugferdFile(this); ze.disableAutoClose(true); ze.export(TARGET_PDF); diff --git a/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverterTest.java b/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverterTest.java index 89a7b6da..4bfac845 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverterTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDTransactionModelConverterTest.java @@ -1,12 +1,29 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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 org.junit.Test; -import org.mustangproject.ZUGFeRD.model.CrossIndustryDocumentType; - -import javax.xml.bind.JAXBElement; import java.math.BigDecimal; import java.util.Date; import java.util.GregorianCalendar; +import javax.xml.bind.JAXBElement; +import org.junit.Test; +import org.mustangproject.ZUGFeRD.model.CrossIndustryDocumentType; public class ZUGFeRDTransactionModelConverterTest { @Test @@ -39,15 +56,15 @@ public class ZUGFeRDTransactionModelConverterTest { .setQuantity(BigDecimal.ONE) .setPrice(BigDecimal.TEN) ); - + // execution final JAXBElement actual = new ZUGFeRDTransactionModelConverter(transaction).convertToModel(); - + // evaluation ZUGFeRDXMLAssert.assertValidZugferd(actual); } - + private static Date createDate(int year, int month, int day) { final GregorianCalendar calendar = new GregorianCalendar(); calendar.set(year, month-1, day); diff --git a/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDXMLAssert.java b/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDXMLAssert.java index df2eb754..0d8413a3 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDXMLAssert.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/ZUGFeRDXMLAssert.java @@ -1,16 +1,33 @@ +/** ********************************************************************** + * + * Copyright 2018 Jochen Staerk + * + * Use is subject to license terms. + * + * 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 com.helger.schematron.ISchematronResource; import com.helger.schematron.pure.SchematronResourcePure; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.parsers.DocumentBuilderFactory; import org.junit.Assert; import org.mustangproject.ZUGFeRD.model.CrossIndustryDocumentType; import org.w3c.dom.Document; import org.w3c.dom.Node; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.parsers.DocumentBuilderFactory; - public class ZUGFeRDXMLAssert { private static final ISchematronResource SCHEMATRON = loadSchematron(); diff --git a/src/test/resources/migration/input/ZUGFeRD1-invoice-adjusted.xml b/src/test/resources/migration/input/ZUGFeRD1-invoice-adjusted.xml index 74bf378e..f3729478 100644 --- a/src/test/resources/migration/input/ZUGFeRD1-invoice-adjusted.xml +++ b/src/test/resources/migration/input/ZUGFeRD1-invoice-adjusted.xml @@ -1,4 +1,20 @@ + diff --git a/src/test/resources/migration/input/ZUGFeRD1-invoice.xml b/src/test/resources/migration/input/ZUGFeRD1-invoice.xml index acfa8950..c9dbbe2c 100644 --- a/src/test/resources/migration/input/ZUGFeRD1-invoice.xml +++ b/src/test/resources/migration/input/ZUGFeRD1-invoice.xml @@ -1,4 +1,20 @@ + diff --git a/src/test/resources/migration/reference/ZUGFeRD2-invoice.xml b/src/test/resources/migration/reference/ZUGFeRD2-invoice.xml index c379c2c1..4247df96 100644 --- a/src/test/resources/migration/reference/ZUGFeRD2-invoice.xml +++ b/src/test/resources/migration/reference/ZUGFeRD2-invoice.xml @@ -1,4 +1,20 @@ +