lib: better message when roi fails to value commodity, fixes #1446
This commit is contained in:
parent
1023a3cc1a
commit
9869624c5c
@ -263,6 +263,6 @@ total trans query = unMix $ sumPostings $ filter (matchesPosting query) $ conca
|
|||||||
|
|
||||||
unMix :: MixedAmount -> Quantity
|
unMix :: MixedAmount -> Quantity
|
||||||
unMix a =
|
unMix a =
|
||||||
case (normaliseMixedAmount $ mixedAmountCost a) of
|
case (unifyMixedAmount $ mixedAmountCost a) of
|
||||||
(Mixed [a]) -> aquantity a
|
Just a -> aquantity a
|
||||||
_ -> error' "MixedAmount failed to normalize" -- PARTIAL:
|
Nothing -> error' $ "Amounts could not be converted to a single cost basis: " ++ show (map showAmount $ amounts a)
|
||||||
|
|||||||
@ -225,3 +225,18 @@ hledger -f- roi -p 2019-11
|
|||||||
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
|
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
|
# 9. Fail with a nice error message when commodity can't be valued
|
||||||
|
hledger -f- roi -p 2019-11 --inv Investment --pnl PnL
|
||||||
|
<<<
|
||||||
|
2019/11/01 Example
|
||||||
|
Assets:Checking -1 A
|
||||||
|
Investment 10 B
|
||||||
|
|
||||||
|
2019/11/02 Example
|
||||||
|
Investment -10 B @@ 1 A
|
||||||
|
Assets:Checking 12 A
|
||||||
|
Unrealized PnL
|
||||||
|
>>>2
|
||||||
|
hledger: Amounts could not be converted to a single cost basis: ["10 B","-10 B @@ 1 A"]
|
||||||
|
>>>=1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user