XRechnung 2.6.0 · UBL

BR-DEX-09

XRechnung 2.6.0 · UBL

fatalcountry

Original rule text

[BR-DEX-09] Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) - Paid amount (BT-113) + Rounding amount (BT-114) + Σ Third party payment amount (BT-DEX-002).

Stored validation assertion
(round((xs:decimal(cbc:PayableAmount) - $payableroundingamount) * 10 * 10) div 100) = (round((xs:decimal(cbc:TaxInclusiveAmount) - $prepaidamount + $thirdpartyprepaidamount) * 10 * 10) div 100)

What this rule requires

The rule checks a financial total in an extended XRechnung: after rounding to two decimals, cbc:PayableAmount minus cbc:PayableRoundingAmount must equal cbc:TaxInclusiveAmount minus cbc:PrepaidAmount plus the sum of all sibling cac:PrepaidPayment/cbc:PaidAmount values. If cbc:PayableRoundingAmount or cbc:PrepaidAmount is absent, it is treated as zero; the third-party prepayment sum is zero only when no cac:PrepaidPayment/cbc:PaidAmount has a non-whitespace value. The document fails when the amounts in cac:LegalMonetaryTotal are not consistent with this equation.

How to fix

Adjust the amounts in cac:LegalMonetaryTotal so that the equation holds after rounding to two decimals. Typically set cbc:PayableAmount = cbc:TaxInclusiveAmount - cbc:PrepaidAmount + cbc:PayableRoundingAmount + sum of all cac:PrepaidPayment/cbc:PaidAmount. Check each involved element for an incorrect value or a missing third-party prepayment amount. Round the result to two decimals before comparing.

Guidance on this rule. The original text above is authoritative.