From 8c79d6529d748c18d957cd732e1d1e9e07d661fc Mon Sep 17 00:00:00 2001 From: Dmitry Astapov Date: Sat, 22 Sep 2018 22:27:53 +0100 Subject: [PATCH] lib: fix balance --budget in the presence of --value --- hledger-lib/Hledger/Data/Amount.hs | 4 +--- tests/budget/budget.test | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index 7fbeab7b1..28173738c 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -400,9 +400,7 @@ canonicaliseAmount styles a@Amount{acommodity=c, astyle=s} = a{astyle=s'} amountValue :: Journal -> Day -> Amount -> Amount amountValue j d a = case commodityValue j d (acommodity a) of - Just v -> v{aquantity=aquantity v * aquantity a - ,aprice=aprice a - } + Just v -> v{aquantity=aquantity v * aquantity a} Nothing -> a -- This is here not in Commodity.hs to use the Amount Show instance above for debugging. diff --git a/tests/budget/budget.test b/tests/budget/budget.test index ae41993fa..e62c0afec 100644 --- a/tests/budget/budget.test +++ b/tests/budget/budget.test @@ -316,3 +316,31 @@ Budget performance in 2018/01/01: # TODO # 15. respect --sort-amount + +# 16. respect --value +< +P 2018/01/26 SHARE €10 + +2018/05/17 Dividend + revenue:dividend €-10 + assets:pension €10 + +2018/05/17 Buy + assets:pension:shares 1 SHARE @ €10 + assets:pension €-10 + +~ monthly from 2018/06 to 2018/07 + assets:pension €1 + assets:bank + +$ hledger -f - bal -M --budget --cumulative --forecast --value +Budget performance in 2018/05/01-2018/06/30: + + || May Jun +================++==================================================== + || €-10 €-10 + assets:bank || 0 €-1 [ 100% of €-1] + assets:pension || €10 €11 [1100% of €1] +----------------++---------------------------------------------------- + || 0 0 [ 0] +