From 63ae4531b8a7c8ba268c6a4bd3c971a49d06f2db Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 08:18:11 -0400 Subject: [PATCH] Support balancing of postings with integer amounts --- src/xact.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/xact.cc b/src/xact.cc index c0d1c724..6ea8d8f9 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -163,11 +163,14 @@ bool xact_base_t::finalize() null_post->amount = balance.as_amount().negated(); null_post->add_flags(POST_CALCULATED); } + else if (balance.is_long()) { + null_post->amount = amount_t(- balance.as_long()); + null_post->add_flags(POST_CALCULATED); + } else if (! balance.is_null() && ! balance.is_realzero()) { throw_(balance_error, _("Transaction does not balance")); } balance = NULL_VALUE; - } else if (balance.is_balance() && balance.as_balance().amounts.size() == 2) { @@ -314,6 +317,7 @@ bool xact_base_t::finalize() if (dynamic_cast(this)) { bool all_null = true; bool some_null = false; + foreach (post_t * post, posts) { if (! post->amount.is_null()) { all_null = false; @@ -327,6 +331,7 @@ bool xact_base_t::finalize() post->xdata().add_flags(POST_EXT_VISITED); post->account->xdata().add_flags(ACCOUNT_EXT_VISITED); } + if (all_null) return false; // ignore this xact completely else if (some_null)