akt-cli 0.7.0__tar.gz → 0.8.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akt-cli
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: akt — a CLI toolbox to fully drive an Akaunting accounting instance
5
5
  Keywords: akaunting,accounting,cli,invoices,bills,api
6
6
  Author: AsyncAlchemist
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "akt-cli"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "akt — a CLI toolbox to fully drive an Akaunting accounting instance"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -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
 
@@ -444,6 +450,23 @@ def _run_special(name: str, client: Client, ns: Any) -> int:
444
450
  print(f" {'Net income to date':>40} {bs['net_income']:>12,.2f}")
445
451
  print(" BALANCED" if bs["balanced"] else " *** DOES NOT BALANCE")
446
452
  return 0 if bs["balanced"] else 1
453
+ if name == "gc_ledger":
454
+ _need_akt_api(client, "gc-ledger")
455
+ rep = client.get("akt-api/ledgers/orphans")
456
+ data = rep.get("data", rep) if isinstance(rep, dict) else rep
457
+ total = data.get("total", 0)
458
+ if not ns.apply:
459
+ if ns.json:
460
+ emit(data, as_json=True)
461
+ else:
462
+ for t, c in (data.get("by_type") or {}).items():
463
+ print(f" {c:>6} {t}")
464
+ print(f"{total} orphaned ledger row(s). Run with --apply to delete.")
465
+ return 0
466
+ res = client.request("DELETE", "akt-api/ledgers/orphans")
467
+ d = res.get("data", res) if isinstance(res, dict) else res
468
+ print(f"deleted {d.get('deleted', 0)} orphaned ledger row(s).")
469
+ return 0
447
470
  raise ValueError(name)
448
471
 
449
472
 
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