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

@ -1709,3 +1709,34 @@ routines_coffee_break:
- перерыв на чай
- отойду минут на пять
action: {type: coffee_break}
expenses_log:
phrases:
- потратил
- записать трату
- запиши трату
- купил за
- заплатил за
action: {type: expenses_log}
expenses_today:
phrases:
- сколько я потратил сегодня
- траты сегодня
- сколько ушло сегодня
action: {type: expenses_today}
expenses_week:
phrases:
- сколько я потратил на этой неделе
- траты на неделе
- недельные траты
action: {type: expenses_week}
expenses_breakdown:
phrases:
- куда ушли деньги
- разбивка по тратам
- на что я тратил
- разбивка по категориям
action: {type: expenses_breakdown}