a couple of fixes to collapsed and subtotal reports
This commit is contained in:
parent
a4d96f79bf
commit
555c2d855f
2 changed files with 20 additions and 24 deletions
14
config.cc
14
config.cc
|
|
@ -582,24 +582,20 @@ OPT_BEGIN(gain, "G") {
|
||||||
} OPT_END(gain);
|
} OPT_END(gain);
|
||||||
|
|
||||||
OPT_BEGIN(average, "A") {
|
OPT_BEGIN(average, "A") {
|
||||||
config.amount_expr = "a";
|
config.total_expr = std::string("M") + config.total_expr;
|
||||||
config.total_expr = "MO";
|
|
||||||
} OPT_END(average);
|
} OPT_END(average);
|
||||||
|
|
||||||
OPT_BEGIN(deviation, "D") {
|
OPT_BEGIN(deviation, "D") {
|
||||||
config.amount_expr = "a";
|
config.total_expr = std::string("DM") + config.total_expr;
|
||||||
config.total_expr = "DMO";
|
|
||||||
} OPT_END(deviation);
|
} OPT_END(deviation);
|
||||||
|
|
||||||
OPT_BEGIN(trend, "X") {
|
OPT_BEGIN(trend, "X") {
|
||||||
config.amount_expr = "a";
|
config.total_expr = std::string("MDM") + config.total_expr;
|
||||||
config.total_expr = "MDMO";
|
|
||||||
} OPT_END(trend);
|
} OPT_END(trend);
|
||||||
|
|
||||||
OPT_BEGIN(weighted_trend, "Z") {
|
OPT_BEGIN(weighted_trend, "Z") {
|
||||||
config.amount_expr = "a";
|
config.total_expr = (std::string("MD(M(") + config.total_expr +
|
||||||
config.total_expr
|
")/(1+(((m-d)/(30*86400))<0?0:((m-d)/(30*86400)))))");
|
||||||
= "MD(MO/(1+(((m-d)/(30*86400))<0?0:((m-d)/(30*86400)))))";
|
|
||||||
} OPT_END(weighted_trend);
|
} OPT_END(weighted_trend);
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
|
||||||
24
walk.cc
24
walk.cc
|
|
@ -123,6 +123,15 @@ static void handle_value(const value_t& value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void determine_amount(value_t& result, balance_pair_t& bal_pair)
|
||||||
|
{
|
||||||
|
account_xdata_t xdata;
|
||||||
|
xdata.value = bal_pair;
|
||||||
|
account_t temp_account;
|
||||||
|
temp_account.data = &xdata;
|
||||||
|
format_t::compute_amount(result, details_t(temp_account));
|
||||||
|
}
|
||||||
|
|
||||||
void collapse_transactions::report_cumulative_subtotal()
|
void collapse_transactions::report_cumulative_subtotal()
|
||||||
{
|
{
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
|
|
@ -130,11 +139,8 @@ void collapse_transactions::report_cumulative_subtotal()
|
||||||
} else {
|
} else {
|
||||||
assert(count > 1);
|
assert(count > 1);
|
||||||
|
|
||||||
account_xdata_t xdata;
|
|
||||||
xdata.total = subtotal;
|
|
||||||
value_t result;
|
value_t result;
|
||||||
totals_account.data = &xdata;
|
determine_amount(result, subtotal);
|
||||||
format_t::compute_total(result, details_t(totals_account));
|
|
||||||
handle_value(result, &totals_account, last_entry, 0, xact_temps, handler);
|
handle_value(result, &totals_account, last_entry, 0, xact_temps, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,14 +216,8 @@ void subtotal_transactions::flush(const char * spec_fmt)
|
||||||
i != balances.end();
|
i != balances.end();
|
||||||
i++) {
|
i++) {
|
||||||
entry.date = finish;
|
entry.date = finish;
|
||||||
{
|
value_t result;
|
||||||
transaction_xdata_t xact_data;
|
determine_amount(result, (*i).second);
|
||||||
xact_data.total = (*i).second;
|
|
||||||
transaction_t temp((*i).first);
|
|
||||||
temp.entry = &entry;
|
|
||||||
temp.data = &xact_data;
|
|
||||||
format_t::compute_total(result, details_t(temp));
|
|
||||||
}
|
|
||||||
entry.date = start;
|
entry.date = start;
|
||||||
|
|
||||||
handle_value(result, (*i).first, &entry, 0, xact_temps, handler);
|
handle_value(result, (*i).first, &entry, 0, xact_temps, handler);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue