Added the concept of a "display_total", used for showing the values in the

totals column of both the register and balance reports.  This is different
from the internal calculated total, which is still "total_expr".
This commit is contained in:
John Wiegley 2009-01-19 22:27:10 -04:00
parent 5c17da6572
commit 83648af19f
3 changed files with 16 additions and 3 deletions

View file

@ -272,6 +272,11 @@ value_t report_t::get_total_expr(call_scope_t& scope)
return total_expr.calc(scope);
}
value_t report_t::get_display_total(call_scope_t& scope)
{
return display_total.calc(scope);
}
namespace {
value_t print_balance(call_scope_t& args)
{
@ -474,6 +479,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
}
break;
case 'd':
if (std::strcmp(p, "display_total") == 0)
return MAKE_FUNCTOR(report_t::get_display_total);
break;
case 'o':
if (std::strncmp(p, "opt_", 4) == 0) {
p = p + 4;

View file

@ -104,6 +104,7 @@ public:
expr_t amount_expr;
expr_t total_expr;
expr_t display_total;
unsigned long budget_flags;
@ -139,6 +140,7 @@ public:
explicit report_t(session_t& _session)
: amount_expr("amount"),
total_expr("total"),
display_total("total_expr"),
head_entries(0),
tail_entries(0),
@ -675,6 +677,7 @@ public:
value_t get_amount_expr(call_scope_t& scope);
value_t get_total_expr(call_scope_t& scope);
value_t get_display_total(call_scope_t& scope);
value_t option_amount_data(call_scope_t&) { // j
format_string = session.plot_amount_format;

View file

@ -72,16 +72,16 @@ void release_session_context()
session_t::session_t()
: register_format
("%-.9(date) %-.20(payee) %-.23(account) %!12(print_balance(amount_expr, 12, 67)) "
"%!12(print_balance(total_expr, 12, 80, true))\n%/"
"%!12(print_balance(display_total, 12, 80, true))\n%/"
"%31|%-.23(account) %!12(print_balance(amount_expr, 12, 67)) "
"%!12(print_balance(total_expr, 12, 80, true))\n"),
"%!12(print_balance(display_total, 12, 80, true))\n"),
wide_register_format
("%-.9D %-.35P %-.39A %22.108t %!22.132T\n%/"
"%48|%-.38A %22.108t %!22.132T\n"),
print_format
("%(date)%(cleared ? \" *\" : (uncleared ? \"\" : \" !\"))%(code ? \" (\" + code + \")\" : \"\") %(payee)\n %-34(account) %12(amount)\n%/ %-34(account) %12(amount)%(note ? \" ; \" + note : \"\")\n%/\n"),
balance_format
("%20(total_expr) %(depth_spacer)%-(partial_account)\n"),
("%20(display_total) %(depth_spacer)%-(partial_account)\n"),
equity_format
("\n%D %Y%C%P\n%/ %-34W %12t\n"),
plot_amount_format