वाणिज्यिक बिलिंग दस्तावेज़ों को मुद्रा की सबसे छोटी भिन्नात्मक इकाई तक सटीक गणितीय निरंतरता बनाए रखनी चाहिए। नीचे Utiliome के भीतर एक सक्रिय इनवॉइस सत्र का प्रतिनिधित्व करने वाला परिचालन JSON डेटा स्कीमा दिया गया है:
{
"meta": {
"invoiceNumber": "INV-2026-0891",
"issueDate": "2026-11-07",
"dueDate": "2026-12-07",
"currency": "USD",
"currencySymbol": "$"
},
"issuer": {
"name": "Apex Cloud Architecture LLC",
"address": "100 Montgomery St, Suite 1400",
"city": "San Francisco, CA 94104",
"taxId": "US-EIN-94-3829102"
},
"client": {
"name": "Nexus Global Logistics Inc",
"address": "450 Lexington Ave, 8th Floor",
"city": "New York, NY 10017",
"taxId": "US-EIN-13-8829104"
},
"items": [
{
"description": "Infrastructure Security Audit & Hardening",
"quantity": 40,
"unitRate": 225.00,
"amount": 9000.00
},
{
"description": "Zero-Trust Kubernetes Cluster Configuration",
"quantity": 1,
"unitRate": 4500.00,
"amount": 4500.00
}
],
"financials": {
"subtotal": 13500.00,
"discountPercent": 5.0,
"discountAmount": 675.00,
"taxPercent": 8.5,
"taxAmount": 1090.13,
"total": 13915.13
}
}
IEEE 754 फ्लोटिंग-पॉइंट राउंडिंग अशुद्धियों (जैसे 0.1 + 0.2 === 0.30000000000000004) को रोकने के लिए, गणनाओं को पूर्णांक लघु मुद्रा इकाइयों (सेंट) में संसाधित किया जाता है:
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;