BR-KSA-06: Invoice transaction code (name attribute) must follow NNPNESB
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
- BR-KSA-07 · Export invoices cannot be self-billed
- BR-KSA-10 · Standard invoices need buyer street, city and country code
- BR-KSA-15 · Standard tax invoices (388) need a supply date
- BR-KSA-25 · Simplified invoice with EDU/HEA exemption needs the buyer name
- BR-KSA-31 · Simplified invoices cannot be self-billed (KSA-2 position 7 = 0)
- BR-KSA-42 · Standard tax invoices and their notes need the buyer name (BT-44)
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