diff options
author | John Wiegley <johnw@newartisans.com> | 2022-04-15 12:20:14 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2022-05-03 13:35:13 -0700 |
commit | ce8fec9ab6608ad35823388eb6e85bb58e7fe86f (patch) | |
tree | 7a9279e37ca59dba4ef44e6d9c649cc927f6f25b /src/textual.cc | |
parent | 68509722d7f177c1a4d7e9025af86833cdb2b3db (diff) | |
download | fork-ledger-ce8fec9ab6608ad35823388eb6e85bb58e7fe86f.tar.gz fork-ledger-ce8fec9ab6608ad35823388eb6e85bb58e7fe86f.tar.bz2 fork-ledger-ce8fec9ab6608ad35823388eb6e85bb58e7fe86f.zip |
When calculating balance assignments, strip away lot annotations
Diffstat (limited to 'src/textual.cc')
-rw-r--r-- | src/textual.cc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/textual.cc b/src/textual.cc index b2108dcf..8ee31eec 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1666,18 +1666,20 @@ post_t * instance_t::parse_post(char * line, balance_t diff = amt; switch (account_total.type()) { - case value_t::AMOUNT: - diff -= account_total.as_amount(); + case value_t::AMOUNT: { + amount_t amt(account_total.as_amount().strip_annotations(keep_details_t())); + diff -= amt; DEBUG("textual.parse", "line " << context.linenum << ": " - << "Subtracting amount " << account_total.as_amount() << " from diff, yielding " << diff); + << "Subtracting amount " << amt << " from diff, yielding " << diff); break; - - case value_t::BALANCE: - diff -= account_total.as_balance(); + } + case value_t::BALANCE: { + balance_t bal(account_total.as_balance().strip_annotations(keep_details_t())); + diff -= bal; DEBUG("textual.parse", "line " << context.linenum << ": " - << "Subtracting balance " << account_total.as_balance() << " from diff, yielding " << diff); + << "Subtracting balance " << bal << " from diff, yielding " << diff); break; - + } default: break; } @@ -1690,9 +1692,10 @@ post_t * instance_t::parse_post(char * line, // Subtract amounts from previous posts to this account in the xact. for (post_t* p : xact->posts) { if (p->account == post->account && p->has_flags(POST_VIRTUAL) == post->has_flags(POST_VIRTUAL)) { - diff -= p->amount; + amount_t amt(p->amount.strip_annotations(keep_details_t())); + diff -= amt; DEBUG("textual.parse", "line " << context.linenum << ": " - << "Subtracting " << p->amount << ", diff = " << diff); + << "Subtracting " << amt << ", diff = " << diff); } } @@ -1726,9 +1729,9 @@ post_t * instance_t::parse_post(char * line, } } else { // balance assertion - diff -= post->amount; + diff -= post->amount.strip_annotations(keep_details_t()); if (! no_assertions && ! diff.is_zero()) { - balance_t tot = -diff + amt; + balance_t tot = (-diff + amt).strip_annotations(keep_details_t()); DEBUG("textual.parse", "Balance assertion: off by " << diff << " (expected to see " << tot << ")"); throw_(parse_error, _f("Balance assertion off by %1% (expected to see %2%)") |