From 3380190d9a97da1c668796c1419efb1655b65f7d Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Fri, 9 Jul 2021 15:50:28 +1000 Subject: [PATCH] fix: web: register chart with multiple commodities/prices, broken in 1.22 (#1597) Make sure to strip prices from amounts before generating JSON data for the register chart. --- hledger-web/Hledger/Web/Handler/RegisterR.hs | 3 ++- hledger-web/templates/chart.hamlet | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hledger-web/Hledger/Web/Handler/RegisterR.hs b/hledger-web/Hledger/Web/Handler/RegisterR.hs index 192ed96cb..d5d5711ec 100644 --- a/hledger-web/Hledger/Web/Handler/RegisterR.hs +++ b/hledger-web/Hledger/Web/Handler/RegisterR.hs @@ -107,7 +107,8 @@ registerChartHtml q title percommoditytxnreports = $(hamletFile "templates/chart charttitle = if null title then "" else title ++ ":" colorForCommodity = fromMaybe 0 . flip lookup commoditiesIndex commoditiesIndex = zip (map fst percommoditytxnreports) [0..] :: [(CommoditySymbol,Int)] - simpleMixedAmountQuantity = maybe 0 aquantity . listToMaybe . amounts + simpleMixedAmountQuantity = maybe 0 aquantity . listToMaybe . amounts . mixedAmountStripPrices + showZeroCommodity = wbUnpack . showMixedAmountB oneLine{displayPrice=False,displayZeroCommodity=True} shownull c = if null c then " " else c nodatelink = (RegisterR, [("q", T.unwords $ removeDates q)]) diff --git a/hledger-web/templates/chart.hamlet b/hledger-web/templates/chart.hamlet index 02e7ab273..78a77db3e 100644 --- a/hledger-web/templates/chart.hamlet +++ b/hledger-web/templates/chart.hamlet @@ -36,8 +36,8 @@ [ #{dayToJsTimestamp $ triDate i}, #{simpleMixedAmountQuantity $ triCommodityBalance c i}, - '#{showMixedAmountWithZeroCommodity $ triCommodityAmount c i}', - '#{showMixedAmountWithZeroCommodity $ triCommodityBalance c i}', + '#{showZeroCommodity $ triCommodityAmount c i}', + '#{showZeroCommodity $ triCommodityBalance c i}', '#{concat $ intersperse "\\n" $ lines $ T.unpack $ showTransaction $ triOrigTransaction i}', #{tindex $ triOrigTransaction i} ],