diff options
-rw-r--r-- | src/commodity.cc | 9 | ||||
-rw-r--r-- | src/report.cc | 6 | ||||
-rw-r--r-- | src/value.cc | 8 | ||||
-rw-r--r-- | test/regress/BFD3FBE1.test | 17 |
4 files changed, 33 insertions, 7 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index 0dad9a1a..5335d8a8 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -481,6 +481,15 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left, if (aleftcomm.details.tag && arightcomm.details.tag) return *aleftcomm.details.tag < *arightcomm.details.tag; + if (! aleftcomm.details.value_expr && arightcomm.details.value_expr) + return true; + if (aleftcomm.details.value_expr && ! arightcomm.details.value_expr) + return false; + + if (aleftcomm.details.value_expr && arightcomm.details.value_expr) + return (aleftcomm.details.value_expr->text() < + arightcomm.details.value_expr->text()); + assert(false); return true; } diff --git a/src/report.cc b/src/report.cc index 28836d0f..21fc9c1b 100644 --- a/src/report.cc +++ b/src/report.cc @@ -813,10 +813,12 @@ value_t report_t::fn_nail_down(call_scope_t& args) switch (arg0.type()) { case value_t::AMOUNT: { amount_t tmp(arg0.as_amount()); - if (tmp.has_commodity() && ! arg1.is_null()) { + if (tmp.has_commodity() && ! tmp.is_null() && ! tmp.is_realzero()) { + arg1 = arg1.strip_annotations(keep_details_t()).to_amount(); expr_t value_expr(is_expr(arg1) ? as_expr(arg1) : - expr_t::op_t::wrap_value(arg1.unrounded() / arg0)); + expr_t::op_t::wrap_value(arg1.unrounded() / + arg0.number())); std::ostringstream buf; value_expr.print(buf); value_expr.set_text(buf.str()); diff --git a/src/value.cc b/src/value.cc index c14a7104..2b1b561f 100644 --- a/src/value.cc +++ b/src/value.cc @@ -742,7 +742,7 @@ value_t& value_t::operator/=(const value_t& val) break; } - add_error_context(_("While dividing %1 by %2:") << val << *this); + add_error_context(_("While dividing %1 by %2:") << *this << val); throw_(value_error, _("Cannot divide %1 by %2") << label() << val.label()); return *this; @@ -948,8 +948,7 @@ bool value_t::is_less_than(const value_t& val) const break; } - add_error_context(_("While comparing if %1 is less than %2:") - << *this << val); + add_error_context(_("While comparing if %1 is less than %2:") << *this << val); throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label()); return *this; @@ -1064,8 +1063,7 @@ bool value_t::is_greater_than(const value_t& val) const break; } - add_error_context(_("While comparing if %1 is greater than %2:") - << *this << val); + add_error_context(_("While comparing if %1 is greater than %2:") << *this << val); throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label()); return *this; diff --git a/test/regress/BFD3FBE1.test b/test/regress/BFD3FBE1.test new file mode 100644 index 00000000..5b2f8b42 --- /dev/null +++ b/test/regress/BFD3FBE1.test @@ -0,0 +1,17 @@ +2011-01-01 * Opening balance + Assets:Investment 100 "AAA" @ 16.58900489 EUR + Assets:Investments 5 "BBB" @ 24.79900855 EUR + Equity:Opening balance + +2011-02-10 * Reimbursement: Taxi / Subway / Bus / Train + Assets:A 1.59 GBP + Assets:B -1.80 EUR @ 0.884955752212389381 GBP + +test reg -X EUR -H +11-Jan-01 Opening balance Assets:Investment 1658.90 EUR 1658.90 EUR + Assets:Investments 124.00 EUR 1782.90 EUR + Equity:Opening balance -1782.90 EUR 0 +11-Feb-10 Reimbursement: Taxi.. <Adjustment> -0.01 EUR -0.01 EUR + Assets:A 1.80 EUR 1.80 EUR + Assets:B -1.80 EUR 0 +end test |