commit 6ea284af227c41e6a25705c49348fb6ba18efe59
parent 5eb23f829d6bc7ac6dae47f0ab3fadab125e7d40
Author: lash <dev@holbrook.no>
Date: Sat, 14 Feb 2026 09:15:56 +0000
Tolerate duplicate asset insert in add tool
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dummy/usawa/runnable/add.py b/dummy/usawa/runnable/add.py
@@ -120,7 +120,7 @@ argp.add_argument('-r', type=str, help='external reference')
argp.add_argument('-s', type=str, dest='src_account', default='general', help='source account')
argp.add_argument('-t', type=str, dest='dst_account', default='general', help='destination account')
argp.add_argument('-a', type=str, dest='amount', help='source and destination amount')
-argp.add_argument('-x', type=str, dest='attachment', action='append', help='add file attachment')
+argp.add_argument('-x', type=str, dest='attachment', default=[], action='append', help='add file attachment')
argp.add_argument('-o', type=str, dest='output', help='output file for updated XML document')
argp.add_argument('--src-type', dest='src_type', type=str, choices=CATEGORIES, default='expense', help='source type')
argp.add_argument('--dst-type', dest='dst_type', type=str, choices=CATEGORIES, default='asset', help='dest type')
@@ -185,9 +185,11 @@ entry.add_part(ctx.part[0], debit=True)
entry.add_part(ctx.part[1])
for o in ctx.attach:
entry.attach(o)
- store.add_asset(o)
+ try:
+ store.add_asset(o)
+ except FileExistsError:
+ logg.info('asset already in store: {}'.format(o))
entry.sign(wallet)
-logg.debug('storing entry {}'.format(entry))
store.add_entry(entry, update_ledger=True)
ledger.truncate()
ledger.sign()