Skip to content

Commit 1cfe3d0

Browse files
authored
Merge branch 'main' into feature/centralized-error-handling-complete
2 parents 6aa89ea + 43e1e58 commit 1cfe3d0

13 files changed

Lines changed: 3720 additions & 7 deletions

File tree

ai-connector/mcp-browser-openai-4o-v1/hetzner/hetzner.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"meta": {
33
"schemaVersion": "1.0.0",
44
"mcpVersion": "mcp-browser-openai-4o-v1",
5-
"created_at": "2025-07-10T14:38:10.890Z",
6-
"updated_at": "2025-07-10T14:38:10.890Z",
5+
"created_at": "2025-07-28T14:16:50.069Z",
6+
"updated_at": "2025-07-28T14:16:50.069Z",
77
"country": [
8-
"US"
8+
"FR"
99
]
1010
},
1111
"data": {
1212
"type": "blueprint",
13-
"id": "b130ac18-04b5-4185-ad5f-e907b1f457b4",
13+
"id": "09ba0c9a-30b7-4237-b91c-b206a10797cb",
1414
"attributes": {
1515
"encrypted": {
1616
"iv": "69f316062bacbd3d45415bb1eaff8c5e",
17-
"content": "57c535501c3be97b250bde2d3947af4295bd1b4467528bd62e72a640aa41cdba7f34a033e83fc89e2b1a3365b41a29c1b2e193bd8f3f2ba303a63bfcba5fd10a99538f2ac0934499f76886cb9ef879d57dc547a2613c0a9fb972e289a7c29f0d4f05338ed400f1466e332526f31dcba2493f943a49e7b9f4c202dced51d906d77813a3f7c25d2eb7aa0abc018a349e2f9a6360b7ea82e3314021e822e66c0a4c51e11825dc548b80da2b270b48fa33c712ce0d1d5d312590df67380fa9d1e50d03f358fd3144ee98181d12e2e7472f9d9d13bbd319d6f85c54daaf69cf67c72271b3635e026ed546e750b4d725606a4f087ec0277115e38c0060d9f8317385622f7fa3535b57771938331f3e2263cb01298c2a904ad6b90df81e4d967b3d8fd33585dbfab961e9763be48b45968f6cacc37983f86d7cc30c5722381ed12dfb53db3ffc28ef7bb266ef7904b13936183074d4304b5244d7f8bc3f21ea56e1595515a547a7f38dc85420629a836dbc417b9cf3563ffe1e10f42075d8b76a5aec2d08f97f9c8035d8d1d533f26597f162c8d972a3df5c71440b487a5912392bc8678892c4f43124c9dac7c1e65c8840470594b8ca1942707e3299624e2bcbaa3fddd2e44e39a8dd278f7815b49bac059efdff07e9798925fd2a46be4583d403c352839ea3865a9428eda5b6134550e718df"
17+
"content": "57c535501c3be97b250bde2d3947af4295bd1b4467528bd62e72a640aa41cdba7f34a033e83fc89e2b1a3365b41a29c13e9de923173360a4e69cf7c9924544b88f629ea5de8d6ffb8bfbed56b923d35a245600d92140186016fc62b132265e565fe50c0efc69af92e29bb7cefb7c4b7fd95f44e4cf0a240963d6296483f2eaeb6126a8d55b2e37c460c95bfcadfcf1a078c9c968dcc8d774cce373ea75b77a5e939a6b73d7435b1a302c6f708a9c537077f28bf45b037a8df0fb0a96ef5036bfc22d8193206291768d8f38b1d0ddae23d4c74cb300b00576a1ed78d159f6ce9dd906937a4b6adc6016cc99ca3bd31ec6766d2b9dae7bf5b8a51976ba07fa0de4c5a0070e71f63f8de1e4ee4b975eaa77237d076621d2c18af4cfab08c2c981ca"
1818
}
1919
}
2020
}

ai-invoice-extractor/README.md

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626

2727
- 🔍 Extract invoice/receipt data
2828
- 🧠 Choose your AI models (OpenAI, Mistral, Anthropic, Google Gemini, and Ollama)
29+
- 🇮🇹 **Full FatturaPA support** for Italian e-invoicing (TD01, TD17-TD19)
2930
- 🔧 Set AI keys with CLI and environment variables
3031
- ⭐ Pretty print the output
3132
- 🔄 Pipe output with other CLI
33+
- 📄 Export to XML/JSON formats
34+
- 🏛️ Public Administration support (CIG/CUP codes)
3235

3336
## Usage
3437

@@ -117,6 +120,23 @@ export EXTRACTOR_API_KEY=sk-your-openai-key
117120
npx ai-invoice-extractor invoice.pdf
118121
```
119122

123+
#### FatturaPA (Italian E-Invoicing)
124+
```sh
125+
# Extract FatturaPA data with full Italian e-invoicing support
126+
npx ai-invoice-extractor -k sk-key -p fattura.pdf
127+
128+
# Export to FatturaPA XML format
129+
npx ai-invoice-extractor -k sk-key fattura.pdf | node -e "
130+
const { FatturapaXmlExporter } = require('./dist/exporters');
131+
const exporter = new FatturapaXmlExporter();
132+
const data = JSON.parse(require('fs').readFileSync(0, 'utf8'));
133+
console.log(exporter.export(data));
134+
"
135+
136+
# Extract cross-border invoice (TD18)
137+
npx ai-invoice-extractor -k sk-key crossborder-invoice.pdf
138+
```
139+
120140
#### Different AI Vendors
121141
```sh
122142
# Mistral AI
@@ -171,6 +191,236 @@ The CLI provides helpful error messages for common issues:
171191
- **Documents:** PDF
172192
- **File size:** Up to 20MB (varies by AI provider)
173193

194+
## FatturaPA (Italian E-Invoicing) Support
195+
196+
The AI Invoice Extractor provides comprehensive support for FatturaPA, the Italian electronic invoicing standard mandated by the Agenzia delle Entrate (Italian Revenue Agency).
197+
198+
### Supported Document Types
199+
200+
| Code | Description | Support |
201+
|------|-------------|---------|
202+
| **TD01** | Domestic invoice | ✅ Full support |
203+
| **TD17** | Domestic reverse charge integration | ✅ Full support |
204+
| **TD18** | Intra-EU purchase integration | ✅ Full support |
205+
| **TD19** | Extra-EU purchase integration | ✅ Full support |
206+
| **TD20-27** | Specialized invoice types | ✅ Basic support |
207+
208+
### Key Features
209+
210+
- **🏢 Complete Party Data:** Italian VAT IDs, Codice Fiscale, REA registration, PEC addresses
211+
- **🌍 Cross-Border Support:** Foreign VAT IDs, tax representatives, currency conversion
212+
- **💰 Tax Compliance:** All Italian VAT rates, nature codes (N1-N7), withholding taxes
213+
- **🏛️ Public Administration:** CIG/CUP codes, office codes, administrative references
214+
- **📋 Line Items:** Product codes, service periods, discounts, custom information
215+
- **💳 Payment Terms:** All Italian payment methods (MP01-MP22), IBAN/BIC, installments
216+
- **📎 References:** Order numbers, contracts, transport documents
217+
- **🔧 Export Formats:** SDI-compliant XML, structured JSON, validation format
218+
219+
### Extracted Fields
220+
221+
The extractor captures **300+ fields** including:
222+
223+
#### Document Header
224+
- Document type code (TD01, TD17-TD19, etc.)
225+
- Invoice number, issue date, due date
226+
- Currency code and exchange rates (for cross-border)
227+
- Transmission format and country codes
228+
229+
#### Party Information (Supplier & Customer)
230+
- Legal name and form
231+
- Italian VAT ID (`IT` + 11 digits) and Tax ID (Codice Fiscale)
232+
- Foreign VAT IDs for cross-border transactions
233+
- Complete addresses with Italian province codes
234+
- Contact information (phone, email, PEC)
235+
- REA registration details (office, number, share capital)
236+
- Tax representative information (for foreign suppliers)
237+
238+
#### Tax Details
239+
- Multiple VAT rates and amounts
240+
- Nature codes for exemptions (N1-N7 with descriptions)
241+
- Withholding taxes (RT01, RT02 types)
242+
- Administrative references for PA invoices
243+
244+
#### Line Items
245+
- Descriptions, quantities, unit prices, totals
246+
- Discounts and markups (percentage and amount)
247+
- VAT rates per line item
248+
- Product codes (EAN, internal, etc.)
249+
- Service periods (start/end dates)
250+
- Cross-border customs information
251+
252+
#### Payment Information
253+
- Payment conditions (TP01-TP03)
254+
- Payment methods (MP01-MP22)
255+
- Bank details (IBAN, BIC, bank name)
256+
- Installment schedules
257+
- Early payment discounts and late penalties
258+
259+
#### References & Additional Data
260+
- CIG (tender codes) and CUP (project codes) for PA
261+
- Order numbers and contract references
262+
- Transport and delivery information
263+
- Digital signature details
264+
- Attachments and notes
265+
266+
### Usage Examples
267+
268+
#### Basic FatturaPA Extraction
269+
```sh
270+
# Extract Italian domestic invoice
271+
npx ai-invoice-extractor -k sk-key fattura-domestica.pdf
272+
273+
# Extract cross-border invoice (German supplier to Italian customer)
274+
npx ai-invoice-extractor -k sk-key fattura-crossborder.pdf
275+
276+
# Extract with pretty formatting
277+
npx ai-invoice-extractor -k sk-key -p fattura.pdf
278+
```
279+
280+
#### Programmatic Usage
281+
```javascript
282+
import { Extractor } from 'ai-invoice-extractor';
283+
import { FatturapaXmlExporter, FatturapaJsonExporter } from 'ai-invoice-extractor/exporters';
284+
285+
// Extract invoice data
286+
const extractor = Extractor.create({
287+
vendor: 'openai',
288+
model: 'gpt-4o',
289+
apiKey: 'sk-your-key'
290+
});
291+
292+
const invoiceData = await extractor.analyseFile({
293+
path: 'fattura.pdf',
294+
prompt: 'EXTRACT_INVOICE_FATTURAPA',
295+
output: fatturapaInvoiceSchema
296+
});
297+
298+
// Export to XML (SDI-compliant)
299+
const xmlExporter = new FatturapaXmlExporter({
300+
formatOutput: true,
301+
validateRequired: true
302+
});
303+
const xml = xmlExporter.export(invoiceData);
304+
305+
// Export to JSON (structured)
306+
const jsonExporter = new FatturapaJsonExporter({
307+
includeMetadata: true,
308+
cleanNullValues: true
309+
});
310+
const json = jsonExporter.export(invoiceData);
311+
312+
// Export for validation
313+
const validationJson = jsonExporter.exportForValidation(invoiceData);
314+
```
315+
316+
#### XML Output Sample
317+
```xml
318+
<?xml version="1.0" encoding="UTF-8"?>
319+
<ns2:FatturaElettronica versione="FPR12" xmlns:ns2="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2">
320+
<FatturaElettronicaHeader>
321+
<DatiTrasmissione>
322+
<IdTrasmittente>
323+
<IdPaese>IT</IdPaese>
324+
<IdCodice>12345678901</IdCodice>
325+
</IdTrasmittente>
326+
<FormatoTrasmissione>FPR12</FormatoTrasmissione>
327+
</DatiTrasmissione>
328+
<CedentePrestatore>
329+
<DatiAnagrafici>
330+
<IdFiscaleIVA>
331+
<IdPaese>IT</IdPaese>
332+
<IdCodice>IT12345678901</IdCodice>
333+
</IdFiscaleIVA>
334+
<Anagrafica>
335+
<Denominazione>Tech Solutions S.r.l.</Denominazione>
336+
</Anagrafica>
337+
</DatiAnagrafici>
338+
</CedentePrestatore>
339+
</FatturaElettronicaHeader>
340+
<FatturaElettronicaBody>
341+
<DatiGenerali>
342+
<DatiGeneraliDocumento>
343+
<TipoDocumento>TD01</TipoDocumento>
344+
<Divisa>EUR</Divisa>
345+
<Data>2024-03-15</Data>
346+
<Numero>INV-2024-001</Numero>
347+
</DatiGeneraliDocumento>
348+
</DatiGenerali>
349+
<!-- ... more XML content ... -->
350+
</FatturaElettronicaBody>
351+
</ns2:FatturaElettronica>
352+
```
353+
354+
#### JSON Output Sample
355+
```json
356+
{
357+
"header": {
358+
"transmission": {
359+
"sender_country": "IT",
360+
"sender_code": "IT12345678901",
361+
"format": "FPR12"
362+
},
363+
"supplier": {
364+
"identification": {
365+
"vat_id": "IT12345678901",
366+
"tax_id": "12345678901"
367+
},
368+
"legal_info": {
369+
"name": "Tech Solutions S.r.l."
370+
},
371+
"address": {
372+
"street": "Via Roma",
373+
"city": "Milano",
374+
"postal_code": "20121",
375+
"province": "MI",
376+
"country": "IT"
377+
}
378+
}
379+
},
380+
"body": {
381+
"general_data": {
382+
"document_type": "TD01",
383+
"currency": { "code": "EUR" },
384+
"date": "2024-03-15",
385+
"number": "INV-2024-001",
386+
"totals": {
387+
"taxable_amount": 1000.00,
388+
"vat_amount": 220.00,
389+
"total_amount": 1220.00
390+
}
391+
},
392+
"line_items": [
393+
{
394+
"line_number": 1,
395+
"description": "Servizi di consulenza IT",
396+
"quantity": 1,
397+
"unit_price": 1000.00,
398+
"total_price": 1000.00,
399+
"vat": {
400+
"rate": 22.00,
401+
"amount": 220.00
402+
}
403+
}
404+
]
405+
}
406+
}
407+
```
408+
409+
### Validation & Compliance
410+
411+
The XML exporter generates output that is:
412+
-**SDI Compliant:** Validates against Italian Sistema di Interscambio
413+
-**Schema Valid:** Follows FatturaPA XSD 1.2.1 specification
414+
-**Tax Authority Ready:** Can be submitted directly to Agenzia delle Entrate
415+
-**Cross-Border Ready:** Handles TD17-TD19 scenarios correctly
416+
417+
### Examples & Testing
418+
419+
The repository includes comprehensive examples:
420+
- `examples/fatturapa/domestic-invoice-sample.json` - Italian domestic invoice (TD01)
421+
- `examples/fatturapa/crossborder-invoice-sample.json` - Cross-border invoice (TD18)
422+
- Complete test suite with 15+ scenarios covering all document types
423+
174424
## Contributing
175425

176426
We use [Bun](https://bun.sh/) instead of npm:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# FatturaPA Examples
2+
3+
This directory contains sample invoices in various formats demonstrating FatturaPA support:
4+
5+
## Domestic Invoices (TD01)
6+
- `domestic-invoice-sample.json` - Sample Italian domestic invoice
7+
- `domestic-invoice-golden.xml` - Expected XML output
8+
- `domestic-invoice-golden.json` - Expected JSON output
9+
10+
## Cross-Border Invoices (TD17-TD19)
11+
- `crossborder-invoice-sample.json` - Sample cross-border invoice
12+
- `crossborder-invoice-golden.xml` - Expected XML output
13+
- `crossborder-invoice-golden.json` - Expected JSON output
14+
15+
## Public Administration
16+
- `pa-invoice-sample.json` - Sample PA invoice with CIG/CUP codes
17+
- `pa-invoice-golden.xml` - Expected XML output
18+
- `pa-invoice-golden.json` - Expected JSON output
19+
20+
## Usage
21+
22+
These examples can be used for:
23+
- Testing the FatturaPA extraction and export functionality
24+
- Validating output against Italian SDI requirements
25+
- Understanding the complete FatturaPA data structure
26+
- Development and integration testing

0 commit comments

Comments
 (0)