| 1 |
-- | /journal handlers. |
| 2 |
|
| 3 |
{-# LANGUAGE NamedFieldPuns #-} |
| 4 |
{-# LANGUAGE OverloadedStrings #-} |
| 5 |
{-# LANGUAGE QuasiQuotes #-} |
| 6 |
{-# LANGUAGE TemplateHaskell #-} |
| 7 |
|
| 8 |
module Hledger.Web.Handler.JournalR where |
| 9 |
|
| 10 |
import Hledger |
| 11 |
import Hledger.Cli.CliOptions |
| 12 |
import Hledger.Web.Import |
| 13 |
import Hledger.Web.WebOptions |
| 14 |
import Hledger.Web.Widget.AddForm (addModal) |
| 15 |
import Hledger.Web.Widget.Common |
| 16 |
(accountQuery, mixedAmountAsHtml, |
| 17 |
transactionFragment, replaceInacct) |
| 18 |
|
| 19 |
-- | The formatted journal view, with sidebar. |
| 20 |
getJournalR :: Handler Html |
| 21 |
getJournalR = do |
| 22 |
checkServerSideUiEnabled |
| 23 |
VD{perms, j, q, opts, qparam, qopts, today} <- getViewData |
| 24 |
require ViewPermission |
| 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 q /= Any then ", filtered" else "" |
| 29 |
acctlink a = (RegisterR, [("q", replaceInacct qparam $ accountQuery a)]) |
| 30 |
rspec = (reportspec_ $ cliopts_ opts){_rsQuery = filterQuery (not . queryIsDepth) q} |
| 31 |
items = reverse $ |
| 32 |
styleAmounts (journalCommodityStylesWith HardRounding j) $ |
| 33 |
entriesReport rspec j |
| 34 |
transactionFrag = transactionFragment j |
| 35 |
|
| 36 |
defaultLayout $ do |
| 37 |
setTitle "journal - hledger-web" |
| 38 |
$(widgetFile "journal") |