summaryrefslogtreecommitdiff
path: root/src/xact.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-27 08:18:11 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-27 08:30:59 -0400
commit63ae4531b8a7c8ba268c6a4bd3c971a49d06f2db (patch)
tree4bb688daf5905c113444589b29aafa6ee24170c5 /src/xact.cc
parent1f379eff70bf38e952e9ec1975d0598b0d2da495 (diff)
downloadfork-ledger-63ae4531b8a7c8ba268c6a4bd3c971a49d06f2db.tar.gz
fork-ledger-63ae4531b8a7c8ba268c6a4bd3c971a49d06f2db.tar.bz2
fork-ledger-63ae4531b8a7c8ba268c6a4bd3c971a49d06f2db.zip
Support balancing of postings with integer amounts
Diffstat (limited to 'src/xact.cc')
-rw-r--r--src/xact.cc7
1 files changed, 6 insertions, 1 deletions
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<xact_t *>(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)