# SDI-00422

Source: https://xmlvalid.com/rules/SDI-00422

> 2.2.2.5 <ImponibileImporto> non calcolato secondo le regole definite nelle specifiche tecniche

- Level: error
- Rule sets: SdI checks (FatturaPA ordinary invoice) Specifiche tecniche 1.9.1
- Context: `/p:FatturaElettronica/FatturaElettronicaBody`
- Test: `every $r in distinct-values(($rates, for $s in $summaries/AliquotaIVA return it:dec($s))) satisfies abs(sum(for $s in $summaries[it:dec(AliquotaIVA) = $r] return it:dec($s/ImponibileImporto)) - sum(for $l in $lines[it:dec(AliquotaIVA) = $r] return it:dec($l/PrezzoTotale)) - sum(for $f in $funds[it:dec(AliquotaIVA) = $r] return it:dec($f/ImportoContributoCassa)) - sum(for $s in $summaries[it:dec(AliquotaIVA) = $r] return it:dec($s/Arrotondamento))) le 1`

In English: For a VAT rate, the taxable amounts of the summaries (ImponibileImporto, 2.2.2.5) do not add up to the line totals at that rate, plus the pension fund contributions and the summaries' Arrotondamento, within one euro.

## Why it fails

- A line was changed or added after the summary was calculated.
- A pension fund contribution (`DatiCassaPrevidenziale`) at that rate was left out of `ImponibileImporto`.
- A document level discount (`ScontoMaggiorazione` in `DatiGeneraliDocumento`) was subtracted from the summary; the SdI adds up the lines only, so a discount has to be a line or go into `Arrotondamento`.

## How to fix it

- For each rate, make `ImponibileImporto` the sum of `PrezzoTotale` of the lines at that rate plus `ImportoContributoCassa` at that rate, and put any rounding difference in `Arrotondamento`.

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