Skip to content

Commit

Permalink
Adding validation of base quantity. #244
Browse files Browse the repository at this point in the history
  • Loading branch information
klakegg committed Nov 15, 2017
1 parent ecbcb7b commit 37ec17b
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
| Replacing rules with rules in EHF Common.
| Validator

| link:https://github.com/difi/vefa-ehf-postaward/issues/244[#244]
| Adding rules link:{ruleurl-inv}NONAT-T10-R033/[NONAT-T10-R033] (**W**) and link:{ruleurl-cre}NONAT-T14-R033/[NONAT-T14-R033] (**W**).
| Validator

| link:https://github.com/difi/vefa-ehf-postaward/issues/233[#233]
| Updated chapter on validation to reflect use of EHF Common.
| Guide
Expand All @@ -31,6 +35,10 @@

|===

WARNING: Validation rules expected to be updated to trigger error in next release:
link:{ruleurl-inv}NONAT-T10-R033/[NONAT-T10-R033],
link:{ruleurl-cre}NONAT-T14-R033/[NONAT-T14-R033]


=== Mapping of rules for EHF Common in EHF Invoice

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
| Bytte ut en del regler med regler i EHF Common.
| Validator

| link:https://github.com/difi/vefa-ehf-postaward/issues/244[#244]
| Langt til reglene link:{ruleurl-inv}NONAT-T10-R033/[NONAT-T10-R033] (**W**) og link:{ruleurl-cre}NONAT-T14-R033/[NONAT-T14-R033] (**W**).
| Validator

| link:https://github.com/difi/vefa-ehf-postaward/issues/233[#233]
| Oppdatert kapittel om validering så det reflerterer bruk av EHF Common.
| Guide
Expand All @@ -31,6 +35,10 @@

|===

WARNING: Valideringsregler som er ventet å trigge feil i neste release:
link:{ruleurl-inv}NONAT-T10-R033/[NONAT-T10-R033],
link:{ruleurl-cre}NONAT-T14-R033/[NONAT-T14-R033]


=== Mapping of rules for EHF Common in EHF Invoice

Expand Down
7 changes: 7 additions & 0 deletions rules/ehf-creditnote-2.0/sch/NONAT-UBL-T14.sch
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@
test="not(cac:Item/cac:ClassifiedTaxCategory/cbc:Percent) or (some $cat in $taxCategories satisfies $cat = $category)"
flag="fatal">[NONAT-T14-R030]-Tax category on line level MUST match provided tax categories on document level.</assert>
</rule>

<rule context="cac:Price/cbc:BaseQuantity">
<assert id="NONAT-T14-R033"
test="xs:decimal(.) &gt; 0"
flag="warning">[NONAT-T10-R031]-Base quantity must be a positive value higher than zero.</assert>
</rule>

<rule context="cac:TaxSubtotal">
<let name="category" value="cac:TaxCategory/cbc:ID/normalize-space(text())"/>
<let name="sumLineExtensionAmount" value="xs:decimal(sum(/ubl:CreditNote/cac:CreditNoteLine[normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID) = $category]/cbc:LineExtensionAmount))"/>
Expand Down
63 changes: 63 additions & 0 deletions rules/ehf-creditnote-2.0/unit-NONAT/NONAT-T14-R033.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<testSet xmlns="http://difi.no/xsd/vefa/validator/1.0" configuration="ehf-t14-base-2.0">
<assert>
<description>Verify use of base quantity</description>
<scope>NONAT-T14-R033</scope>
</assert>
<test>
<assert>
<success>NONAT-T14-R033</success>
</assert>
<CreditNote xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2">

<cac:Price>
<cbc:BaseQuantity>1</cbc:BaseQuantity>
</cac:Price>

</CreditNote>
</test>
<test>
<assert>
<success>NONAT-T14-R033</success>
</assert>
<CreditNote xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2">

<cac:Price>
<cbc:BaseQuantity>0.01</cbc:BaseQuantity>
</cac:Price>

</CreditNote>
</test>
<test>
<assert>
<warning>NONAT-T14-R033</warning>
</assert>
<CreditNote xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2">

<cac:Price>
<cbc:BaseQuantity>0</cbc:BaseQuantity>
</cac:Price>

</CreditNote>
</test>
<test>
<assert>
<warning>NONAT-T14-R033</warning>
</assert>
<CreditNote xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2">

<cac:Price>
<cbc:BaseQuantity>-1</cbc:BaseQuantity>
</cac:Price>

</CreditNote>
</test>
</testSet>
6 changes: 6 additions & 0 deletions rules/ehf-invoice-2.0/sch/NONAT-UBL-T10.sch
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
flag="fatal">[NONAT-T10-R026]-Invoice line amount MUST be equal to the price amount multiplied by the quantity plus charges minus allowances at line level.</assert>
</rule>

<rule context="cac:Price/cbc:BaseQuantity">
<assert id="NONAT-T10-R033"
test="xs:decimal(.) &gt; 0"
flag="warning">[NONAT-T10-R031]-Base quantity must be a positive value higher than zero.</assert>
</rule>

<rule context="cac:TaxSubtotal">
<let name="category" value="normalize-space(cac:TaxCategory/cbc:ID)"/>
<let name="sumLineExtensionAmount" value="xs:decimal(sum(/ubl:Invoice/cac:InvoiceLine[normalize-space(cac:Item/cac:ClassifiedTaxCategory/cbc:ID) = $category]/cbc:LineExtensionAmount))"/>
Expand Down
63 changes: 63 additions & 0 deletions rules/ehf-invoice-2.0/unit-NONAT/NONAT-T10-R033.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<testSet xmlns="http://difi.no/xsd/vefa/validator/1.0" configuration="ehf-t10-base-2.0">
<assert>
<description>Verify use of base quantity</description>
<scope>NONAT-T10-R033</scope>
</assert>
<test>
<assert>
<success>NONAT-T10-R033</success>
</assert>
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">

<cac:Price>
<cbc:BaseQuantity>1</cbc:BaseQuantity>
</cac:Price>

</Invoice>
</test>
<test>
<assert>
<success>NONAT-T10-R033</success>
</assert>
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">

<cac:Price>
<cbc:BaseQuantity>0.01</cbc:BaseQuantity>
</cac:Price>

</Invoice>
</test>
<test>
<assert>
<warning>NONAT-T10-R033</warning>
</assert>
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">

<cac:Price>
<cbc:BaseQuantity>0</cbc:BaseQuantity>
</cac:Price>

</Invoice>
</test>
<test>
<assert>
<warning>NONAT-T10-R033</warning>
</assert>
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">

<cac:Price>
<cbc:BaseQuantity>-1</cbc:BaseQuantity>
</cac:Price>

</Invoice>
</test>
</testSet>

0 comments on commit 37ec17b

Please sign in to comment.