This commit is contained in:
jstaerk
2025-06-30 11:39:43 +02:00
parent 8ce3d21eae
commit 248372c98a
6 changed files with 14 additions and 14 deletions

View File

@@ -12,6 +12,8 @@
- #855
- #874
- #876/830
- #878
- corrected typo ArithmetricException to ArithmeticException
2.17.0
=======

View File

@@ -4,13 +4,14 @@ import java.text.ParseException;
/***
* will be thrown if an invoice cant be reproduced numerically
* ArithmetricException for backwards compatibility, was a spelling error
*/
public class ArithmeticException extends ArithmetricException {
public ArithmeticException() {
this("");
super();
}
public ArithmeticException(String details) {
// super("Could not reproduce the invoice. " + details, 0);
super(details);
}
}

View File

@@ -10,7 +10,6 @@ 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.mustangproject.util.NodeMap;
import org.slf4j.Logger;
@@ -1096,7 +1095,7 @@ public class ZUGFeRDInvoiceImporter {
.collect(Collectors.joining(" + "));
} catch (Exception ignored) {
}
throw new ArithmetricException("Payable total in XML is " + payableTotalFromXml + ", but calculated total is " + calculatedPayableTotal + moreDetails);
throw new ArithmeticException("Payable total in XML is " + payableTotalFromXml + ", but calculated total is " + calculatedPayableTotal + moreDetails);
}
}
}

View File

@@ -24,8 +24,6 @@ import javax.xml.xpath.XPathFactory;
import org.mustangproject.CalculatedInvoice;
import org.mustangproject.Exceptions.ArithmetricException;
import org.mustangproject.XMLTools;
import org.mustangproject.ZUGFeRD.TransactionCalculator;
import org.mustangproject.ZUGFeRD.ZUGFeRDImporter;
import org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -393,7 +391,7 @@ public class XMLValidator extends Validator {
}
}
}
checkArithmetrics(context);
checkArithmetics(context);
} catch (final IrrecoverableValidationError er) {
@@ -417,14 +415,14 @@ public class XMLValidator extends Validator {
}
private void checkArithmetrics(ValidationContext context) {
private void checkArithmetics(ValidationContext context) {
ZUGFeRDInvoiceImporter zi=new ZUGFeRDInvoiceImporter();
try {
zi.fromXML(zfXML);
CalculatedInvoice ci=new CalculatedInvoice();
zi.extractInto(ci);
} catch ( ArithmetricException e) {
} catch ( ArithmeticException e) {
try {
context.addResultItem(new ValidationResultItem(ESeverity.warning, "Arithmetical issue:"+e.getMessage()).setSection(10));

View File

@@ -284,12 +284,12 @@ public class XMLValidatorTest extends ResourceCase {
}
public void testArithmetrics() {
public void testArithmetics() {
final ValidationContext ctx = new ValidationContext(null);
final XMLValidator xv = new XMLValidator(ctx);
final XPathEngine xpath = new JAXPXPathEngine();
File tempFile = getResourceAsFile("invalidArithmetrics.xml");
File tempFile = getResourceAsFile("invalidArithmetics.xml");
try {
xv.setFilename(tempFile.getAbsolutePath());
xv.validate();

View File

@@ -22,11 +22,11 @@
<ram:SpecifiedLineTradeAgreement>
<ram:GrossPriceProductTradePrice>
<ram:ChargeAmount>160.0000</ram:ChargeAmount>
<ram:BasisQuantity unitCode="HUR">2.0000</ram:BasisQuantity>
<ram:BasisQuantity unitCode="HUR">1.0000</ram:BasisQuantity>
</ram:GrossPriceProductTradePrice>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>160.0000</ram:ChargeAmount>
<ram:BasisQuantity unitCode="HUR">2.0000</ram:BasisQuantity>
<ram:BasisQuantity unitCode="HUR">1.0000</ram:BasisQuantity>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
@@ -179,7 +179,7 @@
<ram:TaxBasisTotalAmount>496.00</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">75.04</ram:TaxTotalAmount>
<ram:GrandTotalAmount>571.04</ram:GrandTotalAmount>
<ram:DuePayableAmount>571.05</ram:DuePayableAmount>
<ram:DuePayableAmount>571.04</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>