VRBL-INV-MX-1p0-87

Basic Info

Rule For a Foreign Trade Invoice, the value of the Buyer Region must be contained in Region Code [VRBL-CL-MX-Region] (prefixed by 'VRBL:MX:').
Context /ubl:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:Region
Pattern vrbl-invoice-mx-1p0
Severity fatal

Used Template: CodeList

Parameter Value
probe = .
codeList = $VRBL-MX-Prefix:$VRBL-CL-MX-Region
showValues = false

Implementation

(
	not(../../../../cec:UBLExtensions/cec:UBLExtension/cec:ExtensionContent/vrbl:InvoiceExtension/vrbl:DocumentSupplements/vrbl:Supplement = 'VRBL:MX:ForeignTrade' and (../cac:Country/cbc:IdentificationCode = 'MX' or ../cac:Country/cbc:IdentificationCode = 'US' or ../cac:Country/cbc:IdentificationCode = 'CA') )
)
or
(
	not(boolean(.))
	or
	(
		(
			substring(normalize-space(.), 1, string-length($VRBL-MX-Prefix)) = $VRBL-MX-Prefix
			and
			not(
				contains(
					substring-after(normalize-space(.), $VRBL-MX-Prefix),
					substring($VRBL-CL-MX-Region, 1, 1)
				)
			)
			and
			contains(
				$VRBL-CL-MX-Region,
				concat(
					substring($VRBL-CL-MX-Region, 1, 1),
					substring-after(normalize-space(.), $VRBL-MX-Prefix),
					substring($VRBL-CL-MX-Region, 1, 1)
				)
			)
		)
	)
)