Handlowe dokumenty rozliczeniowe muszą zachowywać bezwzględną spójność matematyczną aż do najmniejszej jednostki ułamkowej waluty. Poniżej przedstawiono schemat danych JSON reprezentujący aktywną sesję faktury w Utiliome:
{
"meta": {
"invoiceNumber": "INV-2026-0891",
"issueDate": "2026-11-07",
"dueDate": "2026-12-07",
"currency": "PLN",
"currencySymbol": "zł"
},
"issuer": {
"name": "Apex Cloud Architecture Sp. z o.o.",
"address": "ul. Prosta 20",
"city": "00-850 Warszawa",
"taxId": "PL5252819201"
},
"client": {
"name": "Nexus Global Logistics S.A.",
"address": "al. Jerozolimskie 100",
"city": "02-011 Warszawa",
"taxId": "PL5261048291"
},
"items": [
{
"description": "Audyt bezpieczeństwa i utwardzanie infrastruktury",
"quantity": 40,
"unitRate": 225.00,
"amount": 9000.00
},
{
"description": "Konfiguracja klastra Kubernetes Zero-Trust",
"quantity": 1,
"unitRate": 4500.00,
"amount": 4500.00
}
],
"financials": {
"subtotal": 13500.00,
"discountPercent": 5.0,
"discountAmount": 675.00,
"taxPercent": 23.0,
"taxAmount": 2949.75,
"total": 15774.75
}
}
Aby zapobiec niedokładnościom zaokrągleń liczb zmiennoprzecinkowych IEEE 754 (takim jak 0.1 + 0.2 === 0.30000000000000004), obliczenia są przetwarzane na całkowitych jednostkach ułamkowych (groszach lub centach):
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;