Skip to content

Commit

Permalink
UAN-3070: Opfølgning på review kommentar fra Peppol
Browse files Browse the repository at this point in the history
  • Loading branch information
DanOvergaard committed Feb 21, 2024
1 parent 3daf88e commit 7d3eac9
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions rules/sch/PEPPOL-EN16931-UBL.sch
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,24 @@ Last update: 2023 May release 3.0.15.
((string-to-codepoints(substring($val,11,1)) - 48) * 19)) mod 89 = 0
"/>
</function>

<!-- Functions and variable for Greek Rules -->
<function xmlns="http://www.w3.org/1999/XSL/Transform" name="u:TinVerification" as="xs:boolean">
<param name="val" as="xs:string"/>
<variable name="digits" select="
for $ch in string-to-codepoints($val)
return codepoints-to-string($ch)"/>
<variable name="checksum" select="
(number($digits[8])*2) +
(number($digits[7])*4) +
(number($digits[6])*8) +
(number($digits[5])*16) +
(number($digits[4])*32) +
(number($digits[3])*64) +
(number($digits[2])*128) +
(number($digits[1])*256) "/>
<value-of select="($checksum mod 11) mod 10 = number($digits[9])"/>
</function>
<!-- Empty elements -->
<pattern>
<rule context="//*[not(*) and not(normalize-space())]">
Expand Down Expand Up @@ -213,7 +231,6 @@ Last update: 2023 May release 3.0.15.
<assert id="PEPPOL-EN16931-R053" test="count(cac:TaxTotal[cac:TaxSubtotal]) = 1" flag="fatal">Only one tax total with tax subtotals MUST be provided.</assert>
<assert id="PEPPOL-EN16931-R054" test="count(cac:TaxTotal[not(cac:TaxSubtotal)]) = (if (cbc:TaxCurrencyCode) then 1 else 0)" flag="fatal">Only one tax total without tax subtotals MUST be provided when tax currency code is provided.</assert>
<assert id="PEPPOL-EN16931-R055" test="not(cbc:TaxCurrencyCode) or (cac:TaxTotal/cbc:TaxAmount[@currencyID=normalize-space(../../cbc:TaxCurrencyCode)] &lt;= 0 and cac:TaxTotal/cbc:TaxAmount[@currencyID=normalize-space(../../cbc:DocumentCurrencyCode)] &lt;= 0) or (cac:TaxTotal/cbc:TaxAmount[@currencyID=normalize-space(../../cbc:TaxCurrencyCode)] &gt;= 0 and cac:TaxTotal/cbc:TaxAmount[@currencyID=normalize-space(../../cbc:DocumentCurrencyCode)] &gt;= 0) " flag="fatal">Invoice total VAT amount and Invoice total VAT amount in accounting currency MUST have the same operational sign</assert>
<assert id="PEPPOL-EN16931-R006" test="(count(cac:AdditionalDocumentReference[cbc:DocumentTypeCode='130']) &lt;= 1)" flag="fatal">Only one invoiced object is allowed on document level</assert>
</rule>
<rule context="cbc:TaxCurrencyCode">
<assert id="PEPPOL-EN16931-R005" test="not(normalize-space(text()) = normalize-space(../cbc:DocumentCurrencyCode/text()))" flag="fatal">VAT accounting currency code MUST be different from invoice currency code when provided.</assert>
Expand Down Expand Up @@ -477,23 +494,7 @@ Last update: 2023 May release 3.0.15.
</rule>
</pattern>
<!-- GREECE -->
<!-- General functions and variable for Greek Rules -->
<function xmlns="http://www.w3.org/1999/XSL/Transform" name="u:TinVerification" as="xs:boolean">
<param name="val" as="xs:string"/>
<variable name="digits" select="
for $ch in string-to-codepoints($val)
return codepoints-to-string($ch)"/>
<variable name="checksum" select="
(number($digits[8])*2) +
(number($digits[7])*4) +
(number($digits[6])*8) +
(number($digits[5])*16) +
(number($digits[4])*32) +
(number($digits[3])*64) +
(number($digits[2])*128) +
(number($digits[1])*256) "/>
<value-of select="($checksum mod 11) mod 10 = number($digits[9])"/>
</function>
<!-- General variable for Greek Rules -->
<let name="isGreekSender" value="($supplierCountry ='GR') or ($supplierCountry ='EL')"/>
<let name="isGreekReceiver" value="($customerCountry ='GR') or ($customerCountry ='EL')"/>
<let name="isGreekSenderandReceiver" value="$isGreekSender and $isGreekReceiver"/>
Expand All @@ -509,7 +510,7 @@ Last update: 2023 May release 3.0.15.
<!-- Sender Rules -->
<pattern>
<let name="dateRegExp" value="'^(0?[1-9]|[12][0-9]|3[01])[-\\/ ]?(0?[1-9]|1[0-2])[-\\/ ]?(19|20)[0-9]{2}'"/>
<let name="greekDocumentType" value="tokenize('1.1 1.2 1.3 1.4 1.5 1.6 2.1 2.2 2.3 2.4 3.1 3.2 4 5.1 5.2 6.1 6.2 7.1 8.1 8.2 11.1 11.2 11.3 11.4 11.5','\s')"/>
<let name="greekDocumentType" value="tokenize('1.1 1.6 2.1 2.4 5.1 5.2 ','\s')"/>
<let name="tokenizedUblIssueDate" value="tokenize(/*/cbc:IssueDate,'-')"/>
<!-- Invoice ID -->
<rule context="/ubl-invoice:Invoice/cbc:ID[$isGreekSender] | /ubl-creditnote:CreditNote/cbc:ID[$isGreekSender]">
Expand Down Expand Up @@ -662,7 +663,7 @@ Last update: 2023 May release 3.0.15.
<let name="UNCL5189" value="tokenize('41 42 60 62 63 64 65 66 67 68 70 71 88 95 100 102 103 104 105', '\s')"/>
<let name="UNCL7161" value="tokenize('AA AAA AAC AAD AAE AAF AAH AAI AAS AAT AAV AAY AAZ ABA ABB ABC ABD ABF ABK ABL ABN ABR ABS ABT ABU ACF ACG ACH ACI ACJ ACK ACL ACM ACS ADC ADE ADJ ADK ADL ADM ADN ADO ADP ADQ ADR ADT ADW ADY ADZ AEA AEB AEC AED AEF AEH AEI AEJ AEK AEL AEM AEN AEO AEP AES AET AEU AEV AEW AEX AEY AEZ AJ AU CA CAB CAD CAE CAF CAI CAJ CAK CAL CAM CAN CAO CAP CAQ CAR CAS CAT CAU CAV CAW CAX CAY CAZ CD CG CS CT DAB DAC DAD DAF DAG DAH DAI DAJ DAK DAL DAM DAN DAO DAP DAQ DL EG EP ER FAA FAB FAC FC FH FI GAA HAA HD HH IAA IAB ID IF IR IS KO L1 LA LAA LAB LF MAE MI ML NAA OA PA PAA PC PL RAB RAC RAD RAF RE RF RH RV SA SAA SAD SAE SAI SG SH SM SU TAB TAC TT TV V1 V2 WH XAA YY ZZZ', '\s')"/>
<let name="UNCL5305" value="tokenize('AE E S Z G O K L M', '\s')"/>
<let name="eaid" value="tokenize('0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0151 0183 0184 0188 0190 0191 0192 0193 0195 0196 0198 0199 0200 0201 0202 0204 0208 0209 0210 0211 0212 0213 0215 0216 0221 0230 9901 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959', '\s')"/>
<let name="eaid" value="tokenize('0002 0007 0009 0037 0060 0088 0096 0097 0106 0130 0135 0142 0151 0183 0184 0188 0190 0191 0192 0193 0195 0196 0198 0199 0200 0201 0202 0204 0208 0209 0210 0211 0212 0213 0215 0216 0218 0221 0230 9901 9910 9913 9914 9915 9918 9919 9920 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9957 9959', '\s')"/>
<rule context="cbc:EmbeddedDocumentBinaryObject[@mimeCode]">
<assert id="PEPPOL-EN16931-CL001" test="
some $code in $MIMECODE
Expand Down

0 comments on commit 7d3eac9

Please sign in to comment.