37 lines
1.3 KiB
Haskell
37 lines
1.3 KiB
Haskell
-- | /journal handlers.
|
|
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
module Hledger.Web.Handler.JournalR where
|
|
|
|
import Hledger
|
|
import Hledger.Cli.CliOptions
|
|
import Hledger.Web.Import
|
|
import Hledger.Web.WebOptions
|
|
import Hledger.Web.Widget.AddForm (addModal)
|
|
import Hledger.Web.Widget.Common
|
|
(accountQuery, mixedAmountAsHtml,
|
|
transactionFragment, replaceInacct)
|
|
|
|
-- | The formatted journal view, with sidebar.
|
|
getJournalR :: Handler Html
|
|
getJournalR = do
|
|
checkServerSideUiEnabled
|
|
VD{caps, j, m, opts, q, qopts, today} <- getViewData
|
|
when (CapView `notElem` caps) (permissionDenied "Ei oikeutta katsella kirjanpitoa ('view')")
|
|
let title = case inAccount qopts of
|
|
Nothing -> "Kaikki kirjaukset"
|
|
Just (a, inclsubs) -> "Tapahtumat tilillä " <> a <> if inclsubs then "" else " (poislukien alatilit)"
|
|
title' = title <> if m /= Any then ", suodatettu" else ""
|
|
acctlink a = (RegisterR, [("q", replaceInacct q $ accountQuery a)])
|
|
rspec = (reportspec_ $ cliopts_ opts){_rsQuery = m}
|
|
items = reverse $ entriesReport rspec j
|
|
transactionFrag = transactionFragment j
|
|
|
|
defaultLayout $ do
|
|
setTitle "päiväkirja - hledger-web"
|
|
$(widgetFile "journal")
|