When --end is used, set a "terminus" date
This means that final balance valuations (with -V or -X) will be done in terms of the date given to --end, rather than based on the current day. Fixes 647D5DB9-DBBB-47C8-80CE-F3F70E3B0253
This commit is contained in:
parent
849e4b2fbb
commit
3a926da4cb
5 changed files with 39 additions and 26 deletions
|
|
@ -753,6 +753,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
|
||||||
return MAKE_FUNCTOR(report_t::fn_display_amount);
|
return MAKE_FUNCTOR(report_t::fn_display_amount);
|
||||||
else if (is_eq(p, "display_total"))
|
else if (is_eq(p, "display_total"))
|
||||||
return MAKE_FUNCTOR(report_t::fn_display_total);
|
return MAKE_FUNCTOR(report_t::fn_display_total);
|
||||||
|
else if (is_eq(p, "date"))
|
||||||
|
return MAKE_FUNCTOR(report_t::fn_today);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
|
|
@ -789,6 +791,10 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
|
||||||
case 'n':
|
case 'n':
|
||||||
if (is_eq(p, "null"))
|
if (is_eq(p, "null"))
|
||||||
return WRAP_FUNCTOR(fn_null);
|
return WRAP_FUNCTOR(fn_null);
|
||||||
|
#if 0
|
||||||
|
else if (is_eq(p, "now"))
|
||||||
|
return MAKE_FUNCTOR(report_t::fn_now);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
|
|
@ -868,6 +874,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name)
|
||||||
return MAKE_FUNCTOR(report_t::fn_truncated);
|
return MAKE_FUNCTOR(report_t::fn_truncated);
|
||||||
else if (is_eq(p, "total_expr"))
|
else if (is_eq(p, "total_expr"))
|
||||||
return MAKE_FUNCTOR(report_t::fn_total_expr);
|
return MAKE_FUNCTOR(report_t::fn_total_expr);
|
||||||
|
else if (is_eq(p, "today"))
|
||||||
|
return MAKE_FUNCTOR(report_t::fn_today);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
|
|
|
||||||
18
src/report.h
18
src/report.h
|
|
@ -119,10 +119,12 @@ public:
|
||||||
#define BUDGET_BUDGETED 0x01
|
#define BUDGET_BUDGETED 0x01
|
||||||
#define BUDGET_UNBUDGETED 0x02
|
#define BUDGET_UNBUDGETED 0x02
|
||||||
|
|
||||||
|
date_t terminus;
|
||||||
uint_least8_t budget_flags;
|
uint_least8_t budget_flags;
|
||||||
|
|
||||||
explicit report_t(session_t& _session)
|
explicit report_t(session_t& _session)
|
||||||
: session(_session), budget_flags(BUDGET_NO_BUDGET) {}
|
: session(_session), terminus(CURRENT_DATE()),
|
||||||
|
budget_flags(BUDGET_NO_BUDGET) {}
|
||||||
|
|
||||||
virtual ~report_t() {
|
virtual ~report_t() {
|
||||||
output_stream.close();
|
output_stream.close();
|
||||||
|
|
@ -154,6 +156,15 @@ public:
|
||||||
value_t fn_format_date(call_scope_t& scope);
|
value_t fn_format_date(call_scope_t& scope);
|
||||||
value_t fn_ansify_if(call_scope_t& scope);
|
value_t fn_ansify_if(call_scope_t& scope);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
value_t fn_now(call_scope_t&) {
|
||||||
|
return CURRENT_TIME();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
value_t fn_today(call_scope_t&) {
|
||||||
|
return terminus;
|
||||||
|
}
|
||||||
|
|
||||||
value_t fn_options(call_scope_t&) {
|
value_t fn_options(call_scope_t&) {
|
||||||
return value_t(static_cast<scope_t *>(this));
|
return value_t(static_cast<scope_t *>(this));
|
||||||
}
|
}
|
||||||
|
|
@ -476,9 +487,8 @@ public:
|
||||||
string predicate =
|
string predicate =
|
||||||
"date<[" + to_iso_extended_string(*interval.start) + "]";
|
"date<[" + to_iso_extended_string(*interval.start) + "]";
|
||||||
parent->HANDLER(limit_).on(string("--end"), predicate);
|
parent->HANDLER(limit_).on(string("--end"), predicate);
|
||||||
#if 0
|
|
||||||
terminus = interval.begin;
|
parent->terminus = *interval.start;
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
|
|
||||||
OPTION(report_t, equity);
|
OPTION(report_t, equity);
|
||||||
|
|
|
||||||
|
|
@ -245,27 +245,12 @@ expr_t::ptr_op_t session_t::lookup(const string& name)
|
||||||
{
|
{
|
||||||
const char * p = name.c_str();
|
const char * p = name.c_str();
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case 'd':
|
|
||||||
if (is_eq(p, "date"))
|
|
||||||
return MAKE_FUNCTOR(session_t::fn_today);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
if (is_eq(p, "now"))
|
|
||||||
return MAKE_FUNCTOR(session_t::fn_now);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
if (WANT_OPT()) { p += OPT_PREFIX_LEN;
|
if (WANT_OPT()) { p += OPT_PREFIX_LEN;
|
||||||
if (option_t<session_t> * handler = lookup_option(p))
|
if (option_t<session_t> * handler = lookup_option(p))
|
||||||
return MAKE_OPT_HANDLER(session_t, handler);
|
return MAKE_OPT_HANDLER(session_t, handler);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
|
||||||
if (is_eq(p, "today"))
|
|
||||||
return MAKE_FUNCTOR(session_t::fn_today);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if they are trying to access an option's setting or value.
|
// Check if they are trying to access an option's setting or value.
|
||||||
|
|
|
||||||
|
|
@ -101,13 +101,6 @@ public:
|
||||||
clean_accounts();
|
clean_accounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
value_t fn_now(call_scope_t&) {
|
|
||||||
return CURRENT_TIME();
|
|
||||||
}
|
|
||||||
value_t fn_today(call_scope_t&) {
|
|
||||||
return CURRENT_DATE();
|
|
||||||
}
|
|
||||||
|
|
||||||
void report_options(std::ostream& out)
|
void report_options(std::ostream& out)
|
||||||
{
|
{
|
||||||
HANDLER(account_).report(out);
|
HANDLER(account_).report(out);
|
||||||
|
|
|
||||||
17
test/regress/647D5DB9.test
Normal file
17
test/regress/647D5DB9.test
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
bal --end 2008/12/31 -JV bal Equities
|
||||||
|
<<<
|
||||||
|
2008/01/01 * Purchase Apple shares
|
||||||
|
Equities 1000 AAPL @ $2
|
||||||
|
Cash
|
||||||
|
|
||||||
|
2008/06/30 * Sell some Apple shares
|
||||||
|
Equities -500 AAPL @ $2.5
|
||||||
|
Cash
|
||||||
|
|
||||||
|
P 2008/10/01 02:18:02 AAPL $3
|
||||||
|
P 2009/01/31 02:18:02 AAPL $4
|
||||||
|
P 3000/01/01 02:18:02 APPL $100
|
||||||
|
>>>1
|
||||||
|
2008-12-31 1500
|
||||||
|
>>>2
|
||||||
|
=== 0
|
||||||
Loading…
Add table
Reference in a new issue