Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement input stream validation starting from 2.8.0 #378

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed FreeSans.ttf
Binary file not shown.
9 changes: 6 additions & 3 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
2.8.0
=======
2023-09-13

- fixes #259 by Heavenfighter: added --disable-file-logging parameter
- Improvement of included notes (#331)
- Should B2B e-invoving come in Germany as defined in the according draft law
([background](https://bit.ly/47CRz4G)) now the InvoiceImporter can at least also parse UBL files.

Improvement of included notes #331
fixes #259 by Heavenfighter
java -Ddisable-file-logging -jar ..\..\..\mustangproject\Mustang-CLI\target\Mustang-CLI-2.7.4-SNAPSHOT.jar --action validate --source Storno_A.xml

2.7.3
=======
Expand Down
26 changes: 3 additions & 23 deletions Mustang-CLI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<parent>
<groupId>org.mustangproject</groupId>
<artifactId>core</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.8.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject</groupId>
<artifactId>Mustang-CLI</artifactId>
<name>e-invoices commandline tool, allowing to create(embed), split and validate Factur-X/ZUGFeRD files. Validation should also work for XRechnung/CII. </name>
<packaging>jar</packaging>
<version>2.7.4-SNAPSHOT</version>
<version>2.8.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.compilerVersion>8</maven.compiler.compilerVersion>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>org.mustangproject</groupId>
<artifactId>validator</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.8.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
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
-->
Expand Down Expand Up @@ -97,26 +97,6 @@
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestSections>
<manifestSection>
<name>FreeSans.ttf</name>
<manifestEntries>
<Content-Type>font/ttf</Content-Type>
</manifestEntries>
</manifestSection>
<manifestSection>
<name>FreeSerif.ttf</name>
<manifestEntries>
<Content-Type>application/x-font</Content-Type>
</manifestEntries>
</manifestSection>
<manifestSection>
<name>Times-Bold.ttf</name>
<manifestEntries>
<Content-Type>application/x-font</Content-Type>
</manifestEntries>
</manifestSection>
</manifestSections>

</archive>
</configuration>
Expand Down
199 changes: 90 additions & 109 deletions Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ If you setup a Maven project, you can grab the artifacts using
<dependency>
<groupId>org.mustangproject</groupId>
<artifactId>library</artifactId>
<version>2.6.1</version>
<version>2.8.0</version>
</dependency>
```
Please note that instead of artifactId `library` you can also
use `validator`, which has a bigger footprint but additionally
allows to run validations.

Contact
-----
Expand Down
30 changes: 2 additions & 28 deletions library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<parent>
<groupId>org.mustangproject</groupId>
<artifactId>core</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.8.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>org.mustangproject</groupId>
<artifactId>library</artifactId>
<version>2.7.4-SNAPSHOT</version>
<version>2.8.1-SNAPSHOT</version>
<packaging>jar</packaging>
<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 Cross Industry Invoice based formats Factur-X/ZUGFeRD, XRechnung and Order-X in your invoice PDFs.
Expand Down Expand Up @@ -63,12 +63,6 @@
<artifactId>jackson-databind</artifactId>
<version>2.14.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.9</version>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
Expand Down Expand Up @@ -174,26 +168,6 @@
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestSections>
<manifestSection>
<name>FreeSans.ttf</name>
<manifestEntries>
<Content-Type>font/ttf</Content-Type>
</manifestEntries>
</manifestSection>
<manifestSection>
<name>FreeSerif.ttf</name>
<manifestEntries>
<Content-Type>application/x-font</Content-Type>
</manifestEntries>
</manifestSection>
<manifestSection>
<name>Times-Bold.ttf</name>
<manifestEntries>
<Content-Type>application/x-font</Content-Type>
</manifestEntries>
</manifestSection>
</manifestSections>
</archive>
</configuration>
</plugin>
Expand Down

This file was deleted.

11 changes: 9 additions & 2 deletions library/src/main/java/org/mustangproject/Invoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -834,14 +834,21 @@ public Invoice setSpecifiedProcuringProjectName(String specifiedProcuringProject
return this;
}


/***
* when the VAT is due, if this can be anticipated, for all items, on transaction level
* @return null if none or the code as string. Use EventTimeCodeTypeConstants, e.g. EventTimeCodeTypeConstants.PAYMENT_DATE
*/
@Override
public String getVATDueDateTypeCode() {
return vatDueDateTypeCode;
}

/**

/***
* Decide when the VAT should be collected.
* @param vatDueDateTypeCode use EventTimeCodeTypeConstants
* @param vatDueDateTypeCode use EventTimeCodeTypeConstants
* @return the invoice (fluent setter)
*/
public Invoice setVATDueDateTypeCode(String vatDueDateTypeCode) {
this.vatDueDateTypeCode = vatDueDateTypeCode;
Expand Down
35 changes: 31 additions & 4 deletions library/src/main/java/org/mustangproject/Item.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.mustangproject;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.fop.util.XMLUtil;
import org.mustangproject.ZUGFeRD.IReferencedDocument;
import org.mustangproject.ZUGFeRD.IZUGFeRDAllowanceCharge;
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableItem;
Expand All @@ -12,7 +11,6 @@
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/***
* describes any invoice line
Expand Down Expand Up @@ -86,20 +84,49 @@ public Item(NodeList itemChilds, boolean recalcPrice) {
}
}
}
if ((currentUBLItemChildNode.getLocalName() != null) && (currentUBLItemChildNode.getLocalName().equals("SellersItemIdentification"))) {
for (Node currentUBLSellerIDNodes : XMLTools.asList(currentUBLItemChildNode.getChildNodes())) {
if ((currentUBLSellerIDNodes.getLocalName() != null) && (currentUBLSellerIDNodes.getLocalName().equals("ID"))) {
sellerAssignedID = currentUBLSellerIDNodes.getTextContent();
}
}
}
}
}

if ((lineTrade != null) && (lineTrade.equals("Price"))) {
// ubl
// PriceAmount with currencyID and BaseQuantity with unitCode
NodeList UBLpriceChilds = itemChilds.item(itemChildIndex).getChildNodes();
boolean isAllowance=true;
String allowanceCharge="";
for (Node currentUBLPriceChildNode : XMLTools.asList(UBLpriceChilds)) {

if ((currentUBLPriceChildNode.getLocalName() != null) && (currentUBLPriceChildNode.getLocalName().equals("PriceAmount"))) {
price = currentUBLPriceChildNode.getTextContent();
}
if ((currentUBLPriceChildNode.getLocalName() != null) && (currentUBLPriceChildNode.getLocalName().equals("BaseQuantity"))) {
basisQuantity = currentUBLPriceChildNode.getTextContent();
}
}/* not needed because already reflected in net price
if ((currentUBLPriceChildNode.getLocalName() != null) && (currentUBLPriceChildNode.getLocalName().equals("AllowanceCharge"))) {
for (Node currentUBLAllowanceChildNode : XMLTools.asList(currentUBLPriceChildNode.getChildNodes())) {
if ((currentUBLAllowanceChildNode.getLocalName()!=null)&&(currentUBLAllowanceChildNode.getLocalName().equals("ChargeIndicator"))) {
if (currentUBLAllowanceChildNode.getTextContent().equalsIgnoreCase("true")) {
isAllowance=false;
}
}
if ((currentUBLAllowanceChildNode.getLocalName()!=null)&&(currentUBLAllowanceChildNode.getLocalName().equals("Amount"))) {
allowanceCharge=currentUBLAllowanceChildNode.getTextContent();
}


}
if (isAllowance) {
// addAllowance(new Allowance(new BigDecimal(allowanceCharge)));
} else {
// addAllowance(new Charge(new BigDecimal(allowanceCharge)));
}
}*/
}

}
Expand Down Expand Up @@ -189,7 +216,7 @@ public Item(NodeList itemChilds, boolean recalcPrice) {
}
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null)
&& (tradeProductChilds.item(tradeProductChildIndex).getLocalName()
.equals("SellerAssignedID"))) {
.equals("SellerAssignedID") ) ) {
sellerAssignedID = tradeProductChilds.item(tradeProductChildIndex).getTextContent();
}
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null)
Expand Down
16 changes: 8 additions & 8 deletions library/src/main/java/org/mustangproject/ReferencedDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

public class ReferencedDocument implements IReferencedDocument {

String issuerAssignedID;
String typeCode;
String referenceTypeCode;
protected String issuerAssignedID;
protected String typeCode;
protected String referenceTypeCode;

public ReferencedDocument(String issuerAssignedID, String typeCode, String referenceTypeCode) {
this.issuerAssignedID = issuerAssignedID;
Expand All @@ -22,23 +22,23 @@ public ReferencedDocument(String issuerAssignedID, String referenceTypeCode) {

/***
* sets an ID assigned by the sender
* @param issuerAssignedID
* @param issuerAssignedID null or a string with the ID of the document as defined by issuer
*/
public void setIssuerAssignedID(String issuerAssignedID) {
this.issuerAssignedID = issuerAssignedID;
}

/**
* which type is the document? e.g. "916" for additional invoice related
* @param typeCode
* which type is the document?
* @param typeCode string with e.g. "916" for additional invoice related
*/
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}

/**
* type of the reference of this line, a UNTDID 1153 code
* @param referenceTypeCode
* type of the reference of this line,
* @param referenceTypeCode the typecode of the reference as a UNTDID 1153 string value https://service.unece.org/trade/untdid/d19b/tred/tred1153.htm
*/
public void setReferenceTypeCode(String referenceTypeCode) {
this.referenceTypeCode = referenceTypeCode;
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/org/mustangproject/SubjectCode.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.mustangproject;

/**
* EN16931-ID: BT-21 - the qualification of the free text on the invoice from BT-22<br/>
* EN16931-ID: BT-21 - the qualification of the free text on the invoice from BT-22<br>
* In the first step only the recommended codes are implemented.
*/
public enum SubjectCode {
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/org/mustangproject/TradeParty.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ public TradeParty setAdditionalAddress(String additionalAddress1, String additio
* e.g. which floor (if LineTwo has already been used e.g. for which building)
* This could sometimes be BT-165?
*
* @param additionalAddress2
* @param additionalAddress2 a String or null
* @return fluent setter
*/
public TradeParty setAdditionalAddressExtension(String additionalAddress2) {
Expand Down
Loading