summaryrefslogtreecommitdiff
path: root/valexpr.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-05 21:47:53 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-05 21:47:53 -0400
commit50f75e0a5c3ee31c2bcc1fcbd8da42e24ccf072f (patch)
tree1ebf3b1adf32c537b95cce4f3074cde2eebc7147 /valexpr.cc
parent7e87a0a0b1a8b76c44f4f678d8bfb5129ba6c5da (diff)
downloadfork-ledger-50f75e0a5c3ee31c2bcc1fcbd8da42e24ccf072f.tar.gz
fork-ledger-50f75e0a5c3ee31c2bcc1fcbd8da42e24ccf072f.tar.bz2
fork-ledger-50f75e0a5c3ee31c2bcc1fcbd8da42e24ccf072f.zip
added support for account sorting
Diffstat (limited to 'valexpr.cc')
-rw-r--r--valexpr.cc42
1 files changed, 22 insertions, 20 deletions
diff --git a/valexpr.cc b/valexpr.cc
index d563c3da..37bb7a80 100644
--- a/valexpr.cc
+++ b/valexpr.cc
@@ -116,34 +116,36 @@ void node_t::compute(balance_t& result, const details_t& details) const
break;
case BALANCE:
- if (details.balance) {
- result = details.balance->quantity;
- if (details.xact)
- result -= details.xact->amount;
- else if (details.account)
- result -= details.account->value.quantity;
+ if (details.xact) {
+ result = details.xact->total.quantity;
+ result -= details.xact->amount;
+ }
+ else if (details.account) {
+ result = details.account->total.quantity;
+ result -= details.account->value.quantity;
}
break;
case COST_BALANCE:
- if (details.balance) {
- result = details.balance->cost;
- if (details.xact)
- result -= details.xact->cost;
- else if (details.account)
- result -= details.account->value.cost;
+ if (details.xact) {
+ result = details.xact->total.cost;
+ result -= details.xact->cost;
+ }
+ else if (details.account) {
+ result = details.account->total.cost;
+ result -= details.account->value.cost;
}
break;
case TOTAL:
- if (details.balance)
- result = details.balance->quantity;
+ if (details.xact)
+ result = details.xact->total.quantity;
else if (details.account)
result = details.account->total.quantity;
break;
case COST_TOTAL:
- if (details.balance)
- result = details.balance->cost;
+ if (details.xact)
+ result = details.xact->total.cost;
else if (details.account)
result = details.account->total.cost;
break;
@@ -164,15 +166,15 @@ void node_t::compute(balance_t& result, const details_t& details) const
break;
case INDEX:
- if (details.index)
- result = *details.index + 1;
+ if (details.xact)
+ result = details.xact->index + 1;
break;
case F_ARITH_MEAN:
- if (details.index) {
+ if (details.xact) {
assert(left);
left->compute(result, details);
- result /= amount_t(*details.index + 1);
+ result /= amount_t(details.xact->index + 1);
}
break;