1-- | /journal handlers. 2 3{-# LANGUAGE NamedFieldPuns #-} 4{-# LANGUAGE OverloadedStrings #-} 5{-# LANGUAGE QuasiQuotes #-} 6{-# LANGUAGE TemplateHaskell #-} 7 8module Hledger.Web.Handler.JournalR where 9 10import Hledger 11import Hledger.Cli.CliOptions 12import Hledger.Web.Import 13import Hledger.Web.WebOptions 14import Hledger.Web.Widget.AddForm (addModal) 15import Hledger.Web.Widget.Common 16 (accountQuery, mixedAmountAsHtml, 17 transactionFragment, replaceInacct) 18 19-- | The formatted journal view, with sidebar. 20getJournalR :: Handler Html 21getJournalR = do 22 checkServerSideUiEnabled 23 VD{caps, j, m, opts, q, qopts, today} <- getViewData 24 when (CapView `notElem` caps) (permissionDenied "Missing the 'view' capability") 25 let title = case inAccount qopts of 26 Nothing -> "General Journal" 27 Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)" 28 title' = title <> if m /= Any then ", filtered" else "" 29 acctlink a = (RegisterR, [("q", replaceInacct q $ accountQuery a)]) 30 (_, items) = transactionsReport (reportopts_ $ cliopts_ opts) j m 31 transactionFrag = transactionFragment j 32 33 defaultLayout $ do 34 setTitle "journal - hledger-web" 35 $(widgetFile "journal") 36