aboutsummaryrefslogtreecommitdiffstats
path: root/firefly_cli
diff options
context:
space:
mode:
Diffstat (limited to 'firefly_cli')
-rw-r--r--firefly_cli/__init__.py2
-rw-r--r--firefly_cli/cli.py1
-rw-r--r--firefly_cli/commands/budget.py7
-rw-r--r--firefly_cli/resolver.py4
4 files changed, 10 insertions, 4 deletions
diff --git a/firefly_cli/__init__.py b/firefly_cli/__init__.py
index f2c1864..1d2fe01 100644
--- a/firefly_cli/__init__.py
+++ b/firefly_cli/__init__.py
@@ -2,4 +2,4 @@
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
# Licensed under the GNU General Public License v2.0 only.
-__version__ = "0.4.0"
+__version__ = "0.4.1"
diff --git a/firefly_cli/cli.py b/firefly_cli/cli.py
index ad54504..712d52d 100644
--- a/firefly_cli/cli.py
+++ b/firefly_cli/cli.py
@@ -19,6 +19,7 @@ _GROUP_HELP = {
"category": "list categories (categories auto-create when used on a tx)",
"tag": "list tags (tags auto-create when attached to a tx)",
"tx": "record, list, and search transactions",
+ "budget": "manage budgets and per-period spending limits",
}
def _build_parser():
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}"
diff --git a/firefly_cli/resolver.py b/firefly_cli/resolver.py
index 53144e1..cb7e9a8 100644
--- a/firefly_cli/resolver.py
+++ b/firefly_cli/resolver.py
@@ -48,6 +48,10 @@ class Resolver:
# transaction), so we resolve to an id. A numeric-looking ref goes
# straight to the show endpoint (lets same-name-safe callers pin an id);
# otherwise match by name against the list.
+ # ponytail: sniffing digits makes a budget literally named "7"
+ # unreachable by name (same lossy tradeoff ISSUES.md #2 hit for
+ # accounts). All-digit budget names are rare; add a --budget-id flag to
+ # tx add if this ever bites, mirroring --from-id/--to-id.
if str(name_or_id).isdigit():
return self.budget_by_id(name_or_id)
return self._match("budget", self._list("/api/v1/budgets"), name_or_id)