feat: expense tracker Python parity (Wave 10)
Some checks failed
Python CI / pytest (ubuntu-latest) (push) Has been cancelled
Python CI / pytest (windows-latest) (push) Has been cancelled
Python CI / ruff (push) Has been cancelled

New `expenses_handlers.py`:
- parse_expense(phrase) -> (amount, category) | None  — pure fn, fully
  unit-tested. Handles "потратил 500 на еду", comma decimals "12,50",
  EN "spent 12.5 on coffee", default category "разное".
- do_expenses_log: append entry to expenses.json (atomic write-then-rename).
- do_expenses_today: sum today's entries (local-day boundary).
- do_expenses_week: rolling 7-day total + count.
- do_expenses_breakdown: per-category, top-5 + tail collapse.

extensions.py / main.py / commands.yaml: 4 new dispatch entries.
.gitignore: + expenses.json.

tests/test_expenses_handlers.py: 8 unit tests covering parse, log,
today/week math, breakdown ordering + tail collapse.

Tests: 96 → 104 (+8). Total Python coverage now mirrors Rust pack
behaviour for personal finance.
This commit is contained in:
Bossiara13 2026-05-16 15:02:07 +03:00
parent b3cfaa5171
commit f102b8dc95
6 changed files with 343 additions and 0 deletions

View file

@ -1735,6 +1735,14 @@ def run_action(action):
extensions.do_good_morning(action, _current_voice or '')
elif t == 'coffee_break':
extensions.do_coffee_break(action, _current_voice or '')
elif t == 'expenses_log':
extensions.do_expenses_log(action, _current_voice or '')
elif t == 'expenses_today':
extensions.do_expenses_today(action, _current_voice or '')
elif t == 'expenses_week':
extensions.do_expenses_week(action, _current_voice or '')
elif t == 'expenses_breakdown':
extensions.do_expenses_breakdown(action, _current_voice or '')
_current_voice: str = ''