# DT-CIUS-PT-161

Source: https://xmlvalid.com/rules/DT-CIUS-PT-161

> Sum of allowances on document level (BT-107) = Σ Document level allowance amount (BT-92), with an acceptance range of 1.00 € (it does not mean that this tolerance is accepted by the customer).

- Level: error
- Rule sets: CIUS-PT rules (Portugal, UBL) 2.1.1
- Context: `cac:LegalMonetaryTotal`
- Test: `(exists(../cac:AllowanceCharge[cbc:ChargeIndicator='false']) and (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator='false']/xs:decimal(cbc:Amount)) * 10 * 10) div 100) <= (xs:decimal(cbc:AllowanceTotalAmount) + 1.00) and (round(sum(../cac:AllowanceCharge[cbc:ChargeIndicator='false']/xs:decimal(cbc:Amount)) * 10 * 10) div 100) >= (xs:decimal(cbc:AllowanceTotalAmount) - 1.00)) or (not(exists(../cac:AllowanceCharge[cbc:ChargeIndicator='false'])) and xs:decimal(cbc:AllowanceTotalAmount) = 0.00) or not(cbc:AllowanceTotalAmount)`

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