dev: transaction-prices.test -> costs.test, cleanup
This commit is contained in:
parent
cf469c080d
commit
2687b7d7b6
@ -1,10 +1,11 @@
|
|||||||
# price-related tests
|
# Cost-related tests
|
||||||
|
|
||||||
<
|
<
|
||||||
2011/01/01
|
2011/01/01
|
||||||
expenses:foreign currency €100 @ $1.35
|
expenses:foreign currency €100 @ $1.35
|
||||||
assets
|
assets
|
||||||
|
|
||||||
# 1. print a transaction with an explicit unit price
|
# 1. print a transaction with an explicit unit cost
|
||||||
$ hledger -f- print --explicit
|
$ hledger -f- print --explicit
|
||||||
2011-01-01
|
2011-01-01
|
||||||
expenses:foreign currency €100 @ $1.35
|
expenses:foreign currency €100 @ $1.35
|
||||||
@ -12,7 +13,7 @@ $ hledger -f- print --explicit
|
|||||||
|
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
# 2. -B/--cost converts to the price's commodity ("cost")
|
# 2. -B/--cost converts to the cost price's commodity
|
||||||
$ hledger -f- print --explicit --cost
|
$ hledger -f- print --explicit --cost
|
||||||
2011-01-01
|
2011-01-01
|
||||||
expenses:foreign currency $135.00
|
expenses:foreign currency $135.00
|
||||||
@ -47,7 +48,7 @@ $ hledger -f- print --cost --infer-equity
|
|||||||
expenses:foreign currency €100 @@ $135
|
expenses:foreign currency €100 @@ $135
|
||||||
assets
|
assets
|
||||||
|
|
||||||
# 5. print a transaction with a total price
|
# 5. print a transaction with a total cost
|
||||||
$ hledger -f - print --explicit
|
$ hledger -f - print --explicit
|
||||||
2011-01-01
|
2011-01-01
|
||||||
expenses:foreign currency €100 @@ $135
|
expenses:foreign currency €100 @@ $135
|
||||||
@ -55,8 +56,8 @@ $ hledger -f - print --explicit
|
|||||||
|
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
# 6. when the balance has exactly two commodities, both unpriced, infer an
|
# 6. when the balance has exactly two commodities, both without cost,
|
||||||
# implicit conversion price for the first one in terms of the second.
|
# infer an implicit balancing cost (conversion rate) for the first one in terms of the second.
|
||||||
<
|
<
|
||||||
2011/01/01
|
2011/01/01
|
||||||
expenses:foreign currency €100
|
expenses:foreign currency €100
|
||||||
@ -155,9 +156,8 @@ $ hledger -f - balance
|
|||||||
10£
|
10£
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
# 14. When commodity price is specified implicitly, transaction should
|
# 14. The balancing cost should still be inferred properly, with proper sign,
|
||||||
# be considered balanced out even when first amount is negative
|
# if the first amount is negative
|
||||||
# (that is, price for it should be determined properly, with proper sign)
|
|
||||||
<
|
<
|
||||||
2011/01/01 x
|
2011/01/01 x
|
||||||
a -10£
|
a -10£
|
||||||
@ -168,7 +168,7 @@ $ hledger -f - balance -N
|
|||||||
16$ b
|
16$ b
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
# 15. Should not infer prices when --strict is specified
|
# 15. Should not infer balancing costs when --strict is specified
|
||||||
$ hledger -f - balance --strict
|
$ hledger -f - balance --strict
|
||||||
>2 /transaction is unbalanced/
|
>2 /transaction is unbalanced/
|
||||||
>=1
|
>=1
|
||||||
@ -178,8 +178,7 @@ $ hledger -f - balance --strict
|
|||||||
a -10£
|
a -10£
|
||||||
b -16$
|
b -16$
|
||||||
|
|
||||||
# 16. When commodity price is specified implicitly, transaction should
|
# 16. A balancing cost can not be inferred when BOTH amounts are negative
|
||||||
# NOT be considered balanced out when BOTH amounts are negative
|
|
||||||
$ hledger -f - balance
|
$ hledger -f - balance
|
||||||
>2 /transaction is unbalanced/
|
>2 /transaction is unbalanced/
|
||||||
>=1
|
>=1
|
||||||
@ -211,7 +210,7 @@ $ hledger -f - balance --no-total
|
|||||||
$-30 c
|
$-30 c
|
||||||
>= 0
|
>= 0
|
||||||
|
|
||||||
# 19. these balance because of the unit prices, and should parse successfully
|
# 19. these balance because of the unit costs, and should parse successfully
|
||||||
<
|
<
|
||||||
1/1
|
1/1
|
||||||
a 1X @ 2Y
|
a 1X @ 2Y
|
||||||
@ -225,7 +224,7 @@ $ hledger -f - balance --no-total
|
|||||||
$ hledger -f - balance --no-total -B
|
$ hledger -f - balance --no-total -B
|
||||||
>= 0
|
>= 0
|
||||||
|
|
||||||
# 21. likewise with total prices. Note how the primary amount's sign is used.
|
# 21. likewise with total costs. Note how the primary amount's sign is used.
|
||||||
<
|
<
|
||||||
1/1
|
1/1
|
||||||
a 1X @@ 1Y
|
a 1X @@ 1Y
|
||||||
@ -242,53 +241,53 @@ $ hledger -f - balance --no-total -B
|
|||||||
# In fact, here is how sign works with costs currently.
|
# In fact, here is how sign works with costs currently.
|
||||||
# See discussion at https://github.com/simonmichael/hledger/issues/1870
|
# See discussion at https://github.com/simonmichael/hledger/issues/1870
|
||||||
<
|
<
|
||||||
2022-01-01 Positive Unit prices
|
2022-01-01 Positive Unit cost
|
||||||
a A 1
|
a A 1
|
||||||
b B -1 @ A 1
|
b B -1 @ A 1
|
||||||
|
|
||||||
2022-01-01 Positive Total prices
|
2022-01-01 Positive Total cost
|
||||||
a A 1
|
a A 1
|
||||||
b B -1 @@ A 1
|
b B -1 @@ A 1
|
||||||
|
|
||||||
2022-01-02 Negative unit prices
|
2022-01-02 Negative unit cost
|
||||||
a A 1
|
a A 1
|
||||||
b B 1 @ A -1
|
b B 1 @ A -1
|
||||||
|
|
||||||
2022-01-02 Negative total prices
|
2022-01-02 Negative total cost
|
||||||
a A 1
|
a A 1
|
||||||
b B 1 @@ A -1
|
b B 1 @@ A -1
|
||||||
|
|
||||||
2022-01-03 Double Negative unit prices
|
2022-01-03 Double Negative unit cost
|
||||||
a A -1
|
a A -1
|
||||||
b B -1 @ A -1
|
b B -1 @ A -1
|
||||||
|
|
||||||
2022-01-03 Double Negative total prices
|
2022-01-03 Double Negative total cost
|
||||||
a A -1
|
a A -1
|
||||||
b B -1 @@ A -1
|
b B -1 @@ A -1
|
||||||
|
|
||||||
# 23. All these transactions are considered balanced
|
# 23. All these transactions are considered balanced
|
||||||
$ hledger -f- print -x
|
$ hledger -f- print -x
|
||||||
2022-01-01 Positive Unit prices
|
2022-01-01 Positive Unit cost
|
||||||
a A 1
|
a A 1
|
||||||
b B -1 @ A 1
|
b B -1 @ A 1
|
||||||
|
|
||||||
2022-01-01 Positive Total prices
|
2022-01-01 Positive Total cost
|
||||||
a A 1
|
a A 1
|
||||||
b B -1 @@ A 1
|
b B -1 @@ A 1
|
||||||
|
|
||||||
2022-01-02 Negative unit prices
|
2022-01-02 Negative unit cost
|
||||||
a A 1
|
a A 1
|
||||||
b B 1 @ A -1
|
b B 1 @ A -1
|
||||||
|
|
||||||
2022-01-02 Negative total prices
|
2022-01-02 Negative total cost
|
||||||
a A 1
|
a A 1
|
||||||
b B 1 @@ A -1
|
b B 1 @@ A -1
|
||||||
|
|
||||||
2022-01-03 Double Negative unit prices
|
2022-01-03 Double Negative unit cost
|
||||||
a A -1
|
a A -1
|
||||||
b B -1 @ A -1
|
b B -1 @ A -1
|
||||||
|
|
||||||
2022-01-03 Double Negative total prices
|
2022-01-03 Double Negative total cost
|
||||||
a A -1
|
a A -1
|
||||||
b B -1 @@ A -1
|
b B -1 @@ A -1
|
||||||
|
|
||||||
@ -296,27 +295,27 @@ $ hledger -f- print -x
|
|||||||
|
|
||||||
# 24. Here they are converted to cost
|
# 24. Here they are converted to cost
|
||||||
$ hledger -f- print -xB
|
$ hledger -f- print -xB
|
||||||
2022-01-01 Positive Unit prices
|
2022-01-01 Positive Unit cost
|
||||||
a A 1
|
a A 1
|
||||||
b A -1
|
b A -1
|
||||||
|
|
||||||
2022-01-01 Positive Total prices
|
2022-01-01 Positive Total cost
|
||||||
a A 1
|
a A 1
|
||||||
b A -1
|
b A -1
|
||||||
|
|
||||||
2022-01-02 Negative unit prices
|
2022-01-02 Negative unit cost
|
||||||
a A 1
|
a A 1
|
||||||
b A -1
|
b A -1
|
||||||
|
|
||||||
2022-01-02 Negative total prices
|
2022-01-02 Negative total cost
|
||||||
a A 1
|
a A 1
|
||||||
b A -1
|
b A -1
|
||||||
|
|
||||||
2022-01-03 Double Negative unit prices
|
2022-01-03 Double Negative unit cost
|
||||||
a A -1
|
a A -1
|
||||||
b A 1
|
b A 1
|
||||||
|
|
||||||
2022-01-03 Double Negative total prices
|
2022-01-03 Double Negative total cost
|
||||||
a A -1
|
a A -1
|
||||||
b A 1
|
b A 1
|
||||||
|
|
||||||
@ -481,7 +480,7 @@ $ hledger -f- print --show-costs --infer-costs
|
|||||||
>=0
|
>=0
|
||||||
|
|
||||||
# 37. And convert to cost
|
# 37. And convert to cost
|
||||||
$ hledger -f- print --cost --infer-costs --cost
|
$ hledger -f- print --infer-costs --cost
|
||||||
2011-01-01
|
2011-01-01
|
||||||
expenses:food £80
|
expenses:food £80
|
||||||
expenses:foreign currency $135
|
expenses:foreign currency $135
|
||||||
@ -594,9 +593,8 @@ $ hledger -f- print --infer-costs
|
|||||||
|
|
||||||
>=0
|
>=0
|
||||||
|
|
||||||
# # when the *cost-basis* balance has exactly two commodities, both
|
# # when the *cost-basis* balance has exactly two commodities, both cost-less,
|
||||||
# # unpriced, infer an implicit conversion price for the first one in terms
|
# # infer a balancing cost for the first one in terms of the second.
|
||||||
# # of the second.
|
|
||||||
# hledger -f - print
|
# hledger -f - print
|
||||||
# <<<
|
# <<<
|
||||||
# 2011/01/01
|
# 2011/01/01
|
||||||
Loading…
Reference in New Issue
Block a user