VRBL-INV-SE-1p0-2

Basic Info

Rule If the Seller Group is Swedish, then the Seller Tax ID used for VAT ID must end in 12 digits.
Context /ubl:Invoice/cac:AccountingSupplierParty
Pattern vrbl-invoice-se-1p0
Severity fatal

Implementation

not(boolean(cac:Party/cac:PartyTaxScheme[cac:TaxScheme/cbc:ID = 'VAT']/cbc:CompanyID))
or
not(
	cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode = 'SE'
	and
	substring(cac:Party/cac:PartyTaxScheme[cac:TaxScheme/cbc:ID = 'VAT']/cbc:CompanyID, 1, 2) = 'SE'
)
or
string(number(substring(cac:Party/cac:PartyTaxScheme[cac:TaxScheme/cbc:ID = 'VAT']/cbc:CompanyID, 3, 12))) != 'NaN'