summaryrefslogtreecommitdiff
path: root/src/py_account.cc
diff options
context:
space:
mode:
authorDaraul <thurst306@gmail.com>2020-03-10 13:38:43 -0400
committerMartin Michlmayr <tbm@cyrius.com>2020-04-05 11:33:09 +0800
commit0018c884dbf228c54e30f0bc8b7586cc35c56b0f (patch)
tree66f637fb69dd59e5e902cdb2ecd1aa041e26f933 /src/py_account.cc
parenta413a072a5a8199d0acee6d6b7a9586a4ddd86ac (diff)
downloadfork-ledger-0018c884dbf228c54e30f0bc8b7586cc35c56b0f.tar.gz
fork-ledger-0018c884dbf228c54e30f0bc8b7586cc35c56b0f.tar.bz2
fork-ledger-0018c884dbf228c54e30f0bc8b7586cc35c56b0f.zip
fix: Fix #543 by tracking an account's real balance
Without these changes, whether an account's balance is virtual or real is not considered when asserting it's balance. This lead to situations where the user must consider their virtual postings when attemping to assert the real balance of the account. See test/regress/543_a.test for that testcase, taken from the original issue. This commit also includes other, fringe, situations that I noticed while working on the fix. It essentially just adds a separate attribute to the account class(?) that hold's the account's "real" balance, which is only updated when the user attempts an assertion on a real account. The virtual account's balance is updated the way it always was.
Diffstat (limited to 'src/py_account.cc')
-rw-r--r--src/py_account.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/py_account.cc b/src/py_account.cc
index 59680a23..295ed9d7 100644
--- a/src/py_account.cc
+++ b/src/py_account.cc
@@ -105,7 +105,7 @@ namespace {
value_t py_amount_1(const account_t& account, const boost::optional<expr_t&>& expr)
{
- return account.amount(expr);
+ return account.amount(false, expr);
}
value_t py_total_0(const account_t& account)
@@ -133,6 +133,7 @@ void export_account()
class_< account_t::xdata_t::details_t > ("AccountXDataDetails")
.def_readonly("total", &account_t::xdata_t::details_t::total)
+ .def_readonly("real_total", &account_t::xdata_t::details_t::real_total)
.def_readonly("calculated", &account_t::xdata_t::details_t::calculated)
.def_readonly("gathered", &account_t::xdata_t::details_t::gathered)