From 0d9d8453387e0f49f0dd4ea4b5f090da91c283bd Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 11 Mar 2012 03:06:03 -0500 Subject: Corrected a rounding error in nail_down Fixes #678 --- src/report.cc | 3 ++- test/regress/889BB167.test | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/regress/889BB167.test diff --git a/src/report.cc b/src/report.cc index 2b07efcb..fb585ce1 100644 --- a/src/report.cc +++ b/src/report.cc @@ -783,7 +783,8 @@ value_t report_t::fn_nail_down(call_scope_t& args) amount_t tmp(arg0.as_amount()); if (tmp.has_commodity() && ! arg1.is_null()) { expr_t value_expr(is_expr(arg1) ? - as_expr(arg1) : expr_t::op_t::wrap_value(arg1 / arg0)); + as_expr(arg1) : + expr_t::op_t::wrap_value(arg1.unrounded() / arg0)); std::ostringstream buf; value_expr.print(buf); value_expr.set_text(buf.str()); diff --git a/test/regress/889BB167.test b/test/regress/889BB167.test new file mode 100644 index 00000000..02e25ab6 --- /dev/null +++ b/test/regress/889BB167.test @@ -0,0 +1,17 @@ +D 1000.00 GBP + +P 2011-01-01 EUR 0.8604 GBP +P 2011-02-01 EUR 0.8576 GBP + +2011-01-31 * AdSense earnings + Assets:Receivable:AdSense 11.00 EUR + Income:AdSense + +2011-02-28 * AdSense earnings + Assets:Receivable:AdSense 10.00 EUR + Income:AdSense + +test reg income:adse -X GBP -H +11-Jan-31 AdSense earnings Income:AdSense -9.46 GBP -9.46 GBP +11-Feb-28 AdSense earnings Income:AdSense -8.58 GBP -18.04 GBP +end test -- cgit v1.2.3