BR-KSA-06: Invoice transaction code (name attribute) must follow NNPNESB

Explained by Matheel from ZATCA's rule text and the condition SDK 3.4.8 executes · Updated

Error: the invoice is rejectedAll invoicesFields: KSA-2

The @name attribute of cbc:InvoiceTypeCode (KSA-2) must start with '01' (tax invoice) or '02' (simplified), followed by 0/1 flags: 3rd-party, nominal, export, summary, self-billed (positions 3–7). The executed check accepts 7, 8 or 9 characters (positions 8–9, continuous supply and B2G, also 0/1); the listed test text allows only 7.

How to fix it

Set the name attribute, e.g. <cbc:InvoiceTypeCode name="0100000">388</cbc:InvoiceTypeCode> for a plain standard invoice or name="0200000" for a simplified one.

ZATCA's official text

[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
Source: ZATCA SDK 3.4.8 · ZATCA KSA rules

Fails when (the condition ZATCA's SDK runs)

not( ( ( (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') ) or (string-length(@name) = 9 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') and (substring(@name,8,1) = '0' or substring(@name,8,1) = '1') and (substring(@name,9,1) = '0' or substring(@name,9,1) = '1') ) or (string-length(@name) = 8 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') and (substring(@name,8,1) = '0' or substring(@name,8,1) = '1') ) ) ) )

Related rules

Validate your invoice against ZATCA's rules

Paste the XML and see every error and warning. It runs in your browser; the invoice goes nowhere.

Validate an invoice or try Matheel