summaryrefslogtreecommitdiff
path: root/src/filters.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-19 04:18:56 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-03-19 04:18:56 -0500
commitd2422f99e6edd17b86502b34be4fb618fe4c838d (patch)
treecbb8fb383ad6e7ca208d6f353a056c5640ffb3d8 /src/filters.cc
parentaee05dc7b7099d4bff8827e293e6b1e3442b9cd9 (diff)
downloadfork-ledger-d2422f99e6edd17b86502b34be4fb618fe4c838d.tar.gz
fork-ledger-d2422f99e6edd17b86502b34be4fb618fe4c838d.tar.bz2
fork-ledger-d2422f99e6edd17b86502b34be4fb618fe4c838d.zip
Allow the equity command to strip annotations
Diffstat (limited to 'src/filters.cc')
-rw-r--r--src/filters.cc47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 749efc77..96e8026a 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -1033,40 +1033,45 @@ void posts_as_equity::report_subtotal()
value_t total = 0L;
foreach (values_map::value_type& pair, values) {
- if (pair.second.value.is_balance()) {
- foreach (const balance_t::amounts_map::value_type& amount_pair,
- pair.second.value.as_balance().amounts)
- handle_value(/* value= */ amount_pair.second,
+ value_t value(pair.second.value.strip_annotations(report.what_to_keep()));
+ if (! value.is_zero()) {
+ if (value.is_balance()) {
+ foreach (const balance_t::amounts_map::value_type& amount_pair,
+ value.as_balance_lval().amounts)
+ handle_value(/* value= */ amount_pair.second,
+ /* account= */ pair.second.account,
+ /* xact= */ &xact,
+ /* temps= */ temps,
+ /* handler= */ handler,
+ /* date= */ finish,
+ /* act_date_p= */ false);
+ } else {
+ handle_value(/* value= */ value.to_amount(),
/* account= */ pair.second.account,
/* xact= */ &xact,
/* temps= */ temps,
/* handler= */ handler,
/* date= */ finish,
/* act_date_p= */ false);
- } else {
- handle_value(/* value= */ pair.second.value,
- /* account= */ pair.second.account,
- /* xact= */ &xact,
- /* temps= */ temps,
- /* handler= */ handler,
- /* date= */ finish,
- /* act_date_p= */ false);
+ }
}
- total += pair.second.value;
+ total += value;
}
values.clear();
- if (total.is_balance()) {
- foreach (const balance_t::amounts_map::value_type& pair,
- total.as_balance().amounts) {
+ if (! total.is_zero()) {
+ if (total.is_balance()) {
+ foreach (const balance_t::amounts_map::value_type& pair,
+ total.as_balance().amounts) {
+ post_t& balance_post = temps.create_post(xact, balance_account);
+ balance_post.amount = - pair.second;
+ (*handler)(balance_post);
+ }
+ } else {
post_t& balance_post = temps.create_post(xact, balance_account);
- balance_post.amount = - pair.second;
+ balance_post.amount = - total.to_amount();
(*handler)(balance_post);
}
- } else {
- post_t& balance_post = temps.create_post(xact, balance_account);
- balance_post.amount = - total.to_amount();
- (*handler)(balance_post);
}
}