build_dati_generali
Build the mandatory DatiGenerali block for an Italian electronic invoice (FatturaPA). Use after validating the cessionario and before adding line items. Validates document type, date, and invoice number.
Instructions
Build the DatiGenerali block required in every FatturaElettronicaBody.
Use this as step 6 in the invoice generation workflow, after validate_cessionario() and before add_linea_dettaglio(). Call get_tipo_documento_codes() first to select the correct TD code (most invoices use TD01; credit notes use TD04; professional fee invoices use TD06).
For credit notes (TD04) or debit notes (TD05), set id_documento_riferimento to the original invoice number and data_documento_riferimento to its issue date.
Validates: tipo_documento must be a valid TD01–TD28 code; data must be YYYY-MM-DD; numero must not exceed 20 characters.
On success returns {'DatiGenerali': {...}} ready for generate_fattura_xml(). On failure returns {'error': ''}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tipo_documento | Yes | Document type code TD01–TD28. Use get_tipo_documento_codes() for the full list. Most invoices use TD01 (standard invoice). | |
| data | Yes | Invoice date in ISO 8601 format (YYYY-MM-DD), e.g. '2026-01-15'. Must not be a future date for ordinary invoices. | |
| numero | Yes | Invoice number (Numero), max 20 alphanumeric chars. Must be unique and sequential per fiscal year. | |
| divisa | No | ISO 4217 currency code. Default 'EUR'. Other currencies for cross-border invoices. | EUR |
| causale | No | Optional free-text description/reason for the invoice (Causale), max 200 chars. Can appear multiple times — pass a single string here. | |
| rif_numero_linea | No | Line number reference for credit/debit notes linking back to the original invoice. | |
| id_documento_riferimento | No | Number of the original invoice (for credit notes TD04, debit notes TD05, etc.). | |
| data_documento_riferimento | No | Date of the original invoice (YYYY-MM-DD), for TD04/TD05. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||