Merge branch 'ZUGFeRD:master' into fix-hyphenation

This commit is contained in:
Adrian-Devries
2025-01-14 07:31:41 +01:00
committed by GitHub
8 changed files with 42 additions and 17 deletions

View File

@@ -1,3 +1,5 @@
- #678
- #679
2.16.0 2.16.0
======= =======

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
@@ -12,7 +12,7 @@
should also work for XRechnung/CII. should also work for XRechnung/CII.
</name> </name>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.compilerVersion>11</maven.compiler.compilerVersion> <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
@@ -23,7 +23,7 @@
<dependency> <dependency>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
<artifactId>validator</artifactId> <artifactId>validator</artifactId>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
<!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with <!-- prototypes of new mustangproject versions can be installed by referring to them and installed to the local repo from a jar file with
mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true mvn install:install-file -Dfile=mustang-1.5.4-SNAPSHOT.jar -DgroupId=org.mustangproject.ZUGFeRD -DartifactId=mustang -Dversion=1.5.4 -Dpackaging=jar -DgeneratePom=true
--> -->

View File

@@ -3,13 +3,13 @@
<parent> <parent>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
<artifactId>library</artifactId> <artifactId>library</artifactId>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Library to write, read and validate e-invoices (Factur-X, ZUGFeRD, Order-X, XRechnung/CII)</name> <name>Library to write, read and validate e-invoices (Factur-X, ZUGFeRD, Order-X, XRechnung/CII)</name>
<description>FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT <description>FOSS Java library to read, write and validate european electronic invoices and orders in the UN/CEFACT

View File

@@ -309,7 +309,7 @@ public class ZUGFeRDInvoiceImporter {
List<IncludedNote> includedNotes = new ArrayList<>(); List<IncludedNote> includedNotes = new ArrayList<>();
//UBL... //UBL...
XPathExpression UBLNotesEx = xpath.compile("/*[local-name()=\"Invoice\"]/*[local-name()=\"Note\"]"); XPathExpression UBLNotesEx = xpath.compile("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"Note\"]");
NodeList UBLNotesNd = (NodeList) UBLNotesEx.evaluate(getDocument(), XPathConstants.NODESET); NodeList UBLNotesNd = (NodeList) UBLNotesEx.evaluate(getDocument(), XPathConstants.NODESET);
if ((UBLNotesNd != null) && (UBLNotesNd.getLength() > 0)) { if ((UBLNotesNd != null) && (UBLNotesNd.getLength() > 0)) {
for (int nodeIndex = 0; nodeIndex < UBLNotesNd.getLength(); nodeIndex++) { for (int nodeIndex = 0; nodeIndex < UBLNotesNd.getLength(); nodeIndex++) {
@@ -556,15 +556,16 @@ public class ZUGFeRDInvoiceImporter {
} }
zpp.addNotes(includedNotes); zpp.addNotes(includedNotes);
String rootNode = extractString("local-name(/*)"); String rootNode = extractString("local-name(/*)");
if (rootNode.equals("Invoice")) { if (rootNode.equals("Invoice")||rootNode.equals("CreditNote")) {
// UBL... // UBL...
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim(); // //*[local-name()="Invoice" or local-name()="CreditNote"]
typeCode = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"InvoiceTypeCode\"]").trim(); number = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"ID\"]").trim();
String issueDateStr = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim(); typeCode = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"InvoiceTypeCode\"]").trim();
String issueDateStr = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"IssueDate\"]").trim();
if (issueDateStr.length()>0) { if (issueDateStr.length()>0) {
issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr); issueDate = new SimpleDateFormat("yyyy-MM-dd").parse(issueDateStr);
} }
String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim(); String dueDt = extractString("/*[local-name()=\"Invoice\" or local-name()=\"CreditNote\"]/*[local-name()=\"DueDate\"]").trim();
if (dueDt.length() > 0) { if (dueDt.length() > 0) {
dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt); dueDate = new SimpleDateFormat("yyyy-MM-dd").parse(dueDt);
} }

View File

@@ -375,7 +375,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
} }
public void testImportMinimum() { public void testImportMinimum() {
File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml"); File CIIinputFile = getResourceAsFile("cii/facturFrMinimum.xml");
try { try {
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile)); ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile));
@@ -394,6 +394,28 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
} }
}
public void testImportUBLCreditnote() { // Confirm some basics also work with UBL credit notes
File CIIinputFile = getResourceAsFile("ubl/UBL-CreditNote-2.1-Example.ubl.xml");
try {
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new FileInputStream(CIIinputFile));
CalculatedInvoice i = new CalculatedInvoice();
zii.extractInto(i);
assertEquals("TOSL108", i.getNumber());
assertEquals("729", i.getGrandTotal().toString());
} catch (IOException e) {
fail("IOException not expected");
} catch (XPathExpressionException e) {
throw new RuntimeException(e);
} catch (ParseException e) {
throw new RuntimeException(e);
}
} }

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>2.15.3-SNAPSHOT</version> <packaging>pom</packaging> <version>2.16.1-SNAPSHOT</version> <packaging>pom</packaging>
<name>Mustang</name> <name>Mustang</name>
<modules> <modules>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject</groupId> <groupId>org.mustangproject</groupId>
@@ -11,7 +11,7 @@
<name>Library to validate e-invoices (ZUGFeRD, Factur-X and Xrechnung)</name> <name>Library to validate e-invoices (ZUGFeRD, Factur-X and Xrechnung)</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
<repositories> <repositories>
<repository> <repository>
<!-- for jargs --> <!-- for jargs -->
@@ -38,7 +38,7 @@
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>library</artifactId> <artifactId>library</artifactId>
<version>2.15.3-SNAPSHOT</version> <version>2.16.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.dom4j</groupId> <groupId>org.dom4j</groupId>

View File

@@ -70,7 +70,7 @@ public class ValidationContext {
} }
public ValidationContext setProfile(String profile) { public ValidationContext setProfile(String profile) {
this.profile = profile; this.profile = profile.trim();
return this; return this;
} }