VRBL-INV-SE-1p0-26
Basic Info
|
Rule
|
If the Buyer Tax Company ID is marked as a Swedish Legal Entity Number, its 10th digit must be the correct checksum of the other 9 digits according to the Luhn algorithm. |
|
Context
|
/ubl:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID
|
|
Pattern
|
vrbl-invoice-se-1p0 |
|
Severity
|
fatal |
Used Template: VRBL-SE-schemeID-0007-checksum
Implementation
not(
@schemeID = '0007'
and
string-length(normalize-space(.)) = 10
and
string(number(normalize-space(.))) != 'NaN'
)
or
(
substring(
string(
100
-
(
0
+ number(substring(normalize-space(.), 1, 1)) * 2
+ string-length(string(number(substring(normalize-space(.), 1, 1)) * 2)) - 1
+ number(substring(normalize-space(.), 2, 1))
+ number(substring(normalize-space(.), 3, 1)) * 2
+ string-length(string(number(substring(normalize-space(.), 3, 1)) * 2)) - 1
+ number(substring(normalize-space(.), 4, 1))
+ number(substring(normalize-space(.), 5, 1)) * 2
+ string-length(string(number(substring(normalize-space(.), 5, 1)) * 2)) - 1
+ number(substring(normalize-space(.), 6, 1))
+ number(substring(normalize-space(.), 7, 1)) * 2
+ string-length(string(number(substring(normalize-space(.), 7, 1)) * 2)) - 1
+ number(substring(normalize-space(.), 8, 1))
+ number(substring(normalize-space(.), 9, 1)) * 2
+ string-length(string(number(substring(normalize-space(.), 9, 1)) * 2)) - 1
)
),
2,
1
)
=
substring(normalize-space(.), 10, 1)
)