diff options
author | thdox <thdox@free.fr> | 2014-05-17 23:41:07 +0200 |
---|---|---|
committer | thdox <thdox@free.fr> | 2014-05-17 23:41:07 +0200 |
commit | 8b3f8d188444510d8ca00e5db90bac0cf5663c91 (patch) | |
tree | 0808331f7b0020c12256096940929a0ae02e7ba8 | |
parent | 6a8b2a5fb08160882b6e101b364ef7c2e80e574e (diff) | |
download | fork-ledger-8b3f8d188444510d8ca00e5db90bac0cf5663c91.tar.gz fork-ledger-8b3f8d188444510d8ca00e5db90bac0cf5663c91.tar.bz2 fork-ledger-8b3f8d188444510d8ca00e5db90bac0cf5663c91.zip |
Fix bug introduced by commit AA2FF2B
Correction is to not use uninitialized amount
-rw-r--r-- | src/textual.cc | 7 | ||||
-rw-r--r-- | test/regress/AA2FF2B.test | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/textual.cc b/src/textual.cc index 8d4db512..418b6c00 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1638,24 +1638,23 @@ post_t * instance_t::parse_post(char * line, "line " << context.linenum << ": " << "post amount = " << amt); amount_t diff = amt; - amount_t tot; switch (account_total.type()) { case value_t::AMOUNT: - tot = account_total.as_amount(); + diff -= account_total.as_amount(); break; case value_t::BALANCE: if (optional<amount_t> comm_bal = account_total.as_balance().commodity_amount(amt.commodity())) - tot = *comm_bal; + diff -= *comm_bal; break; default: break; } - diff -= tot; + amount_t tot = amt - diff; DEBUG("post.assign", "line " << context.linenum << ": " << "diff = " << diff); diff --git a/test/regress/AA2FF2B.test b/test/regress/AA2FF2B.test new file mode 100644 index 00000000..944cdfea --- /dev/null +++ b/test/regress/AA2FF2B.test @@ -0,0 +1,10 @@ +2008/01/20 * La Poste + Revenu:Invest:Exonéré + Actif:Courant:LaPosteLivretA 25,24 € = 25,24 € + +test --args-only --decimal-comma bal + 25,24 € Actif:Courant:LaPosteLivretA + -25,24 € Revenu:Invest:Exonéré +-------------------- + 0 +end test |