summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commodity.cc9
-rw-r--r--src/report.cc6
-rw-r--r--src/value.cc8
3 files changed, 16 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;