format output, some exception logging corrections

This commit is contained in:
Jochen Stärk
2019-06-10 11:57:20 +02:00
parent ee6335ab93
commit 6662f987f6
6 changed files with 397 additions and 348 deletions

View File

@@ -1,4 +1,12 @@
1.7.2
=====
Support BuyerReference (r+w), as well as SpecifiedLegalOrganization (w) and DefinedTradeContact (w)
use dom4j to format output xml document
corrected some exception logging glitches
1.7.1 1.7.1
===== =====
2019-05-26 2019-05-26

View File

@@ -5,12 +5,15 @@ import java.math.BigDecimal;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge; import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableContact;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTransaction; import org.mustangproject.ZUGFeRD.IZUGFeRDExportableTransaction;
import org.mustangproject.ZUGFeRD.ZUGFeRD2PullProvider;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporter; import org.mustangproject.ZUGFeRD.ZUGFeRDExporter;
import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory; import org.mustangproject.ZUGFeRD.ZUGFeRDExporterFromA1Factory;
@@ -32,8 +35,7 @@ public class MustangWriter implements IZUGFeRDExportableTransaction {
ze.export("./MustangGnuaccountingBeispielRE-20171118_506new.pdf"); ze.export("./MustangGnuaccountingBeispielRE-20171118_506new.pdf");
System.out.println("Done."); System.out.println("Done.");
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block Logger.getLogger(MustangWriter.class.getName()).log(Level.SEVERE, null, e1);
e.printStackTrace();
} }
} }

635
pom.xml
View File

@@ -1,325 +1,332 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>org.mustangproject.ZUGFeRD</groupId> <modelVersion>4.0.0</modelVersion>
<artifactId>mustang</artifactId> <groupId>org.mustangproject.ZUGFeRD</groupId>
<version>1.7.2-SNAPSHOT</version> <artifactId>mustang</artifactId>
<packaging>jar</packaging> <version>1.7.2-SNAPSHOT</version>
<name>Mustang</name> <packaging>jar</packaging>
<description>The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs <name>Mustang</name>
<description>The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs
</description> </description>
<url>http://www.mustangproject.org/</url> <url>http://www.mustangproject.org/</url>
<scm> <scm>
<connection>scm:git:https://github.com/ZUGFeRD/mustangproject.git</connection> <connection>scm:git:https://github.com/ZUGFeRD/mustangproject.git</connection>
<developerConnection>scm:git:https://github.com/ZUGFeRD/mustangproject.git</developerConnection> <developerConnection>scm:git:https://github.com/ZUGFeRD/mustangproject.git</developerConnection>
<url>https://github.com/ZUGFeRD/mustangproject</url> <url>https://github.com/ZUGFeRD/mustangproject</url>
<tag>mustang-1.5.2</tag> <tag>mustang-1.5.2</tag>
</scm> </scm>
<repositories> <repositories>
<repository><!-- for jargs --> <repository><!-- for jargs -->
<id>sonatype-oss-public</id> <id>sonatype-oss-public</id>
<url>https://oss.sonatype.org/content/groups/public/</url> <url>https://oss.sonatype.org/content/groups/public/</url>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
</releases> </releases>
<snapshots> <snapshots>
<enabled>true</enabled> <enabled>true</enabled>
</snapshots> </snapshots>
</repository> </repository>
</repositories> </repositories>
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>internal.repo</id> <id>internal.repo</id>
<name>Temporary Staging Repository</name> <name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url> <url>file://${project.build.directory}/mvn-repo</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<github.global.server>github</github.global.server> <github.global.server>github</github.global.server>
<additionalparam>-Xdoclint:none</additionalparam> <additionalparam>-Xdoclint:none</additionalparam>
<!-- Skip error check for javadoc --> <!-- Skip error check for javadoc -->
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE --> <!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE -->
<dependency> <dependency>
<groupId>net.sf.saxon</groupId> <groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId> <artifactId>Saxon-HE</artifactId>
<version>9.8.0-11</version> <version>9.8.0-11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.xml.bind</groupId> <groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId> <artifactId>jaxb-impl</artifactId>
<version>2.2.11</version> <version>2.2.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.xml.bind</groupId> <groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId> <artifactId>jaxb-core</artifactId>
<version>2.2.11</version> <version>2.2.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish.jaxb</groupId> <groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId> <artifactId>jaxb-runtime</artifactId>
<version>2.2.11</version> <version>2.2.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.pdfbox</groupId> <groupId>org.apache.pdfbox</groupId>
<artifactId>preflight</artifactId> <artifactId>preflight</artifactId>
<version>2.0.12</version> <version>2.0.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.pdfbox</groupId> <groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId> <artifactId>pdfbox</artifactId>
<version>2.0.12</version> <version>2.0.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.dom4j</groupId>
<artifactId>junit</artifactId> <artifactId>dom4j</artifactId>
<version>4.12</version> <version>2.1.1</version>
<scope>test</scope> </dependency>
</dependency> <dependency>
<dependency> <groupId>junit</groupId>
<groupId>com.helger</groupId> <artifactId>junit</artifactId>
<artifactId>ph-schematron</artifactId> <version>4.12</version>
<version>5.0.4</version> <scope>test</scope>
<scope>test</scope> </dependency>
</dependency> <dependency>
<dependency> <groupId>com.helger</groupId>
<groupId>org.xmlunit</groupId> <artifactId>ph-schematron</artifactId>
<artifactId>xmlunit-core</artifactId> <version>5.0.4</version>
<version>2.6.2</version> <scope>test</scope>
<scope>test</scope> </dependency>
</dependency> <dependency>
<!-- For Toecount --> <groupId>org.xmlunit</groupId>
<dependency> <artifactId>xmlunit-core</artifactId>
<groupId>com.sanityinc</groupId> <version>2.6.2</version>
<artifactId>jargs</artifactId> <scope>test</scope>
<version>2.0-SNAPSHOT</version> </dependency>
</dependency> <!-- For Toecount -->
<dependency>
<groupId>com.sanityinc</groupId>
<artifactId>jargs</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin><!-- mvn help:effective-pom will otherwise tell it just defaults <plugin><!-- mvn help:effective-pom will otherwise tell it just defaults
to 2.3.2 - which does not release in the maven repo, and neither shows any to 2.3.2 - which does not release in the maven repo, and neither shows any
error message :-( --> error message :-( -->
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId> <artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version> <version>2.5.3</version>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>
<!-- toecount --> <!-- toecount -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version> <version>3.6.1</version>
<configuration> <configuration>
<archive> <archive>
<manifest> <manifest>
<addClasspath>true</addClasspath> <addClasspath>true</addClasspath>
<mainClass>org.mustangproject.toecount.Toecount</mainClass> <mainClass>org.mustangproject.toecount.Toecount</mainClass>
</manifest> </manifest>
</archive> </archive>
<descriptorRefs> <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </descriptorRefs>
<!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven <!-- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
mvn clean compile assembly:single --> mvn clean compile assembly:single -->
<!-- or whatever version you use --> <!-- or whatever version you use -->
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<!-- /toecount --> <!-- /toecount -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version> <version>3.0.1</version>
<configuration> <configuration>
<excludePackageNames>org.mustangproject.ZUGFeRD.model.*</excludePackageNames> <excludePackageNames>org.mustangproject.ZUGFeRD.model.*</excludePackageNames>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-deploy-plugin</artifactId> <artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version> <version>2.8.2</version>
<configuration> <configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo <altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo
</altDeploymentRepository> </altDeploymentRepository>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.github.github</groupId> <groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId> <artifactId>site-maven-plugin</artifactId>
<version>0.12</version> <version>0.12</version>
<configuration> <configuration>
<message>Maven artifacts for ${project.version}</message> <message>Maven artifacts for ${project.version}</message>
<!-- git commit message --> <!-- git commit message -->
<noJekyll>true</noJekyll> <noJekyll>true</noJekyll>
<!-- disable webpage processing --> <!-- disable webpage processing -->
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory> <outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<!-- matches distribution management repository url above --> <!-- matches distribution management repository url above -->
<branch>refs/heads/mvn-repo</branch> <branch>refs/heads/mvn-repo</branch>
<!-- remote branch name --> <!-- remote branch name -->
<includes> <includes>
<include>**/*</include> <include>**/*</include>
</includes> </includes>
<merge>true</merge> <merge>true</merge>
<repositoryName>mustangproject</repositoryName> <repositoryName>mustangproject</repositoryName>
<!-- github repo name --> <!-- github repo name -->
<repositoryOwner>ZUGFeRD</repositoryOwner> <repositoryOwner>ZUGFeRD</repositoryOwner>
<!-- github username --> <!-- github username -->
</configuration> </configuration>
<executions> <executions>
<!-- run site-maven-plugin's 'site' target as part of the build's normal <!-- run site-maven-plugin's 'site' target as part of the build's normal
'deploy' phase --> 'deploy' phase -->
<execution> <execution>
<goals> <goals>
<goal>site</goal> <goal>site</goal>
</goals> </goals>
<phase>deploy</phase> <phase>deploy</phase>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version> <version>2.4.3</version>
<configuration> <configuration>
<transformers> <transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <transformer
<mainClass>org.mustangproject.toecount.Toecount</mainClass> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer> <mainClass>org.mustangproject.toecount.Toecount</mainClass>
</transformers> </transformer>
<minimizeJar>true</minimizeJar> </transformers>
<filters> <minimizeJar>true</minimizeJar>
<filters>
<filter> <filter>
<artifact>*:*</artifact> <artifact>*:*</artifact>
<excludes> <excludes>
<exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude> <exclude>META-INF/*.RSA</exclude>
</excludes> </excludes>
</filter> </filter>
<filter> <filter>
<artifact>log4j:log4j</artifact> <artifact>log4j:log4j</artifact>
<includes> <includes>
<include>**</include> <include>**</include>
</includes> </includes>
</filter> </filter>
<filter> <filter>
<artifact>commons-logging:commons-logging</artifact> <artifact>commons-logging:commons-logging</artifact>
<includes> <includes>
<include>**</include> <include>**</include>
</includes> </includes>
</filter> </filter>
<filter> <filter>
<artifact>com.sun.xml.bind:jaxb-impl</artifact> <artifact>com.sun.xml.bind:jaxb-impl</artifact>
<includes> <includes>
<include>**</include> <include>**</include>
</includes> </includes>
</filter> </filter>
<filter> <filter>
<artifact>com.sun.xml.bind:jaxb-core</artifact> <artifact>com.sun.xml.bind:jaxb-core</artifact>
<includes> <includes>
<include>**</include> <include>**</include>
</includes> </includes>
</filter> </filter>
</filters> </filters>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<artifactSet> <artifactSet>
<excludes> <excludes>
<!--exclude>classworlds:classworlds</exclude> <exclude>junit:junit</exclude> <!--exclude>classworlds:classworlds</exclude> <exclude>junit:junit</exclude>
<exclude>jmock:*</exclude> <exclude>*:xml-apis</exclude> <exclude>org.apache.maven:lib:tests</exclude> <exclude>jmock:*</exclude> <exclude>*:xml-apis</exclude> <exclude>org.apache.maven:lib:tests</exclude>
<exclude>log4j:log4j:jar:</exclude --> <exclude>log4j:log4j:jar:</exclude -->
</excludes> </excludes>
</artifactSet> </artifactSet>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId> <artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<executions> <executions>
<execution> <execution>
<id>filtering-java-templates</id> <id>filtering-java-templates</id>
<goals> <goals>
<goal>filter-sources</goal> <goal>filter-sources</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId> <artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3.1</version> <version>2.3.1</version>
<executions> <executions>
<execution> <execution>
<id>xjc</id> <id>xjc</id>
<goals> <goals>
<goal>xjc</goal> <goal>xjc</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<target>2.1</target> <target>2.1</target>
<packageName>org.mustangproject.ZUGFeRD.model</packageName> <packageName>org.mustangproject.ZUGFeRD.model</packageName>
<sources> <sources>
<source>src/main/resources/schema/ZUGFeRD1p0.xsd</source> <source>src/main/resources/schema/ZUGFeRD1p0.xsd</source>
</sources> </sources>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<mailingLists> <mailingLists>
<mailingList> <mailingList>
<name>User List</name> <name>User List</name>
<archive>https://groups.google.com/forum/?hl=de#!forum/mustangproject</archive> <archive>https://groups.google.com/forum/?hl=de#!forum/mustangproject</archive>
</mailingList> </mailingList>
</mailingLists> </mailingLists>
<licenses> <licenses>
<license> <license>
<name>Apache License, Version 2.0</name> <name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution> <distribution>repo</distribution>
<comments>A business-friendly OSS license</comments> <comments>A business-friendly OSS license</comments>
</license> </license>
</licenses> </licenses>
<developers> <developers>
<developer> <developer>
<name>Jochen Stärk</name> <name>Jochen Stärk</name>
<email>jstaerk@usegroup.de</email> <email>jstaerk@usegroup.de</email>
<roles> <roles>
<role>architect</role> <role>architect</role>
<role>developer</role> <role>developer</role>
</roles> </roles>
</developer> </developer>
<developer> <developer>
<name>Alexander Schmidt</name> <name>Alexander Schmidt</name>
<email>schmidt.alexander@mail.de</email> <email>schmidt.alexander@mail.de</email>
<roles> <roles>
<role>developer</role> <role>developer</role>
</roles> </roles>
</developer> </developer>
</developers> </developers>
</project> </project>

View File

@@ -18,6 +18,10 @@
*********************************************************************** */ *********************************************************************** */
package org.mustangproject.ZUGFeRD; package org.mustangproject.ZUGFeRD;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@@ -25,6 +29,15 @@ import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
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.toecount.Toecount;
public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider { public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
@@ -121,7 +134,28 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
@Override @Override
public byte[] getXML() { public byte[] getXML() {
return zugferdData;
byte[] res = zugferdData;
StringWriter sw = new StringWriter();
Document document=null;
try {
document = DocumentHelper.parseText(new String(zugferdData));
} catch (DocumentException e1) {
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e1);
}
try {
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(sw, format);
writer.write(document);
res = sw.toString().getBytes("UTF-8");
} catch (IOException e) {
Logger.getLogger(ZUGFeRD2PullProvider.class.getName()).log(Level.SEVERE, null, e);
}
return res;
} }
private BigDecimal getTotalGross() { private BigDecimal getTotalGross() {
@@ -292,13 +326,13 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
xml = xml + " <ram:SellerTradeParty>\n" //$NON-NLS-1$ xml = xml + " <ram:SellerTradeParty>\n" //$NON-NLS-1$
// + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n" // + " <GlobalID schemeID=\"0088\">4000001123452</GlobalID>\n"
+ " <ram:Name>" + trans.getOwnOrganisationName() + "</ram:Name>\n"; //$NON-NLS-1$ //$NON-NLS-2$ + " <ram:Name>" + trans.getOwnOrganisationName() + "</ram:Name>\n"; //$NON-NLS-1$ //$NON-NLS-2$
if (trans.getOwnOrganization()!=null) { if (trans.getOwnOrganization() != null) {
xml = xml + " <ram:SpecifiedLegalOrganization>\n" + xml = xml + " <ram:SpecifiedLegalOrganization>\n" + " <ram:ID>"
" <ram:ID>"+trans.getOwnOrganization().getID()+"</ram:ID>\n" + + trans.getOwnOrganization().getID() + "</ram:ID>\n" + " <ram:TradingBusinessName>"
" <ram:TradingBusinessName>"+trans.getOwnOrganization().getName()+"</ram:TradingBusinessName>\n" + + trans.getOwnOrganization().getName() + "</ram:TradingBusinessName>\n"
" </ram:SpecifiedLegalOrganization>"; + " </ram:SpecifiedLegalOrganization>";
} }
if (trans.getOwnContact() != null) { if (trans.getOwnContact() != null) {
xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + trans.getOwnContact().getName() xml = xml + "<ram:DefinedTradeContact>\n" + " <ram:PersonName>" + trans.getOwnContact().getName()
@@ -401,7 +435,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
} }
} }
/* /*
* xml+= " + " <SpecifiedTradeAllowanceCharge>\n" + * xml+= " + " <SpecifiedTradeAllowanceCharge>\n" +
* " <ChargeIndicator>false</ChargeIndicator>\n" + * " <ChargeIndicator>false</ChargeIndicator>\n" +
* " <BasisAmount currencyID=\"EUR\">10</BasisAmount>\n" + * " <BasisAmount currencyID=\"EUR\">10</BasisAmount>\n" +
* " <ActualAmount>1.00</ActualAmount>\n" + * " <ActualAmount>1.00</ActualAmount>\n" +
@@ -485,8 +519,7 @@ public class ZUGFeRD2PullProvider implements IXMLProvider, IProfileProvider {
zugferdData = zugferdRaw; zugferdData = zugferdRaw;
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} // $NON-NLS-1$ } // $NON-NLS-1$
} }

View File

@@ -32,6 +32,7 @@ import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
import org.apache.pdfbox.pdmodel.common.PDNameTreeNode; import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification; import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile; import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
import org.mustangproject.toecount.Toecount;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@@ -46,6 +47,8 @@ import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ZUGFeRDImporter { public class ZUGFeRDImporter {
@@ -69,7 +72,7 @@ public class ZUGFeRDImporter {
extractLowLevel(bis); extractLowLevel(bis);
bis.close(); bis.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
throw new ZUGFeRDExportException(e); throw new ZUGFeRDExportException(e);
} }
} }
@@ -78,7 +81,7 @@ public class ZUGFeRDImporter {
try { try {
extractLowLevel(pdfStream); extractLowLevel(pdfStream);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
throw new ZUGFeRDExportException(e); throw new ZUGFeRDExportException(e);
} }
} }
@@ -161,7 +164,7 @@ public class ZUGFeRDImporter {
try { try {
transformer = tf.newTransformer(); transformer = tf.newTransformer();
} catch (TransformerConfigurationException e) { } catch (TransformerConfigurationException e) {
e.printStackTrace(); Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
} }
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
@@ -190,10 +193,10 @@ public class ZUGFeRDImporter {
XPath xpath = xpathFact.newXPath(); XPath xpath = xpathFact.newXPath();
result = xpath.evaluate(xpathStr, document); result = xpath.evaluate(xpathStr, document);
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
e.printStackTrace(); Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
throw new ZUGFeRDExportException(e); throw new ZUGFeRDExportException(e);
} catch (IOException | SAXException | TransformerException | XPathExpressionException e) { } catch (IOException | SAXException | TransformerException | XPathExpressionException e) {
e.printStackTrace(); Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
throw new ZUGFeRDExportException(e); throw new ZUGFeRDExportException(e);
} }
return result; return result;

View File

@@ -139,8 +139,8 @@ public class Toecount {
try { try {
input = buffer.readLine(); input = buffer.readLine();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} }
if (input.isEmpty()) { if (input.isEmpty()) {
@@ -176,8 +176,8 @@ public class Toecount {
try { try {
selectedName = buffer.readLine(); selectedName = buffer.readLine();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} }
if (selectedName.isEmpty()) { if (selectedName.isEmpty()) {
@@ -193,8 +193,7 @@ public class Toecount {
try { try {
selectedAnswer = buffer.readLine(); selectedAnswer = buffer.readLine();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} }
if (!selectedAnswer.equals("Y") && !selectedAnswer.equals("y")) { if (!selectedAnswer.equals("Y") && !selectedAnswer.equals("y")) {
System.err.println("Aborted by user"); System.err.println("Aborted by user");
@@ -326,7 +325,7 @@ public class Toecount {
System.exit(2); System.exit(2);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e); Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
System.exit(-1); System.exit(-1);
} }
@@ -454,8 +453,7 @@ public class Toecount {
try { try {
format = getStringFromUser("Format (fx=Factur-X, zf=ZUGFeRD,)", "zf", "fx|zf"); format = getStringFromUser("Format (fx=Factur-X, zf=ZUGFeRD,)", "zf", "fx|zf");
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} }
} else { } else {
System.out.println("Format set to " + format); System.out.println("Format set to " + format);
@@ -466,8 +464,7 @@ public class Toecount {
try { try {
zfVersion = getStringFromUser("Version (1 or 2)", "1", "1|2"); zfVersion = getStringFromUser("Version (1 or 2)", "1", "1|2");
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} }
} else { } else {
System.out.println("Version set to " + zfVersion); System.out.println("Version set to " + zfVersion);
@@ -485,8 +482,8 @@ public class Toecount {
"E", "M|m|W|w|B|b|C|c|E|e|X|x|"); "E", "M|m|W|w|B|b|C|c|E|e|X|x|");
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
e.printStackTrace();
} }
} else { } else {
System.out.println("Profile set to " + zfProfile); System.out.println("Profile set to " + zfProfile);
@@ -550,9 +547,8 @@ public class Toecount {
System.out.println("Written to " + outName); System.out.println("Written to " + outName);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Logger.getLogger(Toecount.class.getName()).log(Level.SEVERE, null, e);
// } catch (JAXBException e) {
// e.printStackTrace();
} }
} }