VRBL-INV-IT-1p2-246

Basic Info

Rule The value of the Charge Reason Code must be contained in UNCL7161 charge reason [VRBL-CL-ChargeReasonCode] or be contained in Social Security Charge Code [VRBL-CL-IT-SocialSecurityChargeCode] (prefixed by 'VRBL:IT:'). For more information visit: https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL7161/
Context /ubl:Invoice/cac:AllowanceCharge[string(cbc:ChargeIndicator) = 'true']/cbc:AllowanceChargeReasonCode
Pattern vrbl-invoice-it-1p2
Severity fatal

Used Template: CodeList

Parameter Value
probe = .
codeList = $VRBL-CL-ChargeReasonCode or $VRBL-IT-Prefix:$VRBL-CL-IT-SocialSecurityChargeCode

Implementation

not(boolean(.))
or
(
	(
		not(
			contains(
				normalize-space(.),
				substring($VRBL-CL-ChargeReasonCode, 1, 1)
			)
		)
		and
		contains(
			$VRBL-CL-ChargeReasonCode,
			concat(
				substring($VRBL-CL-ChargeReasonCode, 1, 1),
				normalize-space(.),
				substring($VRBL-CL-ChargeReasonCode, 1, 1)
			)
		)
	)
)
or
(
	(
		substring(normalize-space(.), 1, string-length($VRBL-IT-Prefix)) = $VRBL-IT-Prefix
		and
		not(
			contains(
				substring-after(normalize-space(.), $VRBL-IT-Prefix),
				substring($VRBL-CL-IT-SocialSecurityChargeCode, 1, 1)
			)
		)
		and
		contains(
			$VRBL-CL-IT-SocialSecurityChargeCode,
			concat(
				substring($VRBL-CL-IT-SocialSecurityChargeCode, 1, 1),
				substring-after(normalize-space(.), $VRBL-IT-Prefix),
				substring($VRBL-CL-IT-SocialSecurityChargeCode, 1, 1)
			)
		)
	)
)