summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/print.cc12
-rw-r--r--test/regress/1046.test35
2 files changed, 45 insertions, 2 deletions
diff --git a/src/print.cc b/src/print.cc
index c0817950..9be3b511 100644
--- a/src/print.cc
+++ b/src/print.cc
@@ -245,10 +245,18 @@ namespace {
if (post->cost &&
! post->has_flags(POST_CALCULATED | POST_COST_CALCULATED)) {
+ std::string cost_op;
if (post->has_flags(POST_COST_IN_FULL))
- amtbuf << " @@ " << post->cost->abs();
+ cost_op = "@@";
else
- amtbuf << " @ "
+ cost_op = "@";
+ if (post->has_flags(POST_COST_VIRTUAL))
+ cost_op = "(" + cost_op + ")";
+
+ if (post->has_flags(POST_COST_IN_FULL))
+ amtbuf << " " << cost_op << " " << post->cost->abs();
+ else
+ amtbuf << " " << cost_op << " "
<< (*post->cost / post->amount).abs();
}
diff --git a/test/regress/1046.test b/test/regress/1046.test
new file mode 100644
index 00000000..60c27783
--- /dev/null
+++ b/test/regress/1046.test
@@ -0,0 +1,35 @@
+
+2014-05-01 * Test 1
+ A 1.00 GBP (@) 1.23 EUR
+ B -1.23 EUR
+
+2014-05-02 * Test 2
+ A 1.00 GBP (@@) 1.23 EUR
+ B -1.23 EUR
+
+2014-05-03 * Test 3
+ A 1.00 GBP @ 1.23 EUR
+ B -1.23 EUR
+
+2014-05-04 * Test 4
+ A 1.00 GBP @@ 1.23 EUR
+ B -1.23 EUR
+
+test print
+2014/05/01 * Test 1
+ A 1.00 GBP (@) 1.23 EUR
+ B -1.23 EUR
+
+2014/05/02 * Test 2
+ A 1.00 GBP (@@) 1.23 EUR
+ B -1.23 EUR
+
+2014/05/03 * Test 3
+ A 1.00 GBP @ 1.23 EUR
+ B -1.23 EUR
+
+2014/05/04 * Test 4
+ A 1.00 GBP @@ 1.23 EUR
+ B -1.23 EUR
+end test
+