Skip to content

Commit

Permalink
add fatal check on Invoices with external reference attachment URI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Petersen committed Sep 1, 2024
1 parent a152bf6 commit 30d6172
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 22 deletions.
40 changes: 40 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@echo off
setlocal

REM Set the PROJECT variable to the current directory
set "PROJECT=%~dp0"

REM Check if the target directory exists, if so, remove it
if exist "%PROJECT%target" (
docker run --rm -i -v "%PROJECT%:/src" alpine:3.11 rm -rf /src/target
)

REM Structure
docker run --rm -i ^
-v "%PROJECT%:/src" ^
-v "%PROJECT%target:/target" ^
difi/vefa-structure:0.7

REM Validator
docker run --rm -i -v "%PROJECT%:/src" anskaffelser/validator:2.1.0 build -x -t -n eu.peppol.postaward.v3.billing -a rules,guide -target target/validator /src

REM Generate adoc-files from rules
REM CEN-EN16931-UBL
docker run --rm -i -v "%PROJECT%:/src" -v "%PROJECT%target/generated:/target" --entrypoint java klakegg/saxon:9.8.0-7 -cp /saxon.jar net.sf.saxon.Query -s:/src/rules/sch/CEN-EN16931-UBL.sch -q:tools/xquery/rules_asciidoc_cen.xquery -o:/target/CEN-EN16931-UBL-GENERAL.sch.adoc
docker run --rm -i -v "%PROJECT%:/src" -v "%PROJECT%target/generated:/target" --entrypoint java klakegg/saxon:9.8.0-7 -cp /saxon.jar net.sf.saxon.Query -s:/src/rules/sch/CEN-EN16931-UBL.sch -q:tools/xquery/rules_asciidoc_cen_syntax.xquery -o:/target/CEN-EN16931-UBL-SYNTAX.sch.adoc

REM PEPPOL-EN16931-UBL
docker run --rm -i -v "%PROJECT%:/src" -v "%PROJECT%target/generated:/target" --entrypoint java klakegg/saxon:9.8.0-7 -cp /saxon.jar net.sf.saxon.Query -s:/src/rules/sch/PEPPOL-EN16931-UBL.sch -q:tools/xquery/rules_asciidoc_peppol.xquery -o:/target/PEPPOL-EN16931-UBL-GENERAL.sch.adoc
docker run --rm -i -v "%PROJECT%:/src" -v "%PROJECT%target/generated:/target" --entrypoint java klakegg/saxon:9.8.0-7 -cp /saxon.jar net.sf.saxon.Query -s:/src/rules/sch/PEPPOL-EN16931-UBL.sch -q:tools/xquery/rules_asciidoc_peppol_national.xquery -o:/target/PEPPOL-EN16931-UBL-NATIONAL.sch.adoc

REM Example files
docker run --rm -i -v "%PROJECT%target/site/files:/src" alpine:3.6 rm -rf /src/BIS-Billing3-Examples.zip
docker run --rm -i -v "%PROJECT%rules/examples:/src" -v "%PROJECT%target/site/files:/target" -w /src kramos/alpine-zip -r /target/BIS-Billing3-Examples.zip .

REM Guides
docker run --rm -i -v "%PROJECT%:/documents" -v "%PROJECT%target:/target" difi/asciidoctor

REM Fix ownership
docker run --rm -i -v "%PROJECT%:/src" alpine:3.11 sh -c "chown -R $(id -u).$(id -g) /src/target"

endlocal
18 changes: 18 additions & 0 deletions guide/release-notes/v3.0.18.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
= Version 3.0.18
[horizontal]
Release date:: November 2024

== Changes to BIS document

* sample files and snippits have been updated to reflect the new rule PEPPOL-EN16931-R131
<cac:ExternalReference>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>

== Changes to code lists and validation artefacts


== EN 16931 schematrons updated

* new fatal rule PEPPOL-EN16931-R131 on Document refenced by URI, only allows content starting with http(s):// or ftp(s)://

Binary file modified mapping/mapping-cii-ubl v2 fr19.xls
Binary file not shown.
4 changes: 1 addition & 3 deletions rules/examples/Allowance-example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down Expand Up @@ -366,5 +366,3 @@

</cac:InvoiceLine>
</Invoice>


1 change: 1 addition & 0 deletions rules/sch/PEPPOL-EN16931-CII.sch
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Last update: 2024 May release 3.0.17.
<assert id="PEPPOL-EN16931-R003" test="ram:BuyerReference or ram:BuyerOrderReferencedDocument/ram:IssuerAssignedID" flag="fatal">A buyer reference or purchase order reference MUST be provided.</assert>
<assert id="PEPPOL-EN16931-R006" test="count(ram:AdditionalReferencedDocument[ram:TypeCode='130']) &lt;=1" flag="fatal">Only one invoiced object is allowed on document level</assert>
<assert id="PEPPOL-EN16931-R080" test="count(ram:AdditionalReferencedDocument[ram:TypeCode='50']) &lt;=1" flag="fatal">Only one project reference is allowed on document level</assert>
<assert id="PEPPOL-EN16931-R131" test="boolean(ram:AdditionalReferencedDocument/ram:URIID) and matches(normalize-space(ram:AdditionalReferencedDocument/ram:URIID/text()), '^(http|https|ftp|ftps):','i')" flag="fatal">The Uniform Resource Locater should start with http(s):// or ftp(s)://</assert>
</rule>
<rule context="ram:ApplicableHeaderTradeSettlement">
<assert id="PEPPOL-EN16931-R005" test="not(ram:TaxCurrencyCode) or normalize-space(ram:TaxCurrencyCode/text()) != normalize-space(ram:InvoiceCurrencyCode/text())" flag="fatal">VAT accounting currency code MUST be different from invoice currency code when provided.</assert>
Expand Down
8 changes: 7 additions & 1 deletion rules/sch/PEPPOL-EN16931-UBL.sch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
This schematron uses business terms defined the CEN/EN16931-1 and is reproduced with permission from CEN. CEN bears no liability from the use of the content and implementation of this schematron and gives no warranties expressed or implied for any purpose.
Last update: 2024 May release 3.0.17.
Last update: 2024 Novemeber release 3.0.18.
-->
<schema xmlns="http://purl.oclc.org/dsdl/schematron" xmlns:u="utils" schemaVersion="iso" queryBinding="xslt2">
<title>Rules for Peppol BIS 3.0 Billing</title>
Expand Down Expand Up @@ -247,6 +247,12 @@ Last update: 2024 May release 3.0.17.
<assert id="PEPPOL-EN16931-R080" test="(count(cac:AdditionalDocumentReference[cbc:DocumentTypeCode='50']) &lt;= 1)" flag="fatal">Only one project reference is allowed on document level</assert>
</rule>
</pattern>
<pattern>
<rule context="cac:ExternalReference[cbc:URI]">
<assert id="PEPPOL-EN16931-R131" test="matches(normalize-space(cbc:URI), '^(http|https|ftp|ftps)://', 'i')"
flag="fatal">The Uniform Resource Locater should start with http(s):// or ftp(s)://</assert>
</rule>
</pattern>
<pattern>
<!-- Document level -->
<rule context="ubl-creditnote:CreditNote | ubl-invoice:Invoice">
Expand Down
4 changes: 1 addition & 3 deletions rules/snippets/Calc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down Expand Up @@ -484,5 +484,3 @@
<!-- end::lineamount2[] -->
</cac:InvoiceLine>
</Invoice>


2 changes: 1 addition & 1 deletion rules/snippets/Snippet-cn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
2 changes: 1 addition & 1 deletion rules/snippets/Snippet-full.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
2 changes: 1 addition & 1 deletion rules/snippets/Snippet-refs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
2 changes: 1 addition & 1 deletion rules/snippets/direct-debit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
2 changes: 1 addition & 1 deletion rules/snippets/giro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
4 changes: 1 addition & 3 deletions rules/snippets/item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down Expand Up @@ -386,5 +386,3 @@

</cac:InvoiceLine>
</Invoice>


2 changes: 1 addition & 1 deletion rules/snippets/payment-credit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
2 changes: 1 addition & 1 deletion rules/snippets/payment1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
4 changes: 1 addition & 3 deletions rules/snippets/price.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down Expand Up @@ -464,5 +464,3 @@
</cac:Price>
</cac:InvoiceLine>
</Invoice>


124 changes: 124 additions & 0 deletions rules/unit-CII-PEPPOL/PEPPOL-EN16931-R131.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<testSet xmlns="http://difi.no/xsd/vefa/validator/1.0"
configuration="peppolbis-en16931-base-3.0-cii">
<assert>
<description>Verify that URI has a correct Uniform Resource Locator.</description>
<scope>PEPPOL-EN16931-R131</scope>
</assert>
<test>
<assert>
<success>PEPPOL-EN16931-R131</success>
</assert>
<CrossIndustryInvoice
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">

<SupplyChainTradeTransaction>
<ram:ApplicableHeaderTradeAgreement>
<ram:AdditionalReferencedDocument>
<ram:URIID>ftp://some/invoice/203040</ram:URIID>
</ram:AdditionalReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
</SupplyChainTradeTransaction>

</CrossIndustryInvoice>
</test>
<test>
<assert>
<success>PEPPOL-EN16931-R131</success>
</assert>
<CrossIndustryInvoice
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">

<SupplyChainTradeTransaction>
<ram:ApplicableHeaderTradeAgreement>
<ram:AdditionalReferencedDocument>
<ram:URIID>http://some/invoice/203041</ram:URIID>
</ram:AdditionalReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
</SupplyChainTradeTransaction>

</CrossIndustryInvoice>
</test>
<test>
<assert>
<success>PEPPOL-EN16931-R131</success>
</assert>
<CrossIndustryInvoice
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">

<SupplyChainTradeTransaction>
<ram:ApplicableHeaderTradeAgreement>
<ram:AdditionalReferencedDocument>
<ram:URIID>FTPS://some/invoice/203042</ram:URIID>
</ram:AdditionalReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
</SupplyChainTradeTransaction>

</CrossIndustryInvoice>
</test>
<test>
<assert>
<success>PEPPOL-EN16931-R131</success>
</assert>
<CrossIndustryInvoice
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">

<SupplyChainTradeTransaction>
<ram:ApplicableHeaderTradeAgreement>
<ram:AdditionalReferencedDocument>
<ram:URIID>HTTPS://some/invoice/203043</ram:URIID>
</ram:AdditionalReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
</SupplyChainTradeTransaction>

</CrossIndustryInvoice>
</test>
<test>
<assert>
<error>PEPPOL-EN16931-R131</error>
</assert>
<CrossIndustryInvoice
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">

<SupplyChainTradeTransaction>
<ram:ApplicableHeaderTradeAgreement>
<ram:AdditionalReferencedDocument>
<ram:URIID>HTTPSInvoice 203050</ram:URIID>
</ram:AdditionalReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
</SupplyChainTradeTransaction>


</CrossIndustryInvoice>
</test>
<test>
<assert>
<error>PEPPOL-EN16931-R131</error>
</assert>
<CrossIndustryInvoice
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100">

<SupplyChainTradeTransaction>
<ram:ApplicableHeaderTradeAgreement>
<ram:AdditionalReferencedDocument>
<ram:URIID>FTPInvoice 203051</ram:URIID>
</ram:AdditionalReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
</SupplyChainTradeTransaction>


</CrossIndustryInvoice>
</test>
</testSet>
4 changes: 2 additions & 2 deletions rules/unit-UBL-PEPPOL/PEPPOL-EN16931-R080.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand All @@ -41,7 +41,7 @@
<cbc:DocumentDescription>Technical specification</cbc:DocumentDescription>
<cac:Attachment>
<cac:ExternalReference>
<cbc:URI>www.techspec.no</cbc:URI>
<cbc:URI>http://www.techspec.no</cbc:URI>
</cac:ExternalReference>
</cac:Attachment>
</cac:AdditionalDocumentReference>
Expand Down
Loading

0 comments on commit 30d6172

Please sign in to comment.