generate_fattura_xml
Assemble a complete FatturaPA v1.2.3 XML document from all prepared blocks: transmission header, seller, buyer, document data, line items, and VAT summary. Returns the XML string and filename for final validation.
Instructions
Assemble a complete FatturaPA v1.2.3 XML document from all prepared blocks.
Use this as step 10 in the invoice generation workflow — the final assembly step. All required blocks must come from their respective builder/validator tools; pass the full dict returned by each tool (the function unwraps the top-level key).
Required: dati_trasmissione, cedente_prestatore, cessionario_committente, dati_generali, dettaglio_linee (list), dati_riepilogo (list from compute_totali()). Optional: dati_pagamento, allegati (list), dati_ritenuta.
Does NOT validate against the XSD schema — call validate_fattura_xsd() (step 11) on the returned 'xml' string immediately after to confirm conformance.
On success returns {'xml': str, 'filename': str, 'formato_trasmissione': str, 'length_bytes': int}. On unexpected error returns {'error': ''}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dati_trasmissione | Yes | DatiTrasmissione block from build_transmission_header(). Must contain IdTrasmittente, ProgressivoInvio, FormatoTrasmissione, and CodiceDestinatario. | |
| cedente_prestatore | Yes | CedentePrestatore block from validate_cedente_prestatore(). Contains seller's tax ID, name, address, and fiscal regime. | |
| cessionario_committente | Yes | CessionarioCommittente block from validate_cessionario(). Contains buyer's tax ID, name, and address. | |
| dati_generali | Yes | DatiGenerali block from build_dati_generali(). Contains document type, date, number, and currency. | |
| dettaglio_linee | Yes | List of DettaglioLinee dicts from add_linea_dettaglio(). Each entry must have NumeroLinea, Descrizione, PrezzoUnitario, PrezzoTotale, and AliquotaIVA. | |
| dati_riepilogo | Yes | List of DatiRiepilogo dicts from compute_totali(). Contains VAT summary grouped by AliquotaIVA. | |
| dati_pagamento | No | DatiPagamento block from build_dati_pagamento(). Optional. | |
| allegati | No | List of Allegati dicts from add_allegato(). Optional. | |
| dati_ritenuta | No | DatiRitenuta block from check_ritenuta_acconto(). Required for professional invoices with withholding tax (ritenuta d'acconto). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||