# PEPPOL-EN16931-R054

Source: https://xmlvalid.com/rules/PEPPOL-EN16931-R054

> Only one tax total without tax subtotals MUST be provided when tax currency code is provided.

- Level: error
- Rule sets: Peppol BIS Billing 3.0 rules 3.0.21, XRechnung 3.0 rules (UBL) 2.6.0
- Context: `ubl-creditnote:CreditNote | ubl-invoice:Invoice`
- Test: `count(cac:TaxTotal[not(cac:TaxSubtotal)]) = (if (cbc:TaxCurrencyCode) then 1 else 0)`

> Only one tax total amount must be provided where currency id equals tax currency code, if tax currency code (BT-6) is provided.

- Level: error
- Rule sets: XRechnung 3.0 rules (CII) 2.6.0
- Context: `ram:ApplicableHeaderTradeSettlement`
- Test: `count(ram:SpecifiedTradeSettlementHeaderMonetarySummation/ram:TaxTotalAmount[@currencyID != $documentCurrencyCode]) = (if (ram:TaxCurrencyCode) then 1 else 0)`

## Why it fails

- The invoice has a VAT accounting currency (`cbc:TaxCurrencyCode`) but no second `cac:TaxTotal` with the VAT in that currency, or it has such a total without the currency code.

## How to fix it

- With a tax currency code, add a second `cac:TaxTotal` holding only `cbc:TaxAmount` in that currency, without subtotals. Without one, leave the second tax total out.

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