diff --git a/library/src/main/java/org/mustangproject/EStandard.java b/library/src/main/java/org/mustangproject/EStandard.java index 6cf07237..96f1b7b4 100644 --- a/library/src/main/java/org/mustangproject/EStandard.java +++ b/library/src/main/java/org/mustangproject/EStandard.java @@ -1,6 +1,6 @@ package org.mustangproject; public enum EStandard { - facturx, orderx, deliveradvice, zugferd, cii, ubl + facturx, orderx, despatchadvice, ubldespatchadvice, zugferd, cii, ubl } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java index 5ef1d409..8fbaf975 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/DAPullProvider.java @@ -39,7 +39,7 @@ public class DAPullProvider extends ZUGFeRD2PullProvider implements IXMLProvider protected IExportableTransaction trans; private String paymentTermsDescription; - protected Profile profile = Profiles.getByName(EStandard.deliveradvice,"pilot", 1); + protected Profile profile = Profiles.getByName(EStandard.despatchadvice,"pilot", 1); @Override diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/EinLieferscheinExporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/EinLieferscheinExporter.java new file mode 100644 index 00000000..609755e1 --- /dev/null +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/EinLieferscheinExporter.java @@ -0,0 +1,76 @@ +/** + * ********************************************************************* + *
+ * 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.apache.pdfbox.cos.*; +import org.apache.pdfbox.io.IOUtils; +import org.apache.pdfbox.pdmodel.*; +import org.apache.pdfbox.pdmodel.common.PDMetadata; +import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification; +import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile; +import org.apache.pdfbox.preflight.PreflightDocument; +import org.apache.pdfbox.preflight.exception.ValidationException; +import org.apache.pdfbox.preflight.parser.PreflightParser; +import org.apache.pdfbox.preflight.utils.ByteArrayDataSource; +import org.apache.xmpbox.XMPMetadata; +import org.apache.xmpbox.schema.AdobePDFSchema; +import org.apache.xmpbox.schema.DublinCoreSchema; +import org.apache.xmpbox.schema.PDFAIdentificationSchema; +import org.apache.xmpbox.schema.XMPBasicSchema; +import org.apache.xmpbox.type.BadFieldValueException; +import org.apache.xmpbox.xml.XmpSerializer; + +import javax.activation.DataSource; +import javax.activation.FileDataSource; +import javax.xml.transform.TransformerException; +import java.io.*; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Map; + +public class EinLieferscheinExporter implements IExporter { + IXMLProvider xmlProvider; + IExportableTransaction trans; + + public EinLieferscheinExporter() { + xmlProvider=new UBLDAPullProvider(); + } + + + @Override + public IExporter setTransaction(IExportableTransaction trans) throws IOException { + this.trans=trans; + return this; + } + + @Override + public void export(String ZUGFeRDfilename) throws IOException { + export(new FileOutputStream(new File(ZUGFeRDfilename))); + + } + + @Override + public void export(OutputStream output) throws IOException { + xmlProvider.generateXML(trans); + byte[] bytes=xmlProvider.getXML(); + output.write(bytes, 0, bytes.length); + } +} diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java b/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java index 8f22805e..b5b9ae88 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/Profiles.java @@ -63,7 +63,7 @@ public class Profiles { throw new RuntimeException("Profile not found"); } return result; - } else if (standard == EStandard.deliveradvice) { + } else if (standard == EStandard.despatchadvice) { Profile result = null; result = dx1Map.get(name.toUpperCase()); if (result == null) { diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/UBLDAPullProvider.java b/library/src/main/java/org/mustangproject/ZUGFeRD/UBLDAPullProvider.java new file mode 100644 index 00000000..2890e4b5 --- /dev/null +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/UBLDAPullProvider.java @@ -0,0 +1,137 @@ +/** + * ********************************************************************* + *
+ * 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.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.mustangproject.EStandard;
+import org.mustangproject.FileAttachment;
+import org.mustangproject.XMLTools;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.Base64;
+import java.util.Date;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static org.mustangproject.ZUGFeRD.ZUGFeRDDateFormat.DATE;
+import static org.mustangproject.ZUGFeRD.model.DocumentCodeTypeConstants.CORRECTEDINVOICE;
+import static org.mustangproject.ZUGFeRD.model.TaxCategoryCodeTypeConstants.CATEGORY_CODES_WITH_EXEMPTION_REASON;
+
+public class UBLDAPullProvider implements IXMLProvider {
+
+ protected IExportableTransaction trans;
+ protected TransactionCalculator calc;
+ byte[] ublData;
+ protected Profile profile = Profiles.getByName(EStandard.ubldespatchadvice, "basic", 1);
+
+
+ @Override
+ public void generateXML(IExportableTransaction trans) {
+ this.trans = trans;
+ this.calc = new TransactionCalculator(trans);
+
+ final SimpleDateFormat ublDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+
+ String xml = "\n" +
+ "