SQLite doesn't support Decimal natively - it stores DECIMAL columns as
REAL (float). This caused sqlite3.ProgrammingError when writing Decimal
values.
Changes:
- Add prepare_for_db() helper to convert Decimal→float before writes
- Add Pydantic validators to convert float→Decimal on model creation
- Update CRUD layer tests to verify float params for SQLite
- Add SQLite round-trip tests to verify precision is preserved
The data flow is now:
Decimal (calculations) → float (prepare_for_db) → SQLite → float → Decimal (validators)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- calculations.py: Use Decimal for commission percentages, exchange rates,
and client balances. Added to_decimal() helper for safe float conversion.
Changed from banker's rounding to ROUND_HALF_UP.
- models.py: Changed all fiat amounts, percentages, and exchange rates to
Decimal. Added json_encoders for API serialization.
- transaction_processor.py: Convert to Decimal at data ingestion boundary
(CSV parsing). Updated all defaults and calculations to use Decimal.
- tests: Updated to work with Decimal return types.
This prevents floating-point precision issues in financial calculations.
All 23 tests pass.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Refactor GTQ storage migration: Moved the conversion logic for centavo amounts to GTQ into a new migration function, m004_convert_to_gtq_storage, ensuring proper data type changes and updates across relevant tables. This enhances clarity and maintains the integrity of the migration process.
Refactor DCA Admin page endpoints: Update description, remove unused CRUD operations and API endpoints related to MyExtension, and streamline the code for improved clarity and functionality.
Remove QR Code dialog from MyExtension index.html: streamline the UI by eliminating unused dialog components, enhancing code clarity and maintainability.