anskaffelser / ehf-postaward-g2

Specifications part of EHF Post-Award, 2nd generation.
33 stars 37 forks source link

NONAT-UBL-T10.xsl result in 'FOAR0001: Division by zero' exception #260

Closed monze closed 6 years ago

monze commented 6 years ago

Please make sure this box is checked before submitting your issue - thank you!

Issues related to PEPPOL BIS or rules part of PEPPOL BIS must be sent to rfc@peppol.eu.

Your issue here: Reported the issue in 244, but the work performed did not resolved the problem. Have just confirmed it used the validator for the upcomming version: https://vefa.difi.no/ehf/standard/ehf-invoice-and-creditnote-2.0.13/

It can be validated by taking a Invoice, and set the value of the xPath to 0 Invoice/cac:InvoiceLine/cac:Price/cbc:BaseQuantity

The issue can be seen in this file https://github.com/difi/vefa-ehf-postaward/blob/master/rules/ehf-invoice-2.0/sch/NONAT-UBL-T10.sch

line 107 and 108

<let name="baseQuantity" value="xs:decimal(if (cac:Price/cbc:BaseQuantity) then cac:Price/cbc:BaseQuantity else 1)"/>
<let name="pricePerUnit" value="xs:decimal(cac:Price/cbc:PriceAmount) div $baseQuantity"/>

The problem is, that in line 107 the variable 'baseQuantity' get the value of the cbc:BaseQuantity from the document, which is 0. On the next line, the variable 'baseQuantity' (which is 0) is used in a division, which result in a 'Division by zero' exception.

To correct the problem line 107 must be change to something like this:

<let name="baseQuantity" value="xs:decimal(if (cac:Price/cbc:BaseQuantity and xs:decimal(cac:Price/cbc:BaseQuantity) != 0 ) then cac:Price/cbc:BaseQuantity else 1)"/>

The problem might also exist for CreditNote.

Jacob Mogensen mySupply ApS Denmark

juskoljo commented 6 years ago

Hi! I've made a pull request 9 days ago about this: https://github.com/difi/vefa-ehf-postaward/pull/259

klakegg commented 6 years ago

Please provide a use case where cbc:BaseQuantity is expected to be "0".

monze commented 6 years ago

Same answer as in issue 244.

We have received this document in the production enviroment, from one of our norwegian customers, and we tranmit the document to another of our norwegian customers.

The issue is, that the Schematron validation crash, and thereby don't complete the validation.

juskoljo commented 6 years ago

Due to this issue (SYSTEM-008) validation cannot ever trigger NONAT-T10-R033 or NONAT-T14-R033.