From 941ccb2cb34944e1321b3dc23731bfa93018d74f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 1 Jul 2026 12:13:42 +0200 Subject: feat: tx list --flat, account create --if-not-exists, --since/--until doc (v0.3.6) Three smaller ISSUES.md items, one PATCH (two optional flags + a doc fix; no existing caller or JSON shape changes). - tx list --flat: emit one top-level object per split (journal id repeated), dropping the transactions[] nesting so single-split journals script cleanly. JSON-only; --human already explodes splits into a table. - account create --if-not-exists: resolve the name first; on a clash return the existing account with "existed": true (exit 0) instead of surfacing Firefly's 422, so import scripts are idempotent. Detects via resolver, not by parsing the error string. - SKILL.md documents that --since/--until filter on the transaction date (the value date); Firefly journals have a single date field, no separate book date (verified against firefly-iii TimeCollection setRange). Co-Authored-By: Claude Opus 4.8 --- firefly_cli/output.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'firefly_cli/output.py') diff --git a/firefly_cli/output.py b/firefly_cli/output.py index 166e1bf..6c6a61c 100644 --- a/firefly_cli/output.py +++ b/firefly_cli/output.py @@ -62,6 +62,27 @@ def _tx_rows(rows): def _is_tx(rows): return bool(rows) and isinstance(rows[0], dict) and "transactions" in rows[0] +def flatten_tx(rows): + """Explode unwrapped tx journals into one flat object per split. + + Each journal is {id, transactions: [split, ...], ...}. We emit one object + per split: the split's raw Firefly fields (source_name, amount, etc.) with + the journal id merged in and the `transactions` list dropped. Single-split + journals (the common case) become one clean object. Rows without a + `transactions` list pass through unchanged. + """ + out = [] + for r in rows: + splits = r.get("transactions") + if not isinstance(splits, list): + out.append(r) + continue + for s in splits: + flat = dict(s) + flat["id"] = r.get("id") + out.append(flat) + return out + # Per-resource column whitelists for --human. Firefly returns ~50 fields per # row; only a handful are worth a table. A row is matched by a signature key. # (signature, columns) -- first match wins; unmatched rows use a generic table. -- cgit v1.2.3