MEDIUM: Floating-point REAL type for monetary amounts in SQLite #75
Labels
No Label
architecture
backend
bug
feature
frontend
priority:critical
priority:high
priority:low
priority:medium
priority:nice-to-have
ux
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: null/BillTracker#75
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug Description
Multiple money-related columns in the database use REAL (IEEE 754 double-precision floating point) in SQLite:
Floating-point arithmetic introduces rounding errors (e.g., 0.1 + 0.2 !== 0.3). Some code mitigates this with toFixed() and Math.round(), but its inconsistent across the codebase.
Notably, transactions.amount uses INTEGER (presumably cents) while payments.amount uses REAL, creating an inconsistency that could cause comparison failures.
Impact
Pennies-level rounding discrepancies in financial calculations over time.
Recommended Fix
Long-term: migrate all monetary columns to INTEGER (cents) and convert in the API layer. Short-term: ensure all monetary arithmetic uses Math.round(result * 100) / 100 consistently.
closed v0.34.2.1