compute_totali
Computes VAT summary totals (DatiRiepilogo) from invoice line items grouped by VAT rate and nature, providing imponibile, imposta, and total amounts.
Instructions
Compute DatiRiepilogo VAT summary totals grouped by AliquotaIVA and Natura.
Use this as step 8 in the invoice generation workflow, after all add_linea_dettaglio() calls and before generate_fattura_xml(). Pass the raw line values (not the DettaglioLinee dicts): each item needs 'prezzo_totale' (float), 'aliquota_iva' (float), and optionally 'natura' (str).
Groups lines by (aliquota_iva, natura) pair, sums imponibile, and computes imposta = imponibile × aliquota / 100 (rounded HALF_UP to 2 decimal places). EsigibilitaIVA defaults to 'I' (immediata) for all groups.
Always succeeds (empty list produces empty DatiRiepilogo). Returns: {'DatiRiepilogo': [...], 'totale_imponibile': str, 'totale_imposta': str, 'totale_fattura': str}. Pass 'DatiRiepilogo' directly to generate_fattura_xml() as dati_riepilogo.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| linee | Yes | List of line item dicts, each containing at least: 'prezzo_totale' (float), 'aliquota_iva' (float), and optionally 'natura' (str). These are the raw values, not the DettaglioLinee dicts. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||