Skip to content

Commit

Permalink
web: RegisterR.getRegisterR.addCommas: do not drop last account
Browse files Browse the repository at this point in the history
Bug was introduced in commit 2a99b3d
in an effort to get rid of partial List.tail,
because GHC-9.8 started to warn about it.

Problem is that the rewritten code with tailDef always removes the last account,
whereas the original intention was to replace all accounts by a comma except the last one.
addCommas should prepare a comma separated list like List.intercalate.
  • Loading branch information
thielema committed Sep 23, 2024
1 parent e77f733 commit 1570680
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hledger-web/Hledger/Web/Handler/RegisterR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

module Hledger.Web.Handler.RegisterR where

import qualified Data.List.NonEmpty as NonEmpty
import Data.List (intersperse, nub, partition)
import qualified Data.Text as T
import Safe (tailDef)
import Text.Hamlet (hamletFile)

import Hledger
Expand Down Expand Up @@ -42,10 +42,11 @@ getRegisterR = do
map (\(acct,(name,comma)) -> (acct, (T.pack name, T.pack comma))) .
undecorateLinks . elideRightDecorated 40 . decorateLinks .
addCommas . preferReal . otherTransactionAccounts q acctQuery
snoc xs x = NonEmpty.prependList xs $ NonEmpty.singleton x
addCommas xs =
zip xs $
zip (map (T.unpack . accountSummarisedName . paccount) xs) $
tailDef [""] $ (", "<$xs)
NonEmpty.tail $ snoc (", "<$xs) ""
items =
styleAmounts (journalCommodityStylesWith HardRounding j) $
accountTransactionsReport rspec{_rsQuery=q} j acctQuery
Expand Down

0 comments on commit 1570680

Please sign in to comment.