diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-11 21:32:18 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-11 21:32:32 -0500 |
commit | 67c9cf134d1403657c766e72b96d692a7d538f65 (patch) | |
tree | cd72247ddf240746b524c8fecf6d10f8667b37e4 /src/filters.cc | |
parent | c22b8457eff27f5227fdf452e036b33e41e229c2 (diff) | |
download | fork-ledger-67c9cf134d1403657c766e72b96d692a7d538f65.tar.gz fork-ledger-67c9cf134d1403657c766e72b96d692a7d538f65.tar.bz2 fork-ledger-67c9cf134d1403657c766e72b96d692a7d538f65.zip |
Added --date, similar to --account and --payee
This lets you do things like store a date as the value of a tag, then
run:
ledger --date='has_tag("Foo") ? to_date(tag("Foo")) : date' reg
Diffstat (limited to 'src/filters.cc')
-rw-r--r-- | src/filters.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/filters.cc b/src/filters.cc index 4b54a0cd..8c5d099e 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -706,22 +706,27 @@ void transfer_details::operator()(post_t& post) temp.set_state(post.state()); bind_scope_t bound_scope(scope, temp); + value_t substitute(expr.calc(bound_scope)); switch (which_element) { - case SET_PAYEE: - xact.payee = expr.calc(bound_scope).to_string(); + case SET_DATE: + xact.set_date(substitute.to_date()); break; case SET_ACCOUNT: { std::list<string> account_names; temp.account->remove_post(&temp); - split_string(expr.calc(bound_scope).to_string(), ':', account_names); + split_string(substitute.to_string(), ':', account_names); temp.account = create_temp_account_from_path(account_names, temps, xact.journal->master); temp.account->add_post(&temp); break; } + case SET_PAYEE: + xact.payee = substitute.to_string(); + break; + default: assert(false); break; |