From 078c8380072ec7bc07d1e50afb34da041f446781 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 19 Mar 2012 22:14:20 -0500 Subject: Added regression test for A560FDAD --- test/regress/A560FDAD.test | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/regress/A560FDAD.test (limited to 'test/regress/A560FDAD.test') diff --git a/test/regress/A560FDAD.test b/test/regress/A560FDAD.test new file mode 100644 index 00000000..053f5aaf --- /dev/null +++ b/test/regress/A560FDAD.test @@ -0,0 +1,36 @@ +2012-01-01 * Opening balance + Assets:Current 17.43 EUR + Assets:Investments 200 "LU02" @ 24.77 EUR + Assets:Investments 58 "LU02" @ 24.79900855 EUR + Equity:Opening balance + +2012-01-01 * Opening balance + Assets:Pension 785.44 GBP + Assets:Pension 97.0017 "H2" @ 5.342999720204 GBP + Assets:Pension 4.3441 "H1" @ 5.289999915108 GBP + Equity:Opening balance + +2012-01-01 * Opening balance: misc + Assets:Piggy bank 3.51 GBP + Equity:Opening balance + +2012-01-01 * Opening balance + Assets:Rewards 9836 AAdvantage + Equity:Opening balance + +2012-01-03 * Receivable + Assets:Current + Assets:Receivable -161.06 EUR + Assets:Receivable -9.99 GBP @@ 11.65 EUR + +2012-01-27 * Test + Income:Test -2759.50 GBP + Income:Test -110.76 GBP + Assets:Foo 345.57 GBP + Expenses:Test 16.47 GBP + Expenses:Test 6.33 GBP + Expenses:Test 261.39 GBP + Assets:Current + +test reg -X EUR -H +end test -- cgit v1.2.3 From f76d458ab7f200bd52676fe8103fbfaae4f10488 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 20 Mar 2012 03:15:42 -0500 Subject: Strip annotations in display_filter_posts Fixes #718 --- src/filters.cc | 6 ++++-- test/regress/A560FDAD.test | 50 ++++++++++++++++++++++++++++++++++++++++++++++ test/regress/BFD3FBE1.test | 3 +-- 3 files changed, 55 insertions(+), 4 deletions(-) (limited to 'test/regress/A560FDAD.test') diff --git a/src/filters.cc b/src/filters.cc index 73ee200d..b5f68907 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -522,7 +522,8 @@ bool display_filter_posts::output_rounding(post_t& post) value_t new_display_total; if (show_rounding) { - new_display_total = display_total_expr.calc(bound_scope); + new_display_total = (display_total_expr.calc(bound_scope) + .strip_annotations(report.what_to_keep())); DEBUG("filters.changed_value.rounding", "rounding.new_display_total = " << new_display_total); @@ -539,7 +540,8 @@ bool display_filter_posts::output_rounding(post_t& post) return true; } - if (value_t repriced_amount = display_amount_expr.calc(bound_scope)) { + if (value_t repriced_amount = (display_amount_expr.calc(bound_scope) + .strip_annotations(report.what_to_keep()))) { if (! last_display_total.is_null()) { DEBUG("filters.changed_value.rounding", "rounding.repriced_amount = " << repriced_amount); diff --git a/test/regress/A560FDAD.test b/test/regress/A560FDAD.test index 053f5aaf..b30ea086 100644 --- a/test/regress/A560FDAD.test +++ b/test/regress/A560FDAD.test @@ -33,4 +33,54 @@ Assets:Current test reg -X EUR -H +12-Jan-01 Opening balance Assets:Current 17.43 EUR 17.43 EUR + Assets:Investments 4959.80 EUR 4977.23 EUR + Assets:Investments 1438.34 EUR 6415.57 EUR + Equity:Opening balance -6409.77 EUR 5.80 EUR +12-Jan-01 Opening balance Assets:Pension 785.44 GBP 5.80 EUR + 785.44 GBP + Assets:Pension 97.0017 H2 5.80 EUR + 785.44 GBP + 97.0017 H2 + Assets:Pension 4.3441 H1 5.80 EUR + 785.44 GBP + 4.3441 H1 + 97.0017 H2 + Equity:Opening balance -1326.70 GBP 5.80 EUR + -541.26 GBP + 4.3441 H1 + 97.0017 H2 +12-Jan-01 Opening balance: misc Assets:Piggy bank 3.51 GBP 5.80 EUR + -537.75 GBP + 4.3441 H1 + 97.0017 H2 + Equity:Opening balance -3.51 GBP 5.80 EUR + -541.26 GBP + 4.3441 H1 + 97.0017 H2 +12-Jan-01 Opening balance Assets:Rewards 9836 AAdvantage 9836 AAdvantage + 5.80 EUR + -541.26 GBP + 4.3441 H1 + 97.0017 H2 + Equity:Opening balance -9836 AAdvantage 5.80 EUR + -541.26 GBP + 4.3441 H1 + 97.0017 H2 +12-Jan-03 Commodities revalued 0 5.80 EUR +12-Jan-03 Receivable Assets:Current 172.71 EUR 178.51 EUR + Assets:Receivable -161.06 EUR 17.45 EUR + Assets:Receivable -11.65 EUR 5.80 EUR +12-Jan-27 Test 0.01 EUR 5.81 EUR + Income:Test -3218.04 EUR -3212.23 EUR + -0.01 EUR -3212.24 EUR + Income:Test -129.16 EUR -3341.40 EUR + Assets:Foo 402.99 EUR -2938.41 EUR + Expenses:Test 19.21 EUR -2919.20 EUR + Expenses:Test 7.38 EUR -2911.82 EUR + 0.01 EUR -2911.81 EUR + Expenses:Test 304.82 EUR -2606.99 EUR + -0.01 EUR -2607.00 EUR + Assets:Current 2612.80 EUR 5.80 EUR + 0.01 EUR 5.82 EUR end test diff --git a/test/regress/BFD3FBE1.test b/test/regress/BFD3FBE1.test index 5b2f8b42..0dbda2c7 100644 --- a/test/regress/BFD3FBE1.test +++ b/test/regress/BFD3FBE1.test @@ -11,7 +11,6 @@ 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.. -0.01 EUR -0.01 EUR - Assets:A 1.80 EUR 1.80 EUR +11-Feb-10 Reimbursement: Taxi.. Assets:A 1.80 EUR 1.80 EUR Assets:B -1.80 EUR 0 end test -- cgit v1.2.3 From e3248ee5a6b2c29e1c35eb0315fd66370a117784 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 20 Mar 2012 04:56:03 -0500 Subject: Fix problems with postings --- src/annotate.cc | 3 ++- src/commodity.cc | 2 ++ src/filters.cc | 9 ++++++--- src/temps.cc | 8 ++++++-- src/temps.h | 3 ++- test/regress/A560FDAD.test | 1 - 6 files changed, 18 insertions(+), 8 deletions(-) (limited to 'test/regress/A560FDAD.test') diff --git a/src/annotate.cc b/src/annotate.cc index 25f0e582..98635ad7 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -328,7 +328,8 @@ annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep) if ((keep_price && details.price) || (keep_date && details.date) || (keep_tag && details.tag) || - details.value_expr) + (details.value_expr && + ! details.has_flags(ANNOTATION_VALUE_EXPR_CALCULATED))) { new_comm = pool().find_or_create (referent(), annotation_t(keep_price ? details.price : none, diff --git a/src/commodity.cc b/src/commodity.cc index 5335d8a8..51b8f29c 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -221,6 +221,8 @@ commodity_t& commodity_t::nail_down(const expr_t& expr) { annotation_t new_details; new_details.value_expr = expr; + new_details.add_flags(ANNOTATION_VALUE_EXPR_CALCULATED); + commodity_t * new_comm = commodity_pool_t::current_pool->find_or_create(symbol(), new_details); return *new_comm; diff --git a/src/filters.cc b/src/filters.cc index 02dc392b..58e5fcaf 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -340,9 +340,10 @@ namespace { const bool act_date_p = true, const value_t& total = value_t(), const bool direct_amount = false, - const bool mark_visited = false) + const bool mark_visited = false, + const bool bidir_link = true) { - post_t& post = temps.create_post(*xact, account); + post_t& post = temps.create_post(*xact, account, bidir_link); post.add_flags(ITEM_GENERATED); // If the account for this post is all virtual, then report the post as @@ -566,7 +567,9 @@ bool display_filter_posts::output_rounding(post_t& post) /* date= */ date_t(), /* act_date_p= */ true, /* total= */ precise_display_total, - /* direct_amount= */ true); + /* direct_amount= */ true, + /* mark_visited= */ false, + /* bidir_link= */ false); } } if (show_rounding) diff --git a/src/temps.cc b/src/temps.cc index cb471d41..881077f6 100644 --- a/src/temps.cc +++ b/src/temps.cc @@ -81,7 +81,8 @@ post_t& temporaries_t::copy_post(post_t& origin, xact_t& xact, return temp; } -post_t& temporaries_t::create_post(xact_t& xact, account_t * account) +post_t& temporaries_t::create_post(xact_t& xact, account_t * account, + bool bidir_link) { if (! post_temps) post_temps = std::list(); @@ -93,7 +94,10 @@ post_t& temporaries_t::create_post(xact_t& xact, account_t * account) temp.account = account; temp.account->add_post(&temp); - xact.add_post(&temp); + if (bidir_link) + xact.add_post(&temp); + else + temp.xact = &xact; return temp; } diff --git a/src/temps.h b/src/temps.h index f41c487c..daa1493b 100644 --- a/src/temps.h +++ b/src/temps.h @@ -66,7 +66,8 @@ public: } post_t& copy_post(post_t& origin, xact_t& xact, account_t * account = NULL); - post_t& create_post(xact_t& xact, account_t * account); + post_t& create_post(xact_t& xact, account_t * account, + bool bidir_link = true); post_t& last_post() { return post_temps->back(); } diff --git a/test/regress/A560FDAD.test b/test/regress/A560FDAD.test index b30ea086..ee19e71e 100644 --- a/test/regress/A560FDAD.test +++ b/test/regress/A560FDAD.test @@ -82,5 +82,4 @@ test reg -X EUR -H Expenses:Test 304.82 EUR -2606.99 EUR -0.01 EUR -2607.00 EUR Assets:Current 2612.80 EUR 5.80 EUR - 0.01 EUR 5.82 EUR end test -- cgit v1.2.3