diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-03 18:07:47 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-03 18:07:47 +0200 |
| commit | d44d62f5944c2765ba009197cc3ac5bb50d073e2 (patch) | |
| tree | 0d63be2ea8671ed50ffde99ad533a852444c47d8 /firefly_cli/commands/budget.py | |
| parent | 73fffe2e6f359b302b72b1f3740a08e471a31acc (diff) | |
| download | firefly-cli-d44d62f5944c2765ba009197cc3ac5bb50d073e2.tar.gz firefly-cli-d44d62f5944c2765ba009197cc3ac5bb50d073e2.zip | |
fix(budget): group help blurb, exact Decimal spent, resolver comment (v0.4.1)v0.4.1
Follow-ups from the v0.4.0 review:
- add the missing _GROUP_HELP blurb for the budget group (every other
group shows one) + a regression test asserting all groups have one.
- _spent_scalar sums with decimal.Decimal instead of float (exact money).
- note the numeric-name sniffing tradeoff in resolver.budget().
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'firefly_cli/commands/budget.py')
| -rw-r--r-- | firefly_cli/commands/budget.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/firefly_cli/commands/budget.py b/firefly_cli/commands/budget.py index f9999a5..86317fa 100644 --- a/firefly_cli/commands/budget.py +++ b/firefly_cli/commands/budget.py @@ -1,6 +1,7 @@ # Copyright (C) 2026 Danilo M. <danix@danix.xyz> GPL-2.0-only import calendar from datetime import date +from decimal import Decimal, InvalidOperation from firefly_cli import registry, output from firefly_cli.errors import FireflyError @@ -18,11 +19,11 @@ def _spent_scalar(budget_obj): """Sum a budget's nested `spent` array into a single number (for --human). Firefly sends spent as a per-currency list of {sum: "-12.34", ...}; we sum the sums. JSON output is untouched; this only feeds the table view.""" - total = 0.0 + total = Decimal(0) for entry in budget_obj.get("spent") or []: try: - total += float(entry.get("sum", 0)) - except (TypeError, ValueError): + total += Decimal(str(entry.get("sum", 0))) + except (TypeError, InvalidOperation): pass return f"{total:.2f}" |
