From 41c1fa636aeef010930164636fd2cc4f1e20b721 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 22 Jan 2012 20:39:11 +0000 Subject: [PATCH] parsing: -B/--cost now ignores P historical prices, like ledger --- hledger-lib/Hledger/Data/Journal.hs | 1 - tests/balancing-with-prices.test | 9 --------- tests/prices.test | 30 +++++++++++++++++++++------- tests/timezone.test | 31 +++++++++++++++-------------- 4 files changed, 39 insertions(+), 32 deletions(-) delete mode 100644 tests/balancing-with-prices.test diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 52053c8ac..35fb3f303 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -266,7 +266,6 @@ journalFinalise :: ClockTime -> LocalTime -> FilePath -> String -> JournalContex journalFinalise tclock tlocal path txt ctx j@Journal{files=fs} = journalBalanceTransactions $ journalCanonicaliseAmounts $ - journalApplyHistoricalPrices $ journalCloseTimeLogEntries tlocal j{files=(path,txt):fs, filereadtime=tclock, jContext=ctx} diff --git a/tests/balancing-with-prices.test b/tests/balancing-with-prices.test deleted file mode 100644 index 9ca6105bd..000000000 --- a/tests/balancing-with-prices.test +++ /dev/null @@ -1,9 +0,0 @@ -# 1. this should balance -bin/hledger -f - print -<<< -2011/1/1 - a 1h @ $10 - b 1h @ $20 - c $-30 ->>>2 !/could not balance/ ->>>= 0 diff --git a/tests/prices.test b/tests/prices.test index df050f494..b33196059 100644 --- a/tests/prices.test +++ b/tests/prices.test @@ -12,7 +12,7 @@ bin/hledger -f- print >>>=0 -# 2. convert to cost +# 2. -B/--cost converts to the price's commodity ("cost") bin/hledger -f- print --cost <<< 2011/01/01 @@ -25,12 +25,10 @@ bin/hledger -f- print --cost >>>=0 -# 3. with a historical price directive +# 3. -B should ignore historical price directives bin/hledger -f- print -B <<< -P 2010/12/31 € $1.34 P 2011/01/01 € $1.35 -P 2011/01/02 € $1.36 2011/01/01 expenses:foreign currency €100 @@ -38,12 +36,12 @@ P 2011/01/02 € $1.36 >>> 2011/01/01 - expenses:foreign currency $135.00 - assets $-135.00 + expenses:foreign currency €100 + assets €-100 >>>=0 -# 4. with a total price +# 4. print a transaction with a total price bin/hledger -f - print <<< 2011/01/01 @@ -184,3 +182,21 @@ bin/hledger -f - balance -------------------- £2 >>>=0 + +# 14. this should balance +bin/hledger -f - balance +<<< +2011/1/1 + a 1h @ $10 + b 1h @ $20 + c $-30 +>>>= 0 + +# 15. this should balance, ignoring the P +bin/hledger -f - balance +<<< +P 2011/11/15 EUR CHF 1.234 +2011/11/19 + a EUR 1000.00 + b CHF -1254 +>>>= 0 diff --git a/tests/timezone.test b/tests/timezone.test index 08eeac662..17fe1d5fd 100644 --- a/tests/timezone.test +++ b/tests/timezone.test @@ -1,21 +1,22 @@ # timezone-related tests # 1. as in ledger, historical prices may contain a time and timezone. # hledger ignores them and uses 00:00 local time instead. -bin/hledger -f - balance --no-total --cost -<<< -P 2011/01/01 00:00:00 A $1 -P 2011/01/01 15:00:00-0100 A $2 +# XXX needs --value not --cost +# bin/hledger -f - balance --no-total --cost +# <<< +# P 2011/01/01 00:00:00 A $1 +# P 2011/01/01 15:00:00-0100 A $2 -2010/12/31 - (20101231) 1 A +# 2010/12/31 +# (20101231) 1 A -2011/1/1 - (20110101) 1 A +# 2011/1/1 +# (20110101) 1 A -2011/1/2 - (20110102) 1 A ->>> - 1 A 20101231 - $2 20110101 - $2 20110102 ->>>=0 +# 2011/1/2 +# (20110102) 1 A +# >>> +# 1 A 20101231 +# $2 20110101 +# $2 20110102 +# >>>=0