Added --historical option
This commit is contained in:
parent
21e8b7f6f0
commit
113fb0ee6a
4 changed files with 72 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
61
test/baseline/opt-historical.test
Normal file
61
test/baseline/opt-historical.test
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue