diff options
Diffstat (limited to 'firefly_cli')
| -rw-r--r-- | firefly_cli/__init__.py | 2 | ||||
| -rw-r--r-- | firefly_cli/commands/account.py | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/firefly_cli/__init__.py b/firefly_cli/__init__.py index 79ea6e3..eb73e59 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.3.1" +__version__ = "0.3.2" diff --git a/firefly_cli/commands/account.py b/firefly_cli/commands/account.py index 9dbfab6..d78f8fc 100644 --- a/firefly_cli/commands/account.py +++ b/firefly_cli/commands/account.py @@ -52,9 +52,22 @@ def cmd_get(args, ctx): output.emit(acc, human=ctx.human) return 0 -@registry.command("account balance", help="show current balance for one account (name or id)", args=_name_arg) +def _balance_args(p): + p.add_argument("account", help="account name or id") + p.add_argument("--at", default=None, + help="balance as of this date YYYY-MM-DD (default: current)") + +@registry.command("account balance", help="show balance for one account (name or id); --at for a historical date", args=_balance_args) def cmd_balance(args, ctx): acc = ctx.resolver.account(args.account) + if args.at: + # Firefly recomputes current_balance as of ?date= on the account show endpoint. + dated = output.unwrap(ctx.client.request( + "GET", f"/api/v1/accounts/{acc['id']}", params={"date": args.at})) + output.emit({"id": acc["id"], "name": dated.get("name") or acc.get("name"), + "date": args.at, + "current_balance": dated.get("current_balance")}, human=ctx.human) + return 0 output.emit({"id": acc["id"], "name": acc.get("name"), "current_balance": acc.get("current_balance")}, human=ctx.human) return 0 |
