# F-LIB402

Source: https://xmlvalid.com/rules/F-LIB402

> The taxable amount on the … when currency: '…', Tax Category ID: '…' and Tax Scheme ID: '…', does not match the sum of taxable amounts from the invoice or credit note lines, after adjusting for allowances (discounts) and charges (fees). A rounding difference of up to +/- 1 is allowed. Values found: - Taxable amount on the …: … - Calculated taxable amount (sum of lines adjusted for discounts and charges): … - Difference: …

- Level: error
- Rule sets: OIOUBL 2.1 Invoice rules (Denmark) 1.17.2, OIOUBL 2.1 Credit Note rules (Denmark) 1.17.2, OIOUBL 2.1 Reminder rules (Denmark) 1.17.2
- Test: `(not(current()/cac:TaxCategory/cbc:ID = 'StandardRated' or current()/cac:TaxCategory/cbc:ID = 'ZeroRated' or current()/cac:TaxCategory/cbc:ID = 'ReverseCharge')) or ( not(exists(../../cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ])) and not(exists(../../cac:CreditNoteLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ])) or abs(xs:decimal(cbc:TaxableAmount) - ( sum(../../cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:TaxableAmount) + sum(../../cac:CreditNoteLine/cac:TaxTotal/cac:TaxSubtotal[ cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cbc:TaxableAmount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:TaxableAmount) - sum(../../cac:AllowanceCharge[ cbc:ChargeIndicator = false() and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:Amount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:Amount) + sum(../../cac:AllowanceCharge[ cbc:ChargeIndicator = true() and cac:TaxCategory/cbc:ID = current()/cac:TaxCategory/cbc:ID and cac:TaxCategory/cac:TaxScheme/cbc:ID = current()/cac:TaxCategory/cac:TaxScheme/cbc:ID and cbc:Amount/@currencyID = current()/cbc:TaxableAmount/@currencyID ]/cbc:Amount) )) <= 1 )`

Validate a document against these rules: https://xmlvalid.com/validate
