BR-KSA-06

The invoice transaction code (KSA-2) must exist and respect the following structure: NNPNESBCG where NN (positions 1 and 2) = invoice subtype: - 01 for tax invoice - 02 for simplified tax invoice P (position 3) = 3rd Party invoice transaction, 0 for false, 1 for true; N (position 4) = Nominal invoice transaction, 0 for false, 1 for true; E (position 5) = Exports invoice transaction, 0 for false, 1 for true; S (position 6) = Summary invoice transaction, 0 for false, 1 for true; B (position 7) = Self billed invoice transaction, 0 for false, 1 for true; C (position 8) = Continuous Supply invoice transaction, 0 for false, 1 for true; G (position 9) = B2G invoice transaction, 0 for false, 1 for true

error: the document is invalid

What the rule checks

As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element.

Context
cbc:InvoiceTypeCode
Test
((string-length(@name))= 7) and ((substring(@name,1,2) = '01') or (substring(@name,1,2) = '02')) and ((substring(@name,3,1) = '0') or (substring(@name,3,1) = '1')) and ((substring(@name,4,1) = '0') or (substring(@name,4,1) = '1')) and ((substring(@name,5,1) = '0') or (substring(@name,5,1) = '1')) and ((substring(@name,6,1) = '0') or (substring(@name,6,1) = '1')) and ((substring(@name,7,1) = '0') or (substring(@name,7,1) = '1'))

Checked with Saudi Arabia ZATCA Tax Invoice (UBL), Saudi Arabia ZATCA Simplified Tax Invoice (UBL)