hledger/hledger-web/Hledger/Web/Handler/JournalR.hs
Stephen Morgan acfbd36fb8 dev: web: Use entriesReport instead of transactionReport.
This produces identical results. The only fields used in the TransactionReport were torig, split, and amt.
- torig is the same as in entriesReport
- since transactionsReport calls accountTransactionsReportItems with
  None as thisacctq, all accounts are considered ‘other accounts’, so
  amt is always zero, and ($if not split && not (mixedAmountLooksZero amt)) never fires.
- So the only thing used is torig, and we can just get that from the
  entriesReport.
2021-07-22 19:00:37 -10:00

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 "Missing the 'view' capability")
let title = case inAccount qopts of
Nothing -> "General Journal"
Just (a, inclsubs) -> "Transactions in " <> a <> if inclsubs then "" else " (excluding subaccounts)"
title' = title <> if m /= Any then ", filtered" 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 "journal - hledger-web"
$(widgetFile "journal")