Skip to content

fix(budget-tracker): use Decimal for precision, add edit & delete-by-…#1719

Closed
Rachi-collab wants to merge 1 commit into
steam-bell-92:mainfrom
Rachi-collab:fix/budget-tracker-decimal-edit-delete-1718
Closed

fix(budget-tracker): use Decimal for precision, add edit & delete-by-…#1719
Rachi-collab wants to merge 1 commit into
steam-bell-92:mainfrom
Rachi-collab:fix/budget-tracker-decimal-edit-delete-1718

Conversation

@Rachi-collab

Copy link
Copy Markdown

What

  • Replaced all float usage with decimal.Decimal for monetary values to eliminate floating-point precision errors (e.g. 0.1 + 0.2 no longer gives 0.30000000000000004)
  • Added edit_transaction() — lets users update category, description, amount, or type of any existing entry by ID without touching other records
  • Added delete_transaction() — lets users remove a single transaction by ID after confirmation
  • Added an id column to the CSV schema; existing files without it are auto-migrated on startup

Why

Fixes all three issues reported in #1718:

  • Financial calculations were imprecise due to float arithmetic
  • There was no way to correct a wrong entry without wiping everything
  • There was no way to remove one transaction selectively

How

  • Decimal with ROUND_HALF_UP to 2 decimal places is used everywhere amounts are read, stored, or calculated
  • save_all_transactions() rewrites the full CSV atomically, used by both edit and delete
  • next_id() generates auto-incrementing integer IDs; initialize_file() detects and backfills IDs in old CSV files for backward compatibility
  • Menu options renumbered: Edit → 6, Delete single → 7, Clear all → 8, Exit → 9

Testing

  • Added income and expense entries and verified totals are exact with no floating-point drift
  • Edited individual fields (category, description, amount, type) one at a time; pressing Enter skips and keeps the original value
  • Deleted a single transaction by ID and confirmed all other entries remain intact
  • Ran python -m py_compile to verify no syntax errors
  • Tested auto-migration: ran the updated script against an old CSV (no id column) and confirmed IDs were backfilled correctly

Closes #1718

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

@Rachi-collab is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@steam-bell-92

Copy link
Copy Markdown
Owner

@Rachi-collab not your assigned issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the transaction management and financial data accuracy

2 participants