corrected the deviation report (-D) when -V is also being used

This commit is contained in:
John Wiegley 2004-09-25 17:59:14 -04:00
parent d74e926b43
commit 26de701a4e
4 changed files with 10 additions and 16 deletions

View file

@ -586,16 +586,16 @@ OPT_BEGIN(average, "A") {
} OPT_END(average);
OPT_BEGIN(deviation, "D") {
config.total_expr = std::string("DM") + config.total_expr;
config.total_expr = std::string("t-M") + config.total_expr;
} OPT_END(deviation);
OPT_BEGIN(trend, "X") {
config.total_expr = std::string("MDM") + config.total_expr;
config.total_expr = std::string("M(t-M") + config.total_expr + ")";
} OPT_END(trend);
OPT_BEGIN(weighted_trend, "Z") {
config.total_expr = (std::string("MD(M(") + config.total_expr +
")/(1+(((m-d)/(30*86400))<0?0:((m-d)/(30*86400)))))");
config.total_expr = (std::string("M(t-(M(") + config.total_expr +
")/(1+(((m-d)/(30*86400))<0?0:((m-d)/(30*86400))))))");
} OPT_END(weighted_trend);
} // namespace ledger

View file

@ -967,9 +967,6 @@ Strips the commodity from the argument.
@item M
The median of the argument; @samp{Mx} is the same as @samp{x/n}.
@item D
The deviation of the argument; @samp{Dx} is the same as @samp{x-x/n}.
@item P
The present market value of the argument. The syntax @samp{P(x,d)} is
supported, which yields the market value at time @samp{d}.

View file

@ -505,13 +505,6 @@ value_expr_t * parse_value_term(std::istream& in)
node->left = parse_value_term(in);
break;
case 'D': {
node.reset(new value_expr_t(value_expr_t::O_SUB));
node->left = parse_value_term("a");
node->right = parse_value_term(in);
break;
}
case 'P':
node.reset(new value_expr_t(value_expr_t::F_VALUE));
if (peek_next_nonws(in) == '(') {

View file

@ -38,8 +38,10 @@ void sort_transactions::flush()
for (transactions_deque::iterator i = transactions.begin();
i != transactions.end();
i++)
i++) {
transaction_xdata(**i).dflags &= ~TRANSACTION_SORT_CALC;
(*handler)(**i);
}
transactions.clear();
@ -405,8 +407,10 @@ void walk_accounts(account_t& account,
sort_accounts(account, sort_order, accounts);
for (accounts_deque::const_iterator i = accounts.begin();
i != accounts.end();
i++)
i++) {
account_xdata(**i).dflags &= ~ACCOUNT_SORT_CALC;
walk_accounts(**i, handler, sort_order);
}
} else {
for (accounts_map::const_iterator i = account.accounts.begin();
i != account.accounts.end();