diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-08 01:00:16 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-08 01:00:16 -0600 |
commit | 113fb0ee6a520dccdcd18a634f7ee73acd8ee488 (patch) | |
tree | e8038d74b59e2d71cabbfefc3fda5453332a5b77 | |
parent | 21e8b7f6f0a182f67899c5cd3689a5e646d8ed4a (diff) | |
download | fork-ledger-113fb0ee6a520dccdcd18a634f7ee73acd8ee488.tar.gz fork-ledger-113fb0ee6a520dccdcd18a634f7ee73acd8ee488.tar.bz2 fork-ledger-113fb0ee6a520dccdcd18a634f7ee73acd8ee488.zip |
Added --historical option
-rw-r--r-- | doc/ledger.1 | 3 | ||||
-rw-r--r-- | src/report.cc | 3 | ||||
-rw-r--r-- | src/report.h | 8 | ||||
-rw-r--r-- | test/baseline/opt-historical.test | 61 |
4 files changed, 72 insertions, 3 deletions
diff --git a/doc/ledger.1 b/doc/ledger.1 index 4829034f..2fb074cb 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1,4 +1,4 @@ -.Dd February 28, 2012 +.Dd March 7, 2012 .Dt ledger 1 .Sh NAME .Nm ledger @@ -163,6 +163,7 @@ Show any gains (or losses) in commodity values over time. Only show the top .Ar number postings. +.It Fl \-historical Pq Fl H .It Fl \-invert Invert the value of amounts shown. .It Fl \-market Pq Fl V diff --git a/src/report.cc b/src/report.cc index ba70d1d3..26e6da0c 100644 --- a/src/report.cc +++ b/src/report.cc @@ -924,11 +924,9 @@ option_t<report_t> * report_t::lookup_option(const char * p) case 'G': OPT_CH(gain); break; -#if 0 case 'H': OPT_CH(historical); break; -#endif case 'I': OPT_CH(price); break; @@ -1044,6 +1042,7 @@ option_t<report_t> * report_t::lookup_option(const char * p) break; case 'h': OPT(head_); + else OPT(historical); break; case 'i': OPT(invert); diff --git a/src/report.h b/src/report.h index 515b14c2..d68d1f75 100644 --- a/src/report.h +++ b/src/report.h @@ -645,6 +645,14 @@ public: }); OPTION(report_t, head_); + + OPTION_(report_t, historical, DO() { // -H + parent->HANDLER(amount_) + .set_expr(string("--historical"), + "nail_down(amount_expr, (s,d,t -> market(s,value_date,t)))"); + }); + + OPTION(report_t, inject_); OPTION_(report_t, invert, DO() { diff --git a/test/baseline/opt-historical.test b/test/baseline/opt-historical.test new file mode 100644 index 00000000..1cd141ab --- /dev/null +++ b/test/baseline/opt-historical.test @@ -0,0 +1,61 @@ +2012-03-01 Broker + Assets:Stocks 10 APPL {$1} @ $1 + Equity + +2012-03-02 Broker + Assets:Stocks 10 APPL {$1} @ $2 + Equity + +2012-03-03 Broker + Assets:Stocks 10 APPL {$1} @ $3 + Equity + +2012-03-04 Broker + Assets:Stocks 10 APPL {$1} @ $4 + Equity + +2012-03-05 Broker + Assets:Stocks 10 APPL {$1} @ $5 + Equity + +test reg stocks -O +12-Mar-01 Broker Assets:Stocks 10 APPL 10 APPL +12-Mar-02 Broker Assets:Stocks 10 APPL 20 APPL +12-Mar-03 Broker Assets:Stocks 10 APPL 30 APPL +12-Mar-04 Broker Assets:Stocks 10 APPL 40 APPL +12-Mar-05 Broker Assets:Stocks 10 APPL 50 APPL +end test + +test reg stocks -B +12-Mar-01 Broker Assets:Stocks $10 $10 +12-Mar-02 Broker Assets:Stocks $20 $30 +12-Mar-03 Broker Assets:Stocks $30 $60 +12-Mar-04 Broker Assets:Stocks $40 $100 +12-Mar-05 Broker Assets:Stocks $50 $150 +end test + +test reg stocks -I +12-Mar-01 Broker Assets:Stocks $10 $10 +12-Mar-02 Broker Assets:Stocks $10 $20 +12-Mar-03 Broker Assets:Stocks $10 $30 +12-Mar-04 Broker Assets:Stocks $10 $40 +12-Mar-05 Broker Assets:Stocks $10 $50 +end test + +test reg stocks -O -H +end test + +test reg stocks -B -H +end test + +test reg stocks -I -H +end test + +test reg stocks -O -V +end test + +test reg stocks -B -V +end test + +test reg stocks -I -V +end test |