Skip to content

Commit

Permalink
Merge pull request #91 from OpenPEPPOL/POACC-735
Browse files Browse the repository at this point in the history
POACC-735 updated COMMON-049 and release notes
  • Loading branch information
MartinForsberg-Ecru authored Feb 12, 2024
2 parents d5094ca + cf753e7 commit 9819f49
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
4 changes: 4 additions & 0 deletions guides/release-notes/v3.0.13.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ Release date:: May 2024

== Changes to code lists and validation artefacts

* Added new Swedish rule SE-R-013 for validation of the check number of a Swedish Organization number. The rule is introduced as severity warning. All rules which verifies the format of Organization numbers (SE-R-003, SE-R-004 and SE-R-013) will be changed to severity fatal in next release.

* Update of PEPPOL-COMMON-R049 which validates identifiers using ICD/EAS 0007. The change is adding validation of the check number of a Swedish Organization number.


== Other
1 change: 1 addition & 0 deletions rules/sch/parts/common.sch
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<include href="function/mod97-0208.xml"/>
<include href="function/checkCodiceIPA.xml"/>
<include href="function/abn.xml"/>
<include href="function/checkSEOrgnr.xml"/>

<include href="common/empty-elements.sch"/>
<include href="common/rules.sch"/>
Expand Down
4 changes: 2 additions & 2 deletions rules/sch/parts/common/rules.sch
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<assert id="PEPPOL-COMMON-R048" test="u:checkPIVAseIT(normalize-space())" flag="warning">Italian VAT Code (Partita Iva) must be stated in the correct format</assert>
</rule>
<rule context="cbc:EndpointID[@schemeID = '0007'] | cac:PartyIdentification/cbc:ID[@schemeID = '0007'] | cbc:CompanyID[@schemeID = '0007']">
<assert id="PEPPOL-COMMON-R049" test="string-length(normalize-space()) = 10 and string(number(normalize-space())) != 'NaN'" flag="fatal">Swedish organization number MUST be stated in the correct format.</assert>
</rule>
<assert id="PEPPOL-COMMON-R049" test="string-length(normalize-space()) = 10 and string(number(normalize-space())) != 'NaN' and u:checkSEOrgnr(normalize-space())" flag="fatal">Swedish organization number MUST be stated in the correct format.</assert>
</rule>
<rule context="cbc:EndpointID[@schemeID = '0151'] | cac:PartyIdentification/cbc:ID[@schemeID = '0151'] | cbc:CompanyID[@schemeID = '0151']">
<assert id="PEPPOL-COMMON-R050" test="matches(normalize-space(), '^[0-9]{11}$') and u:abn(normalize-space())" flag="fatal">Australian Business Number (ABN) MUST be stated in the correct format.</assert>
</rule>
Expand Down
27 changes: 27 additions & 0 deletions rules/sch/parts/function/checkSEOrgnr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Function for Swedish organisation numbers (0007) -->
<function xmlns="http://www.w3.org/1999/XSL/Transform" name="u:checkSEOrgnr" as="xs:boolean">
<param name="number" as="xs:string"/>
<choose>
<!-- Check if input is numeric -->
<when test="not(matches($number, '^\d+$'))">
<sequence select="false()"/>
</when>
<otherwise>
<!-- verify the check number of the provided identifier according to the Luhn algorithm-->
<variable name="mainPart" select="substring($number, 1, 9)"/>
<variable name="checkDigit" select="substring($number, 10, 1)"/>
<variable name="sum" as="xs:integer">
<value-of select="sum(
for $pos in 1 to string-length($mainPart) return
if ($pos mod 2 = 1)
then (number(substring($mainPart, string-length($mainPart) - $pos + 1, 1)) * 2) mod 10 +
(number(substring($mainPart, string-length($mainPart) - $pos + 1, 1)) * 2) idiv 10
else number(substring($mainPart, string-length($mainPart) - $pos + 1, 1))
)"/>
</variable>
<variable name="calculatedCheckDigit" select="(10 - $sum mod 10) mod 10"/>
<sequence select="$calculatedCheckDigit = number($checkDigit)"/>
</otherwise>
</choose>
</function>
17 changes: 15 additions & 2 deletions rules/unit-common/PEPPOL-COMMON-R049.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Order-2">
<cac:BuyerCustomerParty>
<cac:Party>
<cbc:EndpointID schemeID="0007">5533221144</cbc:EndpointID>
<cbc:EndpointID schemeID="0007">2021005489</cbc:EndpointID>
</cac:Party>
</cac:BuyerCustomerParty>
</Order>
Expand Down Expand Up @@ -55,5 +55,18 @@
</Order>
</test>


<test>
<assert>
<error>PEPPOL-COMMON-R049</error>
</assert>
<Order 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:Order-2">
<cac:BuyerCustomerParty>
<cac:Party>
<cbc:EndpointID schemeID="0007">2021005480</cbc:EndpointID>
</cac:Party>
</cac:BuyerCustomerParty>
</Order>
</test>
</testSet>

0 comments on commit 9819f49

Please sign in to comment.