VRBL-INV-IT-1p2-66

Basic Info

Rule If the Seller ID is marked as an Italian Codice Fiscale, it must have the correct format. In case of legal persons, it must be an 11-digit number. In case of natural persons, it must be a 16 character alphanumeric string with the correct structure.
Context /ubl:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID
Pattern vrbl-invoice-it-1p2
Severity fatal

Used Template: VRBL-IT-schemeID-0210

Implementation

not(@schemeID = '0210')
or
(
	string-length(normalize-space(.)) = 11
	and
	string-length(translate(normalize-space(.), $Numerics, '')) = 0
)
or
(
	string-length(normalize-space(.)) = 16
	and
	string-length(translate(substring(normalize-space(.), 1, 6), $AlphabetUpperCase, '')) = 0
	and
	string-length(translate(substring(normalize-space(.), 7, 2), $Numerics, '')) = 0
	and
	string-length(translate(substring(normalize-space(.), 9, 1), 'ABCDEHLMPRST', '')) = 0
	and
	string-length(translate(substring(normalize-space(.), 10, 2), $Numerics, '')) = 0
	and
	string-length(translate(substring(normalize-space(.), 12, 5), $AlphaNumerics, '')) = 0
)