Skip to content

Commit

Permalink
Delete amount and value on closing
Browse files Browse the repository at this point in the history
  • Loading branch information
sboehler committed Jan 25, 2021
1 parent bc029f2 commit 49a561e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/balance/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,14 @@ func (b *Balance) Update(day *ledger.Day, np prices.NormalizedPrices, close bool
return Error{c, "account is not open"}
}
for pos, amount := range b.Amounts {
if pos.Account == c.Account && !amount.IsZero() {
if pos.Account != c.Account {
continue
}
if !amount.IsZero() || !b.Values[pos].IsZero() {
return Error{c, "account has nonzero position"}
}
delete(b.Amounts, pos)
delete(b.Values, pos)
}
delete(b.Account, c.Account)
}
Expand Down

0 comments on commit 49a561e

Please sign in to comment.