summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
Diffstat (limited to 'amount.cc')
-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