VRBL-INV-PEPPOL-RS-83

Basic Info

Rule If the Buyer Party ID is marked as a GLN, its 13th digit must be the correct checksum of the other 12 digits according to the GS1 check digit calculation.
Context /ubl:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID
Pattern vrbl-invoice-peppol-bis3p0-reduced-syntax
Severity fatal

Used Template: GLN-checksum

Implementation

not(
	@schemeID = '0088'
	and
	string-length(normalize-space(.)) = 13
	and
	string(number(normalize-space(.))) != 'NaN'
)
or
(
	substring(
		string(
			1000
			-
			(
				0
				+ number(substring(normalize-space(.), 1, 1))
				+ number(substring(normalize-space(.), 2, 1)) * 3
				+ number(substring(normalize-space(.), 3, 1))
				+ number(substring(normalize-space(.), 4, 1)) * 3
				+ number(substring(normalize-space(.), 5, 1))
				+ number(substring(normalize-space(.), 6, 1)) * 3
				+ number(substring(normalize-space(.), 7, 1))
				+ number(substring(normalize-space(.), 8, 1)) * 3
				+ number(substring(normalize-space(.), 9, 1))
				+ number(substring(normalize-space(.), 10, 1)) * 3
				+ number(substring(normalize-space(.), 11, 1))
				+ number(substring(normalize-space(.), 12, 1)) * 3
			)
		),
		3,
		1
	)
	=
	substring(normalize-space(.), 13, 1)
)