summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2005-02-12 07:40:16 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:40:58 -0400
commite0a4109856ddc3664ad25b779dc20e7f74545445 (patch)
tree63009a6a002c99723ce4bd98c2ba17b9f1aa7799
parent4df96ff13b20ae4ca2498e675d7a5ff7ff64fccc (diff)
downloadfork-ledger-e0a4109856ddc3664ad25b779dc20e7f74545445.tar.gz
fork-ledger-e0a4109856ddc3664ad25b779dc20e7f74545445.tar.bz2
fork-ledger-e0a4109856ddc3664ad25b779dc20e7f74545445.zip
(reconcile_transactions): Added an error message, to make it easier to
know when the commodity is wrong to --reconcile (such as using $ instead of \$ in the UNIX shell).
-rw-r--r--reconcile.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/reconcile.cc b/reconcile.cc
index 555f3d60..9d6cae70 100644
--- a/reconcile.cc
+++ b/reconcile.cc
@@ -75,11 +75,20 @@ void reconcile_transactions(transactions_list& xact_list,
return;
}
- balance -= cleared_balance;
- if (balance.type >= value_t::BALANCE)
+ if (cleared_balance.type >= value_t::BALANCE)
throw error("Cannot reconcile accounts with multiple commodities");
+
+ cleared_balance.cast(value_t::AMOUNT);
balance.cast(value_t::AMOUNT);
+ commodity_t& cb_comm = ((amount_t *) cleared_balance.data)->commodity();
+ commodity_t& b_comm = ((amount_t *) balance.data)->commodity();
+
+ balance -= cleared_balance;
+ if (balance.type >= value_t::BALANCE)
+ throw error(std::string("Reconcile balance is not of the same commodity ('") +
+ b_comm.symbol + "' != '" + cb_comm.symbol + "')");
+
// If the amount to reconcile is the same as the pending balance,
// then assume an exact match and return the results right away.
amount_t to_reconcile = *((amount_t *) balance.data);