summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-09 01:23:38 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-09 02:22:50 -0400
commitfc09b69fb765dc934be10d0544b1366f86f21ee2 (patch)
tree755313686184c4f538c27f12c474266f61d22148 /src/post.cc
parent524c98244ec19e6a0368deb1e05c69955bcf2e34 (diff)
downloadfork-ledger-fc09b69fb765dc934be10d0544b1366f86f21ee2.tar.gz
fork-ledger-fc09b69fb765dc934be10d0544b1366f86f21ee2.tar.bz2
fork-ledger-fc09b69fb765dc934be10d0544b1366f86f21ee2.zip
Fixed interaction with -V/X and grouped postings
With -s, -M/Y/D, -n, and a few other flags, postings get "grouped" into meta-transactions that contain more postings than before. In all these cases, -V use the date of the *earliest* posting in that group, which makes little sense and caused breakages with -J. It now uses the latest date. Fixes #197 / 68EAF363-D0FE-4127-866E-A5AEBACB65D6
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/post.cc b/src/post.cc
index 7dc15830..e182a731 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -78,6 +78,13 @@ optional<string> post_t::get_tag(const mask_t& tag_mask,
return none;
}
+date_t post_t::value_date() const
+{
+ if (xdata_ && is_valid(xdata_->value_date))
+ return xdata_->value_date;
+ return date();
+}
+
date_t post_t::date() const
{
if (xdata_ && is_valid(xdata_->date))
@@ -319,6 +326,14 @@ namespace {
return long(post.reported_account()->depth);
}
+ value_t get_value_date(post_t& post) {
+ if (post.has_xdata()) {
+ post_t::xdata_t& xdata(post.xdata());
+ if (! xdata.value_date.is_not_a_date())
+ return xdata.value_date;
+ }
+ return post.date();
+ }
value_t get_datetime(post_t& post) {
return post.xdata().datetime;
}
@@ -479,6 +494,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
case 'v':
if (name == "virtual")
return WRAP_FUNCTOR(get_wrapper<&get_virtual>);
+ else if (name == "value_date")
+ return WRAP_FUNCTOR(get_wrapper<&get_value_date>);
break;
case 'x':