Ignore currency-related transactions in CGT asset accounts

This commit is contained in:
RunasSudo 2023-07-03 22:32:48 +10:00
parent 474a5016db
commit 4de3dc41ac
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -189,15 +189,19 @@ def cgt_assets():
assets = []
for posting in cgt_postings:
if posting.commodity == '$':
# FIXME: Detect this better
continue
if posting.quantity >= 0:
assets.append(CGTAsset(posting.quantity, posting.commodity, posting.account, posting.transaction.dt))
elif posting.quantity < 0:
asset = next((a for a in assets if a.commodity == posting.commodity and a.account == posting.account), None)
if asset is None:
raise Exception('Attempted credit {} without preceding debit balance'.quantity(posting.amount()))
raise Exception('Attempted credit {} without preceding debit balance'.format(posting.amount()))
if asset.quantity + posting.quantity < 0:
raise Exception('Attempted credit {} with insufficient debit balance {}'.quantity(posting.amount(), asset.amount()))
raise Exception('Attempted credit {} with insufficient debit balance {}'.format(posting.amount(), asset.amount()))
if asset.quantity + posting.quantity != 0:
raise NotImplementedError('Partial disposal of CGT asset not implemented')