summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-20 19:10:16 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-20 19:10:34 -0400
commit96782df17c5e23dfb86bac745d9f7553a6f74fd4 (patch)
tree838cdc5db002c31a8d1b8ca2a4fe7006442db032
parent8483ea16e23eefd3281774c142c7117a8a87c245 (diff)
downloadfork-ledger-96782df17c5e23dfb86bac745d9f7553a6f74fd4.tar.gz
fork-ledger-96782df17c5e23dfb86bac745d9f7553a6f74fd4.tar.bz2
fork-ledger-96782df17c5e23dfb86bac745d9f7553a6f74fd4.zip
Enabled --current option
-rw-r--r--src/report.h4
-rw-r--r--src/session.cc5
-rw-r--r--src/session.h4
-rw-r--r--test/baseline/opt-current.test17
4 files changed, 29 insertions, 1 deletions
diff --git a/src/report.h b/src/report.h
index 5bd98360..991d60ba 100644
--- a/src/report.h
+++ b/src/report.h
@@ -297,7 +297,9 @@ public:
"%(quoted(join(note)))\n");
});
- OPTION(report_t, current); // -c
+ OPTION_(report_t, current, DO() { // -c
+ parent->HANDLER(limit_).on("date<=today");
+ });
OPTION_(report_t, daily, DO() {
parent->HANDLER(period_).on("daily");
diff --git a/src/session.cc b/src/session.cc
index 7a3ecf19..8e505c22 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -241,6 +241,11 @@ expr_t::ptr_op_t session_t::lookup(const string& name)
return MAKE_OPT_HANDLER(session_t, handler);
}
break;
+
+ case 't':
+ if (is_eq(p, "today"))
+ return MAKE_FUNCTOR(session_t::fn_today);
+ break;
}
return symbol_scope_t::lookup(name);
diff --git a/src/session.h b/src/session.h
index d2320bb7..cb71c61b 100644
--- a/src/session.h
+++ b/src/session.h
@@ -98,6 +98,10 @@ public:
clean_accounts();
}
+ value_t fn_today(call_scope_t&) {
+ return CURRENT_DATE();
+ }
+
option_t<session_t> * lookup_option(const char * p);
virtual expr_t::ptr_op_t lookup(const string& name);
diff --git a/test/baseline/opt-current.test b/test/baseline/opt-current.test
new file mode 100644
index 00000000..a0450ea2
--- /dev/null
+++ b/test/baseline/opt-current.test
@@ -0,0 +1,17 @@
+bal --current
+<<<
+2007/02/02 RD VMMXX
+ Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
+ Income:Dividends:Vanguard:VMMXX $-0.35
+
+2700/02/02 RD VMMXX
+ Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
+ Income:Dividends:Vanguard:VMMXX $-0.35
+>>>1
+ 0.350 VMMXX Assets:Investments:Vanguard:VMMXX
+ $-0.35 Income:Dividends:Vanguard:VMMXX
+--------------------
+ $-0.35
+ 0.350 VMMXX
+>>>2
+=== 0