diff --git a/History.md b/History.md index 36fa2040..dc7128ab 100644 --- a/History.md +++ b/History.md @@ -3,7 +3,7 @@ 2024- - 435 use invoiceimporter as common technical basis also for zugferdimporter - also import delivery address -- 527 metrics raises errors +- 527 metrics may raise error on some pdf files - 517 read product GlobalID - 380 Added test for input stream validation - 518 corrently validate more XRechnung versions @@ -13,6 +13,8 @@ - 532 support validation warnings! - 534 new signature - 538 Mustang validator always claims PDF is invalid if flavour is PDF/A-3A +- 555 be able to validate ubl credit notes +- when parsing now distinguishing between the parseExceptions StructureException and ArithmetricException 2.14.2 diff --git a/library/src/main/java/org/mustangproject/Exceptions/ArithmetricException.java b/library/src/main/java/org/mustangproject/Exceptions/ArithmetricException.java new file mode 100644 index 00000000..de063e81 --- /dev/null +++ b/library/src/main/java/org/mustangproject/Exceptions/ArithmetricException.java @@ -0,0 +1,13 @@ +package org.mustangproject.Exceptions; + +import java.text.ParseException; + +/*** + * will be thrown if a invoice cant be reproduced numerically + */ +public class ArithmetricException extends ParseException { + public ArithmetricException() { + super( + "Could not reproduce the invoice, this could mean that it could not be read properly", 0); + } +} diff --git a/library/src/main/java/org/mustangproject/Exceptions/StructureException.java b/library/src/main/java/org/mustangproject/Exceptions/StructureException.java new file mode 100644 index 00000000..1859da7a --- /dev/null +++ b/library/src/main/java/org/mustangproject/Exceptions/StructureException.java @@ -0,0 +1,12 @@ +package org.mustangproject.Exceptions; + +import java.text.ParseException; + +/*** + * will be thrown if a invoice cant be read + */ +public class StructureException extends ParseException { + public StructureException(String message, int line) { + super(message, line); + } +} diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java index 7a979763..871a0e82 100644 --- a/library/src/main/java/org/mustangproject/TradeParty.java +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonInclude(JsonInclude.Include.NON_EMPTY) public class TradeParty implements IZUGFeRDExportableTradeParty { - protected String name, zip, street, location, taxScheme; + protected String name, zip, street, location, country, taxScheme; protected String taxID = null, vatID = null; protected String ID = null; protected String description = null; @@ -58,7 +58,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { this.street = street; this.zip = zip; this.location = location; - this.taxScheme = country; + this.country = country; } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index e9c5f712..cebeb824 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -54,15 +54,6 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter { } - /*** - * Wrapper for protected method extractString - * @param xpathStr the xpath expression to be evaluated - * @return the extracted String for the specific path in the document - */ - public String wExtractString(String xpathStr) { - return extractString(xpathStr); - } - //////////////////////////////////// diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index 5c9ee429..600b2879 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -9,6 +9,8 @@ import org.apache.pdfbox.pdmodel.common.PDNameTreeNode; import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification; import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile; import org.mustangproject.*; +import org.mustangproject.Exceptions.ArithmetricException; +import org.mustangproject.Exceptions.StructureException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -701,15 +703,13 @@ public class ZUGFeRDInvoiceImporter { try { whichType = getStandard(); } catch (Exception e) { - throw new ParseException("Could not find out if it's an invoice, order, or delivery advice", 0); - + throw new StructureException("Could not find out if it's an invoice, order, or delivery advice", 0); } if ((whichType != EStandard.despatchadvice) && ((!expectedStringTotalGross.equals(XMLTools.nDigitFormat(expectedGrandTotal, 2))) && (!ignoreCalculationErrors))) { - throw new ParseException( - "Could not reproduce the invoice, this could mean that it could not be read properly", 0); + throw new ArithmetricException(); } } return zpp;