diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-17 09:11:33 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:37 -0400 |
commit | d8296ddc57376ab76b2a4a2c99ef3d0e884b33b8 (patch) | |
tree | 1ad2a6b168ed9609c9f03ad122ab2055694ee900 | |
parent | 269a7c6f3bb6f2d8d537c9df6b78ce6a24796678 (diff) | |
download | fork-ledger-d8296ddc57376ab76b2a4a2c99ef3d0e884b33b8.tar.gz fork-ledger-d8296ddc57376ab76b2a4a2c99ef3d0e884b33b8.tar.bz2 fork-ledger-d8296ddc57376ab76b2a4a2c99ef3d0e884b33b8.zip |
Completed commodity math tests.
-rw-r--r-- | amount.cc | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -635,11 +635,21 @@ amount_t& amount_t::operator/=(const amount_t& amt) } if (has_commodity() && amt.has_commodity() && - commodity() != amt.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")); + } + + if (! amt.quantity || ! amt) { + throw new amount_error("Divide by zero"); + } + else if (! quantity) { + *this = amt; + *this = *this - *this; // preserve the foreign commodity + goto finish; + } _dup(); |