Restored pricesdb command and --pricesdb-format option
This commit is contained in:
parent
47d237e18b
commit
1fd4387b67
6 changed files with 31 additions and 3 deletions
|
|
@ -101,7 +101,7 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
foreach (commodity_t::base_t::history_map::value_type hpair,
|
foreach (commodity_t::base_t::history_map::value_type hpair,
|
||||||
pair.second.prices) {
|
pair.second.prices) {
|
||||||
xact_t * xact;
|
xact_t * xact;
|
||||||
string symbol = hpair.second.commodity().symbol();
|
string symbol = hpair.second.commodity().symbol();
|
||||||
|
|
||||||
std::map<string, xact_t *>::iterator i =
|
std::map<string, xact_t *>::iterator i =
|
||||||
xacts_by_commodity.find(symbol);
|
xacts_by_commodity.find(symbol);
|
||||||
|
|
@ -123,6 +123,8 @@ void posts_commodities_iterator::reset(journal_t& journal)
|
||||||
temp.amount = hpair.second;
|
temp.amount = hpair.second;
|
||||||
temp.set_flags(ITEM_GENERATED | ITEM_TEMP);
|
temp.set_flags(ITEM_GENERATED | ITEM_TEMP);
|
||||||
|
|
||||||
|
temp.xdata().datetime = hpair.first;
|
||||||
|
|
||||||
xact->add_post(&temp);
|
xact->add_post(&temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ protected:
|
||||||
|
|
||||||
std::list<post_t> post_temps;
|
std::list<post_t> post_temps;
|
||||||
std::list<account_t> acct_temps;
|
std::list<account_t> acct_temps;
|
||||||
xacts_list xact_temps;
|
xacts_list xact_temps;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
posts_commodities_iterator() {
|
posts_commodities_iterator() {
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,10 @@ namespace {
|
||||||
return long(post.reported_account()->depth);
|
return long(post.reported_account()->depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_t get_datetime(post_t& post) {
|
||||||
|
return post.xdata().datetime;
|
||||||
|
}
|
||||||
|
|
||||||
template <value_t (*Func)(post_t&)>
|
template <value_t (*Func)(post_t&)>
|
||||||
value_t get_wrapper(call_scope_t& scope) {
|
value_t get_wrapper(call_scope_t& scope) {
|
||||||
return (*Func)(find_scope<post_t>(scope));
|
return (*Func)(find_scope<post_t>(scope));
|
||||||
|
|
@ -282,6 +286,8 @@ expr_t::ptr_op_t post_t::lookup(const string& name)
|
||||||
case 'd':
|
case 'd':
|
||||||
if (name == "depth")
|
if (name == "depth")
|
||||||
return WRAP_FUNCTOR(get_wrapper<&get_account_depth>);
|
return WRAP_FUNCTOR(get_wrapper<&get_account_depth>);
|
||||||
|
else if (name == "datetime")
|
||||||
|
return WRAP_FUNCTOR(get_wrapper<&get_datetime>);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ public:
|
||||||
value_t total;
|
value_t total;
|
||||||
std::size_t count;
|
std::size_t count;
|
||||||
date_t date;
|
date_t date;
|
||||||
|
datetime_t datetime;
|
||||||
account_t * account;
|
account_t * account;
|
||||||
void * ptr;
|
void * ptr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ public:
|
||||||
|
|
||||||
OPTION__(report_t, pricesdb_format_, CTOR(report_t, pricesdb_format_) {
|
OPTION__(report_t, pricesdb_format_, CTOR(report_t, pricesdb_format_) {
|
||||||
on(none,
|
on(none,
|
||||||
"P %[%Y/%m/%d %H:%M:%S] %A %t\n");
|
"P %(datetime) %(account) %(scrub(display_amount))\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
OPTION__(report_t, print_format_, CTOR(report_t, print_format_) {
|
OPTION__(report_t, print_format_, CTOR(report_t, print_format_) {
|
||||||
|
|
|
||||||
19
test/baseline/opt-pricesdb-format.test
Normal file
19
test/baseline/opt-pricesdb-format.test
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
pricesdb --pricesdb-format='P %(date) %(scrub(display_amount))\n'
|
||||||
|
<<<
|
||||||
|
P 2009/01/01 13:30:00 AAPL $10.00
|
||||||
|
P 2009/01/01 14:30:00 AAPL $20.00
|
||||||
|
P 2009/01/01 15:30:00 AAPL $30.00
|
||||||
|
P 2009/01/01 16:30:00 AAPL $40.00
|
||||||
|
P 2009/02/01 17:30:00 AAPL $50.00
|
||||||
|
|
||||||
|
2009/03/01 Purchase
|
||||||
|
Assets:Brokerage 100 AAPL
|
||||||
|
Income
|
||||||
|
>>>1
|
||||||
|
P 09-Jan-01 $10.00
|
||||||
|
P 09-Jan-01 $20.00
|
||||||
|
P 09-Jan-01 $30.00
|
||||||
|
P 09-Jan-01 $40.00
|
||||||
|
P 09-Feb-01 $50.00
|
||||||
|
>>>2
|
||||||
|
=== 0
|
||||||
Loading…
Add table
Reference in a new issue