commit 73db0def93c00657aaa773def129807d2cd32956
parent 21ec11b24ad8cc88fe547eb5fc706d544e25086f
Author: lash <dev@holbrook.no>
Date: Sat, 4 Apr 2026 11:10:08 -0600
Add accounts to interactive state listing
Diffstat:
2 files changed, 24 insertions(+), 37 deletions(-)
diff --git a/dummy/usawa/cli/entry.py b/dummy/usawa/cli/entry.py
@@ -7,7 +7,7 @@ import subprocess
import mimetypes
from usawa import Asset, Entry, EntryPart
-from usawa.account import Account, AccountDisplay
+from usawa.account import Account, AccountDisplay, AccountType
logg = logging.getLogger('cli.entry')
@@ -119,6 +119,11 @@ def handle_description(ctx, entry, v):
entry.description = v
+def handle_reset(ctx, entry, v):
+ entry.debit = []
+ entry.credit = []
+
+
def try_entry_uuid(ctx, v):
v = uuid.UUID(v)
entry = Entry.empty(ref=str(v))
@@ -271,6 +276,11 @@ class EntrySession:
if v == 'd':
handle_description(self.ctx, self.entry, v)
return True
+ if v == 'r':
+ handle_reset(self.ctx, self.entry, v)
+ return True
+ if v == 's':
+ return True
logg.error('invalid input')
return True
@@ -334,4 +344,17 @@ Extref: {}
self.entry.ref,
self.entry.extref,
)
+
+ s += "Accounts src:\n"
+ for v in self.entry.debit:
+ typ = getattr(AccountType, v.typ)
+ o = Account.from_path(v.account, sym=v.unit, typ=typ)
+ s += "\t" + o.to_path() + " " + self.ctx.uidx.to_floatstring(v.unit, v.amount) + "\n"
+
+ s += "Accounts dst:\n"
+ for v in self.entry.credit:
+ typ = getattr(AccountType, v.typ)
+ o = Account.from_path(v.account, sym=v.unit, typ=typ)
+ s += "\t" + o.to_path() + " " + self.ctx.uidx.to_floatstring(v.unit, v.amount) + "\n"
+
return s
diff --git a/dummy/usawa/runnable/entry.py b/dummy/usawa/runnable/entry.py
@@ -24,22 +24,6 @@ logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
-#def parse_type(ctx, v):
-# v = v.lower()
-# r = None
-# for k in CATEGORIES:
-# if k.startswith(v):
-# r = k
-# logg.info("expanded input '{}' to category {}".format(v, r))
-# break
-# if not r:
-# raise ValueError('invalid type: ' + v)
-# o = getattr(AccountType, r)
-# logg.debug('accounttype {}'.format(o))
-# return o
-#
-#
-
def main():
def croak(*args, **kwargs):
sys.exit(1)
@@ -64,25 +48,12 @@ def main():
if args.v:
logg.setLevel(getattr(logging, args.v.upper()))
- #ctx = Context(args)
-
cfg = usawa.config.load_config(config_dir=args.c)
ctx = UsawaContext(cfg)
- #dp = os.path.realpath(args.src_dir)
- #ctx.set('srcdir', dp)
ctx.init(args)
ctx.set('unitbase', ctx.uidx.base)
ctx.set('commit', False)
-# entry = try_entry(ctx, args)
-# if entry.serial > 0:
-# raise NotImplementedError('entry edit not yet implemented')
-# do_prepare(ctx, entry=entry)
-# entry = Entry.empty(ref=ctx.get('ref'), unitindex=ctx.uidx, tx_date=ctx.get('dt'))
- #entry = ctx.store.get_draft(entry)
- #entry.description = ctx.get('description')
- #entry.dt = ctx.txdate
-
o = EntrySession(ctx, args.entry)
for v in args.x:
@@ -93,13 +64,6 @@ def main():
entry = o.start()
-# if ctx.commit:
-# if entry.serial != -1:
-# raise AttributeError('entry draft already marked as committed')
-# entry.serial = ctx.ledger.next_serial()
-
-# v = input_or_default('Commit? (type YES, any other input is no)', '')
-
print(entry)