diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-21 15:55:03 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-21 15:55:03 -0400 |
commit | 000bfe1cece3ecbfee8f07a46d1f0b000dbbc983 (patch) | |
tree | 6d2c666097900fff421da6a57b41f0a7c43a39b7 /valexpr.cc | |
parent | 225acd14e57a0a476ce022a7c5703a8f1cee34ef (diff) | |
download | fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.tar.gz fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.tar.bz2 fork-ledger-000bfe1cece3ecbfee8f07a46d1f0b000dbbc983.zip |
only compute the cost when it differs from the amount
Diffstat (limited to 'valexpr.cc')
-rw-r--r-- | valexpr.cc | 43 |
1 files changed, 34 insertions, 9 deletions
@@ -83,10 +83,18 @@ void value_expr_t::compute(value_t& result, const details_t& details, break; case COST: - if (details.xact) - result = details.xact->cost; - else if (details.account) - result = details.account->value.cost; + if (details.xact) { + if (details.xact->cost) + result = *details.xact->cost; + else + result = details.xact->amount; + } + else if (details.account) { + if (details.account->value.cost) + result = *details.account->value.cost; + else + result = details.account->value.quantity; + } break; case TOTAL: @@ -96,10 +104,18 @@ void value_expr_t::compute(value_t& result, const details_t& details, result = details.account->total.quantity; break; case COST_TOTAL: - if (details.xact) - result = details.xact->total.cost; - else if (details.account) - result = details.account->total.cost; + if (details.xact) { + if (details.xact->total.cost) + result = *details.xact->total.cost; + else + result = details.xact->total.quantity; + } + else if (details.account) { + if (details.account->total.cost) + result = *details.account->total.cost; + else + result = details.account->total.quantity; + } break; case VALUE_EXPR: @@ -166,6 +182,13 @@ void value_expr_t::compute(value_t& result, const details_t& details, if (details.xact) result = details.xact->index + 1; else if (details.account) + result = details.account->subcount; + break; + + case COUNT: + if (details.xact) + result = details.xact->index + 1; + else if (details.account) result = details.account->count; break; @@ -377,7 +400,7 @@ value_expr_t * parse_value_term(std::istream& in) in.get(c); switch (c) { // Basic terms - case 'N': + case 'm': node.reset(new value_expr_t(value_expr_t::CONSTANT_T)); node->constant_t = now; break; @@ -388,6 +411,7 @@ value_expr_t * parse_value_term(std::istream& in) case 'X': node.reset(new value_expr_t(value_expr_t::CLEARED)); break; case 'R': node.reset(new value_expr_t(value_expr_t::REAL)); break; case 'n': node.reset(new value_expr_t(value_expr_t::INDEX)); break; + case 'N': node.reset(new value_expr_t(value_expr_t::COUNT)); break; case 'l': node.reset(new value_expr_t(value_expr_t::DEPTH)); break; case 'O': node.reset(new value_expr_t(value_expr_t::TOTAL)); break; case 'C': node.reset(new value_expr_t(value_expr_t::COST_TOTAL)); break; @@ -715,6 +739,7 @@ void dump_value_expr(std::ostream& out, const value_expr_t * node) case value_expr_t::CLEARED: out << "CLEARED"; break; case value_expr_t::REAL: out << "REAL"; break; case value_expr_t::INDEX: out << "INDEX"; break; + case value_expr_t::COUNT: out << "COUNT"; break; case value_expr_t::DEPTH: out << "DEPTH"; break; case value_expr_t::TOTAL: out << "TOTAL"; break; case value_expr_t::COST_TOTAL: out << "COST_TOTAL"; break; |