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

Mustang outputs validation errors whereas KoSIT works #593

Open
wurst-hans opened this issue Nov 27, 2024 · 4 comments
Open

Mustang outputs validation errors whereas KoSIT works #593

wurst-hans opened this issue Nov 27, 2024 · 4 comments

Comments

@wurst-hans
Copy link

Using Mustang 2.15.0 CLI and PDF examples from current ZUGFeRD 2.3.2, for example XRECHNUNG_Reisekostenabrechnung.pdf I get errors on validation (notice that I mean the XML error, not the already known Java errors):

$ java -Xmx1G -Dfile.encoding=UTF-8 -jar Mustang-CLI-2.15.0.jar --action validate --source XRECHNUNG_Reisekostenabrechnung.pdf
13:46:44.810 [main] INFO  c.h.s.x.SchematronResourceXSLTCache - Compiling XSLT instance [cpPath=/xslt/en16931schematron/EN16931-CII-validation.xslt; urlResolved=true; URL=jar:file:/mnt/wsl/dev/code/netadvisor/zugferd/Mustang-CLI-2.15.0.jar!/xslt/en16931schematron/EN16931-CII-validation.xslt]
13:46:46.412 [main] INFO  c.h.s.x.SchematronResourceXSLTCache - Compiling XSLT instance [cpPath=/xslt/XR_30/XRechnung-CII-validation.xslt; urlResolved=true; URL=jar:file:/mnt/wsl/dev/code/netadvisor/zugferd/Mustang-CLI-2.15.0.jar!/xslt/XR_30/XRechnung-CII-validation.xslt]
13:46:46.574 [main] WARN  c.h.x.t.LoggingTransformErrorListener - [warn] Transformation warning (net.sf.saxon.trans.XPathException: A function that computes atomic values should use xsl:sequence rather than xsl:value-of)
13:46:46.576 [main] WARN  c.h.x.t.LoggingTransformErrorListener - [warn] Transformation warning (net.sf.saxon.trans.XPathException: A function that computes atomic values should use xsl:sequence rather than xsl:value-of)
13:46:46.710 [main] INFO  o.m.validator.XMLValidator - FailedAssert
13:46:46.719 [main] WARN  o.m.validator.ZUGFeRDValidator - Warning 27: Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)
13:46:46.719 [main] INFO  o.m.validator.XMLValidator - FailedAssert
13:46:46.720 [main] WARN  o.m.validator.ZUGFeRDValidator - Warning 27: Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)
13:46:46.720 [main] INFO  o.m.validator.XMLValidator - FailedAssert
13:46:46.720 [main] WARN  o.m.validator.ZUGFeRDValidator - Warning 27: Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)
13:46:46.720 [main] INFO  o.m.validator.XMLValidator - FailedAssert
13:46:46.720 [main] WARN  o.m.validator.ZUGFeRDValidator - Warning 27: Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)
13:46:46.755 [main] INFO  o.m.validator.ZUGFeRDValidator - Parsed PDF:valid XML:valid Signature:null Checksum:D335AC75A79B2AA9511F9D335852B64DCCFAD507 Profile:urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0 Version:2 Took:3862ms Errors:[27,27,27,27]
<?xml version="1.0" encoding="UTF-8"?>

<validation filename="XRECHNUNG_Reisekostenabrechnung.pdf" datetime="2024-11-27 13:46:42">
  <pdf>ValidationResult [flavour=3b, totalAssertions=21440, assertions=[], isCompliant=true]
    <info>
      <signature>unknown</signature>
      <duration unit="ms">1706</duration>
    </info>
    <summary status="valid"/>
  </pdf>
  <xml>
    <info>
      <version>2</version>
      <profile>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</profile>
      <validator version="2.15.0"/>
      <rules>
        <fired>30</fired>
        <failed>4</failed>
      </rules>
      <duration unit="ms">2089</duration>
    </info>
    <messages>
      <warning type="27" location="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction[1]/ram:IncludedSupplyChainTradeLineItem[1]/ram:SpecifiedLineTradeAgreement[1]/ram:GrossPriceProductTradePrice[1]" criterion="not(ram:ChargeAmount) or xs:decimal(../ram:NetPriceProductTradePrice/ram:ChargeAmount) = xs:decimal(ram:ChargeAmount) - xs:decimal(ram:AppliedTradeAllowanceCharge/ram:ActualAmount)">Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)</warning>
      <warning type="27" location="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction[1]/ram:IncludedSupplyChainTradeLineItem[2]/ram:SpecifiedLineTradeAgreement[1]/ram:GrossPriceProductTradePrice[1]" criterion="not(ram:ChargeAmount) or xs:decimal(../ram:NetPriceProductTradePrice/ram:ChargeAmount) = xs:decimal(ram:ChargeAmount) - xs:decimal(ram:AppliedTradeAllowanceCharge/ram:ActualAmount)">Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)</warning>
      <warning type="27" location="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction[1]/ram:IncludedSupplyChainTradeLineItem[3]/ram:SpecifiedLineTradeAgreement[1]/ram:GrossPriceProductTradePrice[1]" criterion="not(ram:ChargeAmount) or xs:decimal(../ram:NetPriceProductTradePrice/ram:ChargeAmount) = xs:decimal(ram:ChargeAmount) - xs:decimal(ram:AppliedTradeAllowanceCharge/ram:ActualAmount)">Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)</warning>
      <warning type="27" location="/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction[1]/ram:IncludedSupplyChainTradeLineItem[4]/ram:SpecifiedLineTradeAgreement[1]/ram:GrossPriceProductTradePrice[1]" criterion="not(ram:ChargeAmount) or xs:decimal(../ram:NetPriceProductTradePrice/ram:ChargeAmount) = xs:decimal(ram:ChargeAmount) - xs:decimal(ram:AppliedTradeAllowanceCharge/ram:ActualAmount)">Item net price MUST equal (Gross price - Allowance amount) when gross price is provided. [ID PEPPOL-EN16931-R046] from /xslt/XR_30/XRechnung-CII-validation.xslt)</warning>
    </messages>
    <summary status="valid"/>
  </xml>
  <messages></messages>
  <summary status="valid"/>
</validation>

Instead, when validating the embedded XML with KoSIT Validator 1.5.0 the XRechnung is fully validated without any errors:

Angaben zum geprüften Dokument

Referenz:
2962fa84-dec1-4829-b879-a1254a38c1a5
Zeitpunkt der Prüfung:
27.11.2024, 13:47:42
Erkannter Dokumenttyp:
EN16931 XRechnung (CII)
Erkannter Rechnungssteller:
Lieferant GmbH
Erkannte Rechnungsnummer:
280081
Erkanntes Rechnungsdatum:
15.11.2024
Konformitätsprüfung: Das geprüfte Dokument enthält weder Fehler noch Warnungen. Es ist konform zu den formalen Vorgaben.

Bewertung: Es wird empfohlen das Dokument anzunehmen und weiter zu verarbeiten.
@mkilian
Copy link
Contributor

mkilian commented Nov 29, 2024

They are warnings, not errors. In the validation output, they are marked as such, and the overall outcome is status="valid". However, I'm not sure why the KoSIT validator doesn't display any warning.

@wurst-hans
Copy link
Author

Sorry, I expressed myself incorrectly. Yes, I have seen that they are “only” warnings. The question is not why they are not found in KoSIT, but why they are found in Mustangproject.
When I look at the corresponding XML file:

<ram:SpecifiedLineTradeAgreement>
  <ram:GrossPriceProductTradePrice>
    <ram:ChargeAmount>11.76</ram:ChargeAmount>
  </ram:GrossPriceProductTradePrice>
  <ram:NetPriceProductTradePrice>
    <ram:ChargeAmount>11.76</ram:ChargeAmount>
  </ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>

I see a GrossPriceProductTradePrice of 11.76 for the first position, a NetPriceProductTradePrice of 11.76 and no specification for AppliedTradeAllowanceCharge. This means that both amounts are mathematically correct because there is no discount.
I suspect that the Mustangproject validator expects AppliedTradeAllowanceCharge to be specified in this context, but this does not seem to be a problem with KoSIT.
I don't want to discuss what is correct. What is not nice, however, is that the two validators deliver different results here.

@wurst-hans
Copy link
Author

wurst-hans commented Dec 1, 2024

By the way: If the XML part contains warnings - and in this case it seems to me to be a serious error (the validator speaks of “MUST”), is the document really compliant (i.e. valid)? Is it really compliant with ZUGFeRD 2.3.2? (In this case I would expect a severity of NOTICE or INFORMATION, but not a WARNING.)

I would say it is not compliant, but under the circumstances that the validator issues warnings but still classifies the XML as valid, you could still release the document for further processing. That would be exactly the wording or rating I would give the document.

@mkilian
Copy link
Contributor

mkilian commented Dec 1, 2024

By the way: If the XML part contains warnings - and in this case it seems to me to be a serious error (the validator speaks of “MUST”), is the document really compliant (i.e. valid)? Is it really compliant with ZUGFeRD 2.3.2? (In this case I would expect a severity of NOTICE or INFORMATION, but not a WARNING.)

The text, especially the word "MUST" comes from the validating XSLT, so I guess it would be a bad idea to changes this in mustangproject.

I just compared .../XR_30/XRechnung-CII-validation.xslt (from mustangproject) and .../3.0.2/xsl/XRechnung-CII-validation.xsl (from the KoSIT validator), and for the warnings you got, there's no difference (including the flag, which is "warning" in both files). As noted, I've no idea why the KoSIT validator doesn't display them.

(What's even weirder, in other cases, the KoSIT validator does issue warnings. For example, if you have an empty ram:DefinedTradeContact element, you get a warning from Rule PEPPOL-EN16931-R008: "Document MUST not contain empty elements." The overall outcome of the validation by the KoSIT validator in this case is "Acceptable".)

I really don't want to read the code of the KoSIT validator to find out which criteria are used to decide wether a warning will be issued or not ;-)

For warnings from mustangproject, please note that it currently has a bug that can case errors to be treated as warnings. I've alread submitted a pull request for this one and hope it'll be merged before the next release. (See #595).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants