summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordbear496 <70439542+dbear496@users.noreply.github.com>2023-07-13 17:05:27 -0400
committerJohn Wiegley <johnw@newartisans.com>2023-07-16 05:22:57 -0700
commitc645ee10ccc9bebc90e68b1b148ce554e07736fb (patch)
tree9eb7ae66abace2181dedf101e28a2dad4621fc15
parent4a5b5c4db575710e910913c95f7b13419fe09919 (diff)
downloadfork-ledger-c645ee10ccc9bebc90e68b1b148ce554e07736fb.tar.gz
fork-ledger-c645ee10ccc9bebc90e68b1b148ce554e07736fb.tar.bz2
fork-ledger-c645ee10ccc9bebc90e68b1b148ce554e07736fb.zip
include zero-amounts in balance_t::map_sorted_amounts
-rw-r--r--src/balance.cc6
-rw-r--r--src/filters.cc1
2 files changed, 5 insertions, 2 deletions
diff --git a/src/balance.cc b/src/balance.cc
index a61fc9e5..9965fe8b 100644
--- a/src/balance.cc
+++ b/src/balance.cc
@@ -273,7 +273,7 @@ balance_t::strip_annotations(const keep_details_t& what_to_keep) const
void balance_t::sorted_amounts(amounts_array& sorted) const
{
foreach (const amounts_map::value_type& pair, amounts)
- if (pair.second)
+ if (! pair.second.is_null())
sorted.push_back(&pair.second);
std::stable_sort(
sorted.begin(), sorted.end(),
@@ -287,7 +287,7 @@ void balance_t::map_sorted_amounts(function<void(const amount_t&)> fn) const
if (! amounts.empty()) {
if (amounts.size() == 1) {
const amount_t& amount((*amounts.begin()).second);
- if (amount)
+ if (! amount.is_null())
fn(amount);
}
else {
@@ -327,6 +327,8 @@ namespace {
}
void operator()(const amount_t& amount) {
+ if(amount.is_zero()) return;
+
int width;
if (! first) {
out << std::endl;
diff --git a/src/filters.cc b/src/filters.cc
index f725c247..3acb5624 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -1082,6 +1082,7 @@ namespace {
}
void operator()(const amount_t& amount) {
+ if(amount.is_zero()) return;
post_t& balance_post = temps.create_post(xact, &balance_account);
balance_post.amount = - amount;
(*handler)(balance_post);