A Python tool to extract data from Italian electronic invoices (XML format) and create formatted Excel reports.
- Processes Italian electronic invoices in XML format
- Extracts key invoice information including:
- Invoice numbers and dates
- Supplier and customer details
- Line items with quantities and prices
- VAT rates and totals
- Generates formatted Excel reports with:
- Proper data types (dates, currencies, percentages)
- Auto-sized columns
- Formatted headers
- Euro currency symbols
- Thousand separators
- Docker Desktop (for development container)
- VS Code with Remote Development extension
- Python 3.6 or higher
- Clone the repository
- Open in VS Code
- When prompted, click "Reopen in Container" or run Command Palette (F1) > "Remote-Containers: Reopen in Container"
- Wait for the container to build and start
xml-invoices-extractor/
├── input-unsigned/ # Place your XML invoice files here
├── process_invoices.sh # Bash script to process invoices
├── xml_invoices_extractor.py
└── README.md
- Place your signed P7M invoice files in the
input
folder - Make the script executable:
chmod +x process_invoices.sh
- Run the bash script:
./process_invoices.sh
- Unsigned invoices will be available in the
input-unsigned
folder
- Place your XML invoice files in the
input-unsigned
folder (Optional if you used the Bash script) - Run the script:
python xml_invoices_extractor.py
- Find the generated Excel report (
invoice_report.xlsx
) in the project root directory
The script expects Italian electronic invoices in XML format with the following structure:
- Root element:
<p:FatturaElettronica>
- Namespace:
http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2
- Key elements:
Numero
(Invoice number)Data
(Invoice date)DettaglioLinee
(Line items)ImportoTotaleDocumento
(Total amount)
The generated Excel file includes the following columns:
- Invoice Number (text)
- Invoice Date (date format)
- Supplier Name (text)
- Customer Name (text)
- Line Number (number)
- Description (text)
- Quantity (number)
- Unit Price (currency)
- Total Price (currency)
- VAT Rate (percentage)
- Invoice Total Amount (currency)
The script includes error handling for:
- Missing XML files or folders
- Invalid XML structure
- Missing data fields
- Non-numeric values in numeric fields
- File access and permissions issues
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.