akt-cli 0.7.0__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {akt_cli-0.7.0 → akt_cli-0.8.1}/PKG-INFO +1 -1
- {akt_cli-0.7.0 → akt_cli-0.8.1}/pyproject.toml +1 -1
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/cli.py +26 -1
- {akt_cli-0.7.0 → akt_cli-0.8.1}/LICENSE +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/README.md +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/__init__.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/client.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/coa.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/commands.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/config.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/ledger.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/output.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/registry.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/reports.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/resources.py +0 -0
- {akt_cli-0.7.0 → akt_cli-0.8.1}/src/akt/verify.py +0 -0
|
@@ -226,6 +226,12 @@ def _build_parser() -> argparse.ArgumentParser:
|
|
|
226
226
|
p.add_argument("--to", dest="date_to", metavar="YYYY-MM-DD")
|
|
227
227
|
p.set_defaults(_special=sp)
|
|
228
228
|
|
|
229
|
+
gp = sub.add_parser("gc-ledger", parents=[common],
|
|
230
|
+
help="Report/remove orphaned ledger rows (needs the akt-api module)")
|
|
231
|
+
gp.add_argument("--apply", action="store_true",
|
|
232
|
+
help="delete the orphaned rows (default: report only)")
|
|
233
|
+
gp.set_defaults(_special="gc_ledger")
|
|
234
|
+
|
|
229
235
|
return parser
|
|
230
236
|
|
|
231
237
|
|
|
@@ -236,7 +242,9 @@ def _need_akt_api(client: Client, cmd: str) -> None:
|
|
|
236
242
|
|
|
237
243
|
|
|
238
244
|
def _fetch_balances(client: Client, ns: Any):
|
|
239
|
-
|
|
245
|
+
# One big page instead of paginating (a chart of accounts is small); saves
|
|
246
|
+
# round-trips, which matters when a script runs many balance/report calls.
|
|
247
|
+
accounts = client.list("chart-of-accounts", all_pages=True, params={"limit": 1000})
|
|
240
248
|
accts_by_id = {a["id"]: {"code": a.get("code"), "name": a.get("name"),
|
|
241
249
|
"type_id": a.get("type_id")} for a in accounts}
|
|
242
250
|
params: dict[str, Any] = {}
|
|
@@ -444,6 +452,23 @@ def _run_special(name: str, client: Client, ns: Any) -> int:
|
|
|
444
452
|
print(f" {'Net income to date':>40} {bs['net_income']:>12,.2f}")
|
|
445
453
|
print(" BALANCED" if bs["balanced"] else " *** DOES NOT BALANCE")
|
|
446
454
|
return 0 if bs["balanced"] else 1
|
|
455
|
+
if name == "gc_ledger":
|
|
456
|
+
_need_akt_api(client, "gc-ledger")
|
|
457
|
+
rep = client.get("akt-api/ledgers/orphans")
|
|
458
|
+
data = rep.get("data", rep) if isinstance(rep, dict) else rep
|
|
459
|
+
total = data.get("total", 0)
|
|
460
|
+
if not ns.apply:
|
|
461
|
+
if ns.json:
|
|
462
|
+
emit(data, as_json=True)
|
|
463
|
+
else:
|
|
464
|
+
for t, c in (data.get("by_type") or {}).items():
|
|
465
|
+
print(f" {c:>6} {t}")
|
|
466
|
+
print(f"{total} orphaned ledger row(s). Run with --apply to delete.")
|
|
467
|
+
return 0
|
|
468
|
+
res = client.request("DELETE", "akt-api/ledgers/orphans")
|
|
469
|
+
d = res.get("data", res) if isinstance(res, dict) else res
|
|
470
|
+
print(f"deleted {d.get('deleted', 0)} orphaned ledger row(s).")
|
|
471
|
+
return 0
|
|
447
472
|
raise ValueError(name)
|
|
448
473
|
|
|
449
474
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|