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.
This commit is contained in:
Stephen Morgan 2021-07-09 15:50:28 +10:00 committed by Simon Michael
parent b8f0900edb
commit 3380190d9a
2 changed files with 4 additions and 3 deletions

View File

@ -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)])

View File

@ -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}
],