diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-01 10:29:04 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-01 10:29:04 +0200 |
| commit | b078c5980facc0ebe4acd1f251f6ae3dad561292 (patch) | |
| tree | 29611c1d9f039e96db81b4b2bc31b8d7729f0a36 /tests/unit | |
| parent | 0c9939c5961a3cef50e6378c0eefbeaae00f4c67 (diff) | |
| download | firefly-cli-b078c5980facc0ebe4acd1f251f6ae3dad561292.tar.gz firefly-cli-b078c5980facc0ebe4acd1f251f6ae3dad561292.zip | |
feat: account balance --at for historical balance (v0.3.2)
Reconciliation needed an account's balance as of a past date; the command
only reported the current balance, forcing hand-written sum scripts.
--at YYYY-MM-DD re-fetches the account with Firefly's ?date= param, which
recomputes current_balance as of that date (end of day, no client math).
Without --at the current-balance path is unchanged (no extra API call).
Verified live read-only against real data: Mediolanum current 183.23 vs
--at 2026-06-10 164.38, boundary probe gives distinct daily balances.
PATCH: new optional flag, contract unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/test_commands_account.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/unit/test_commands_account.py b/tests/unit/test_commands_account.py index 2c07780..4a01292 100644 --- a/tests/unit/test_commands_account.py +++ b/tests/unit/test_commands_account.py @@ -22,11 +22,25 @@ class TestAccountCmd(unittest.TestCase): ctx, client, resolver = make_ctx() resolver.account.return_value = {"id": "3", "name": "Checking", "current_balance": "100.00"} - args = MagicMock(account="Checking") + args = MagicMock(account="Checking", at=None) rc = acct.cmd_balance(args, ctx) resolver.account.assert_called_once_with("Checking") + client.request.assert_not_called() # current balance from resolver, no extra call self.assertEqual(rc, 0) + def test_balance_at_date_fetches_dated_account(self): + ctx, client, resolver = make_ctx() + resolver.account.return_value = {"id": "3", "name": "Checking", + "current_balance": "100.00"} + client.request.return_value = {"data": {"id": "3", "attributes": { + "name": "Checking", "current_balance": "42.00"}}} + args = MagicMock(account="Checking", at="2026-05-31") + rc = acct.cmd_balance(args, ctx) + self.assertEqual(rc, 0) + method, path = client.request.call_args[0][:2] + self.assertEqual((method, path), ("GET", "/api/v1/accounts/3")) + self.assertEqual(client.request.call_args[1]["params"], {"date": "2026-05-31"}) + class TestAccountCreate(unittest.TestCase): def _args(self, **kw): base = dict(name=None, type=None, opening_balance=None, currency=None) |
