I documenti di fatturazione commerciale devono mantenere un'assoluta coerenza matematica fino alla minima frazione monetaria. Di seguito e riportato lo schema dati JSON operativo che rappresenta una sessione di fatturazione attiva all'interno di Utiliome:
{
"meta": {
"invoiceNumber": "INV-2026-0891",
"issueDate": "2026-11-07",
"dueDate": "2026-12-07",
"currency": "EUR",
"currencySymbol": "€"
},
"issuer": {
"name": "Apex Cloud Architecture S.r.l.",
"address": "Via Monte Napoleone 14",
"city": "20121 Milano MI",
"taxId": "IT12345678901"
},
"client": {
"name": "Nexus Global Logistics S.p.A.",
"address": "Corso Vittorio Emanuele II 88",
"city": "00186 Roma RM",
"taxId": "IT98765432109"
},
"items": [
{
"description": "Audit di sicurezza dell'infrastruttura e hardening",
"quantity": 40,
"unitRate": 225.00,
"amount": 9000.00
},
{
"description": "Configurazione cluster Kubernetes Zero-Trust",
"quantity": 1,
"unitRate": 4500.00,
"amount": 4500.00
}
],
"financials": {
"subtotal": 13500.00,
"discountPercent": 5.0,
"discountAmount": 675.00,
"taxPercent": 22.0,
"taxAmount": 2821.50,
"total": 15646.50
}
}
Per prevenire le imprecisioni di arrotondamento in virgola mobile dello standard IEEE 754 (come 0.1 + 0.2 === 0.30000000000000004), i calcoli vengono eseguiti nelle unita monetarie minime intere (centesimi):
const subtotalCents = items.reduce((sum, item) => {
return sum + Math.round(item.quantity * item.unitRate * 100);
}, 0);
const discountCents = Math.round(subtotalCents * (discountPercent / 100));
const taxableCents = subtotalCents - discountCents;
const taxCents = Math.round(taxableCents * (taxPercent / 100));
const totalCents = taxableCents + taxCents;