# SDI-00423

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

> 2.2.1.11 <PrezzoTotale> 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/DatiBeniServizi/DettaglioLinee`
- Test: `abs(it:price($unit, ScontoMaggiorazione, true()) * $quantity - $total) le 0.01 or abs(it:price($unit, ScontoMaggiorazione, false()) * $quantity - $total) le 0.01`

In English: A line total (PrezzoTotale, 2.2.1.11) is not the unit price after its discounts and surcharges, times the quantity, within one cent.

## Why it fails

- Percentage discounts were added up instead of applied one after the other: the SdI applies each to the price left by the previous one.
- The line total was rounded before multiplying, or the quantity is missing (it then counts as 1).

## How to fix it

- Calculate `PrezzoTotale` as `PrezzoUnitario`, minus each `SC` and plus each `MG` in turn (an amount, or a percentage of the price so far), times `Quantita`.

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