summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-17 09:11:23 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:35:36 -0400
commit269a7c6f3bb6f2d8d537c9df6b78ce6a24796678 (patch)
tree88b55d6200b638667f8e8d2411eb51236ae73400
parentd650725f373e61bec4e64c1fe2c7189086c8be61 (diff)
downloadfork-ledger-269a7c6f3bb6f2d8d537c9df6b78ce6a24796678.tar.gz
fork-ledger-269a7c6f3bb6f2d8d537c9df6b78ce6a24796678.tar.bz2
fork-ledger-269a7c6f3bb6f2d8d537c9df6b78ce6a24796678.zip
Got most of the commodity tests working, save multiplication and division.
-rw-r--r--amount.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/amount.cc b/amount.cc
index a3a7fb40..73bc6718 100644
--- a/amount.cc
+++ b/amount.cc
@@ -634,6 +634,13 @@ amount_t& amount_t::operator/=(const amount_t& amt)
goto finish;
}
+ if (has_commodity() && amt.has_commodity() &&
+ commodity() != amt.commodity())
+ throw new amount_error
+ (std::string("Dividing amounts with different commodities: ") +
+ (has_commodity() ? commodity_->qualified_symbol : "NONE") + " != " +
+ (amt.has_commodity() ? amt.commodity_->qualified_symbol : "NONE"));
+
_dup();
// Increase the value's precision, to capture fractional parts after