From 0a7a6c87f8bb23c67a1b9e063ec8f4e41c4f8138 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 22 Nov 2015 08:37:02 -0800 Subject: [PATCH] clean up price tests --- tests/journal/market-prices.test | 42 ++++++++--- .../transaction-prices.test} | 71 +++++-------------- 2 files changed, 52 insertions(+), 61 deletions(-) rename tests/{misc/prices.test => journal/transaction-prices.test} (75%) diff --git a/tests/journal/market-prices.test b/tests/journal/market-prices.test index dc8b09f7e..9f2a285f3 100644 --- a/tests/journal/market-prices.test +++ b/tests/journal/market-prices.test @@ -1,22 +1,48 @@ -# market prices defined with the P directive are used by -V/--value. +# . Market prices are ignored by -B/--cost. +hledger -f- print -B +<<< +P 2011/01/01 € $1.35 -# 1. market prices (a) are affected by D directives and (b) contribute -# to amount style canonicalisation. +2011/01/01 + expenses:foreign currency €100 + assets + +>>> +2011/01/01 + expenses:foreign currency €100 + assets €-100 + +>>>=0 + +# # 14b. market price used in balancing - this should balance +# hledger -f - balance +# <<< +# P 2011/11/15 EUR CHF 1.234 +# 2011/11/19 +# a EUR 1000.00 +# b USD 1000.00 +# c CHF -1254 +# >>>= 0 + +# . Market prices are used by -V/--value. +# They are affected by D directives, currently. +# They contribute to amount style canonicalisation. # (https://github.com/simonmichael/hledger/issues/131#issuecomment-133545140) hledger -f- balance -V <<< -D 1000.00 H -P 2015/08/14 EEEE 41.66 -P 2015/08/14 FFFF 74.62 +D 1000.00 H ; declare a default commodity named H + +P 2015/08/14 EEEE 41.66 ; default commodity H is used for these market prices +P 2015/08/14 FFFF 74.62 P 2015/08/14 GGGG 32.39 2015/08/15 - a 2.4120 EEEE @@ 100 + a 2.4120 EEEE @@ 100 ; default commodity H is used for these transaction prices a 0.3350 FFFF @@ 25 a 0.7718 GGGG @@ 25 - b + b ; implicit balancing amount is in the cost commodity, H >>> 150.48 H a -150.00 H b diff --git a/tests/misc/prices.test b/tests/journal/transaction-prices.test similarity index 75% rename from tests/misc/prices.test rename to tests/journal/transaction-prices.test index aa62dca54..e5681d21e 100644 --- a/tests/misc/prices.test +++ b/tests/journal/transaction-prices.test @@ -25,23 +25,7 @@ hledger -f- print --cost >>>=0 -# 3. -B should ignore historical price directives -hledger -f- print -B -<<< -P 2011/01/01 € $1.35 - -2011/01/01 - expenses:foreign currency €100 - assets - ->>> -2011/01/01 - expenses:foreign currency €100 - assets €-100 - ->>>=0 - -# 4. print a transaction with a total price +# 3. print a transaction with a total price hledger -f - print <<< 2011/01/01 @@ -54,7 +38,7 @@ hledger -f - print >>>=0 -# 5. when the balance has exactly two commodities, both unpriced, infer an +# 4. when the balance has exactly two commodities, both unpriced, infer an # implicit conversion price for the first one in terms of the second. hledger -f - print <<< @@ -76,7 +60,7 @@ hledger -f - print >>>=0 -## 6. another, from ledger tests. Just one posting to price so uses @@. +## 5. another, from ledger tests. Just one posting to price so uses @@. hledger -f - print <<< 2002/09/30 * 1a1a6305d06ce4b284dba0d267c23f69d70c20be @@ -89,7 +73,7 @@ hledger -f - print >>>=0 -# 7. when the balance has more than two commodities, don't bother +# 6. when the balance has more than two commodities, don't bother hledger -f - print <<< 2011/01/01 @@ -98,7 +82,7 @@ hledger -f - print expenses:other £200 >>>= !0 -# 8. another +# 7. another hledger -f - balance -B <<< 2011/01/01 @@ -113,7 +97,7 @@ hledger -f - balance -B 0 >>>=0 -# 9. transaction in two commodities should balance out properly +# 8. transaction in two commodities should balance out properly hledger -f - balance --cost <<< 2011/01/01 x @@ -126,9 +110,9 @@ hledger -f - balance --cost 0 >>>=0 -# 10. When commodity price is specified implicitly, transaction should -# be considered balanced out even when first amount is negative -# (that is, price for it should be determined properly, with proper sign) +# 9. When commodity price is specified implicitly, transaction should +# be considered balanced out even when first amount is negative +# (that is, price for it should be determined properly, with proper sign) hledger -f - balance <<< 2011/01/01 x @@ -142,7 +126,7 @@ hledger -f - balance -10£ >>>=0 -# 11. When commodity price is specified implicitly, transaction should +# 10. When commodity price is specified implicitly, transaction should # NOT be considered balanced out when BOTH amounts are negative hledger -f - balance <<< @@ -152,7 +136,7 @@ hledger -f - balance >>> >>>=1 -# 12. Differently-priced lots of a commodity should be merged in balance report +# 11. Differently-priced lots of a commodity should be merged in balance report hledger -f - balance <<< 2011/1/1 @@ -166,7 +150,7 @@ hledger -f - balance £2 >>>=0 -# 13. this should balance +# 12. this should balance hledger -f - balance <<< 2011/1/1 @@ -175,26 +159,7 @@ hledger -f - balance c $-30 >>>= 0 -# 14. we ignore P, so this should balance -hledger -f - balance -<<< -P 2011/11/15 EUR CHF 1 -2011/11/19 - a EUR 1000.00 - b CHF -1254 ->>>= 0 - -# # 14b. if P worked, this should balance -# hledger -f - balance -# <<< -# P 2011/11/15 EUR CHF 1.234 -# 2011/11/19 -# a EUR 1000.00 -# b USD 1000.00 -# c CHF -1254 -# >>>= 0 - -# 15. these balance because of the unit prices, and should parse successfully +# 13. these balance because of the unit prices, and should parse successfully hledger -f - balance --no-total <<< 1/1 @@ -204,7 +169,7 @@ hledger -f - balance --no-total -1X a >>>= 0 -# 16. +# 14. hledger -f - balance --no-total -B <<< 1/1 @@ -213,7 +178,7 @@ hledger -f - balance --no-total -B >>> >>>= 0 -# 17. likewise with total prices. Note how the primary amount's sign is used. +# 15. likewise with total prices. Note how the primary amount's sign is used. hledger -f - balance --no-total <<< 1/1 @@ -223,7 +188,7 @@ hledger -f - balance --no-total -1X a >>>= 0 -# 18. +# 16. hledger -f - balance --no-total -B <<< 1/1 @@ -232,7 +197,7 @@ hledger -f - balance --no-total -B >>> >>>= 0 -# 19. here, a's primary amount is 0, and its cost is 1Y; b is the assigned auto-balancing amount of -1Y (per issue 69) +# 17. here, a's primary amount is 0, and its cost is 1Y; b is the assigned auto-balancing amount of -1Y (per issue 69) hledger -f - balance --no-total -E <<< 1/1 @@ -245,7 +210,7 @@ hledger -f - balance --no-total -E -1Y b >>>= 0 -# 20. the above with -B +# 18. the above with -B hledger -f - balance --no-total -E -B <<< 1/1