# CFDI40167

Source: https://xmlvalid.com/rules/CFDI40167

> El valor del campo Importe no se encuentra entre el limite inferior y superior permitido (…, … × …).

- Level: error
- Rule sets: SAT validations of CFDI 4.0 and Pagos 2.0 Matrices of 25 March 2026 and Pagos 2.0 rev. B
- Context: `cfdi:Conceptos/cfdi:Concepto`
- Test: `mx:between(@Cantidad, @ValorUnitario, true(), @Importe)`

In English: A line's Importe must be Cantidad times ValorUnitario, within the limits Anexo 20 computes from the decimals written: (Cantidad - half a unit) × (ValorUnitario - half a unit) truncated, up to (Cantidad + half a unit) × (ValorUnitario + half a unit) rounded up.

## Why it fails

- The amount was computed from a price with more decimals than the one written in ValorUnitario.
- A discount subtracted from Importe instead of being given in Descuento.

## How to fix it

- Give ValorUnitario with the decimals the computation used (up to six), Importe as Cantidad times ValorUnitario, and the discount in the line's Descuento.

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