summaryrefslogtreecommitdiff
path: root/src/annotate.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-23 19:31:06 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-23 19:31:06 -0400
commiteda6cbd0146d371653feec70e0eb3ee4e4c56379 (patch)
treeaeb4e1ace0f9b284789f66f3ceb30bed66946b93 /src/annotate.cc
parent014fde3418783d1ee1ec7fe4ea6c8b04ae7f6cd8 (diff)
parent93807fade69dd4f0ec575eda78fe1a77a85c24e3 (diff)
downloadfork-ledger-eda6cbd0146d371653feec70e0eb3ee4e4c56379.tar.gz
fork-ledger-eda6cbd0146d371653feec70e0eb3ee4e4c56379.tar.bz2
fork-ledger-eda6cbd0146d371653feec70e0eb3ee4e4c56379.zip
Merge branch 'next'
Diffstat (limited to 'src/annotate.cc')
-rw-r--r--src/annotate.cc50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/annotate.cc b/src/annotate.cc
index 08b73443..33c0aebb 100644
--- a/src/annotate.cc
+++ b/src/annotate.cc
@@ -166,15 +166,27 @@ annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep)
commodity_t * new_comm;
- bool keep_price = (what_to_keep.keep_price &&
- (! what_to_keep.only_actuals ||
- ! details.has_flags(ANNOTATION_PRICE_CALCULATED)));
- bool keep_date = (what_to_keep.keep_date &&
- (! what_to_keep.only_actuals ||
- ! details.has_flags(ANNOTATION_DATE_CALCULATED)));
- bool keep_tag = (what_to_keep.keep_tag &&
- (! what_to_keep.only_actuals ||
- ! details.has_flags(ANNOTATION_TAG_CALCULATED)));
+ bool keep_price =
+ ((what_to_keep.keep_price ||
+ (details.has_flags(ANNOTATION_PRICE_FIXATED) &&
+ has_flags(COMMODITY_SAW_ANN_PRICE_FLOAT) &&
+ has_flags(COMMODITY_SAW_ANN_PRICE_FIXATED))) &&
+ (! what_to_keep.only_actuals ||
+ ! details.has_flags(ANNOTATION_PRICE_CALCULATED)));
+ bool keep_date =
+ (what_to_keep.keep_date &&
+ (! what_to_keep.only_actuals ||
+ ! details.has_flags(ANNOTATION_DATE_CALCULATED)));
+ bool keep_tag =
+ (what_to_keep.keep_tag &&
+ (! what_to_keep.only_actuals ||
+ ! details.has_flags(ANNOTATION_TAG_CALCULATED)));
+
+ DEBUG("commodity.annotated.strip",
+ "Reducing commodity " << *this << std::endl
+ << " keep price " << keep_price << " "
+ << " keep date " << keep_date << " "
+ << " keep tag " << keep_tag);
if ((keep_price && details.price) ||
(keep_date && details.date) ||
@@ -184,12 +196,24 @@ annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep)
(referent(), annotation_t(keep_price ? details.price : none,
keep_date ? details.date : none,
keep_tag ? details.tag : none));
- } else {
- new_comm = &referent();
+
+ // Transfer over any relevant annotation flags, as they still apply.
+ if (new_comm->annotated) {
+ annotation_t& new_details(as_annotated_commodity(*new_comm).details);
+ if (keep_price)
+ new_details.add_flags(details.flags() &
+ (ANNOTATION_PRICE_CALCULATED |
+ ANNOTATION_PRICE_FIXATED));
+ if (keep_date)
+ new_details.add_flags(details.flags() & ANNOTATION_DATE_CALCULATED);
+ if (keep_tag)
+ new_details.add_flags(details.flags() & ANNOTATION_TAG_CALCULATED);
+ }
+
+ return *new_comm;
}
- assert(new_comm);
- return *new_comm;
+ return referent();
}
void annotated_commodity_t::write_annotations