aligned-ibrp-hvg-08

For each different value of tax category rate (ibt-119) where the tax category code (ibt-118) is "HVG", the tax category taxable amount (ibt-116) in a tax breakdown (ibg-23) MUST equal the sum of Invoice line net amounts (ibt-131) plus the sum of document level charge amounts (ibt-99) minus the sum of document level allowance amounts (ibt-92) where the tax category code (ibt-151, ibt-102, ibt-95) is "HVG" and the tax rate (ibt-152, ibt-103, ibt-96) equals the tax category rate (ibt-119).

error: the document is invalid

What the rule checks

As the rule set's publisher wrote it. The rule runs on every element the context matches, and fails where the test is false; the validator reports the line of that element.

Context
/*/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory[normalize-space(cbc:ID) = 'HVG'][cac:TaxScheme/normalize-space(upper-case(cbc:ID))='VAT']
Test
every $rate in xs:decimal((cbc:Percent, 0)[1]) satisfies (((exists(//cac:InvoiceLine[cac:Item/cac:ClassifiedTaxCategory/normalize-space(cbc:ID) = 'HVG'][cac:Item/cac:ClassifiedTaxCategory/xs:decimal((cbc:Percent, 0)[1]) =$rate]) or exists(//cac:AllowanceCharge[cac:TaxCategory/normalize-space(cbc:ID)='HVG'][cac:TaxCategory/xs:decimal((cbc:Percent, 0)[1]) = $rate])) and (u:slack(../xs:decimal(cbc:TaxableAmount), sum(../../../cac:InvoiceLine[cac:Item/cac:ClassifiedTaxCategory/normalize-space(cbc:ID)='HVG'][cac:Item/ cac:ClassifiedTaxCategory/xs:decimal((cbc:Percent, 0)[1]) =$rate]/xs:decimal(cbc:LineExtensionAmount)) + sum(../../../cac:AllowanceCharge[cbc:ChargeIndicator=true()][cac:TaxCategory/normalize-space(cbc:ID)='HVG'][cac:TaxCategory/xs:decimal((cbc:Percent, 0)[1]) = $rate]/xs:decimal(cbc:Amount)) - sum(../../../cac:AllowanceCharge[cbc:ChargeIndicator=false()][cac:TaxCategory/normalize-space(cbc:ID)='HVG'][cac:TaxCategory/xs:decimal((cbc:Percent, 0)[1]) = $rate]/xs:decimal(cbc:Amount)),0.02))) or ((exists(//cac:CreditNoteLine[cac:Item/cac:ClassifiedTaxCategory/normalize-space(cbc:ID) = 'HVG'][cac:Item/cac:ClassifiedTaxCategory/xs:decimal((cbc:Percent, 0)[1]) =$rate]) or exists(//cac:AllowanceCharge[cac:TaxCategory/normalize-space(cbc:ID)='HVG'][cac:TaxCategory/xs:decimal((cbc:Percent, 0)[1]) = $rate])) and (u:slack(../xs:decimal(cbc:TaxableAmount), sum(../../../cac:CreditNoteLine[cac:Item/cac:ClassifiedTaxCategory/normalize-space(cbc:ID)='HVG'][cac:Item/cac:ClassifiedTaxCategory/xs:decimal((cbc:Percent, 0)[1]) =$rate]/xs:decimal(cbc:LineExtensionAmount)) + sum(../../../cac:AllowanceCharge[cbc:ChargeIndicator=true()][cac:TaxCategory/normalize-space(cbc:ID)='HVG'][cac:TaxCategory/xs:decimal((cbc:Percent, 0)[1]) = $rate]/xs:decimal(cbc:Amount)) - sum(../../../cac:AllowanceCharge[cbc:ChargeIndicator=false()][cac:TaxCategory/normalize-space(cbc:ID)='HVG'][cac:TaxCategory/xs:decimal((cbc:Percent, 0)[1]) = $rate]/xs:decimal(cbc:Amount)),0.02))))

Checked with PINT MY Invoice, PINT MY Credit Note