mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
raw journal report -> journal entries report
This commit is contained in:
parent
12a37612fb
commit
6496c1ef61
@ -85,7 +85,7 @@ data Loc = Loc {
|
||||
data Screen = BalanceScreen -- ^ like hledger balance, shows accounts
|
||||
| RegisterScreen -- ^ like hledger register, shows transaction-postings
|
||||
| PrintScreen -- ^ like hledger print, shows journal transactions
|
||||
-- | LedgerScreen -- ^ shows the raw journal
|
||||
-- | LedgerScreen -- ^ shows the raw journal entries
|
||||
deriving (Eq,Show)
|
||||
|
||||
-- | Run the vty (curses-style) ui.
|
||||
|
@ -87,14 +87,14 @@ getJournalEditR = do
|
||||
setTitle "hledger-web journal edit form"
|
||||
addHamlet $ editform vd
|
||||
|
||||
-- | The raw journal view, with sidebar.
|
||||
getJournalRawR :: Handler RepHtml
|
||||
getJournalRawR = do
|
||||
-- | The journal entries view, with sidebar.
|
||||
getJournalEntriesR :: Handler RepHtml
|
||||
getJournalEntriesR = do
|
||||
vd@VD{..} <- getViewData
|
||||
let
|
||||
sidecontent = sidebar vd
|
||||
title = "Journal entries" ++ if m /= MatchAny then ", filtered" else "" :: String
|
||||
maincontent = rawJournalReportAsHtml opts vd $ rawJournalReport opts nullfilterspec $ filterJournalTransactions2 m j
|
||||
maincontent = entriesReportAsHtml opts vd $ entriesReport opts nullfilterspec $ filterJournalTransactions2 m j
|
||||
defaultLayout $ do
|
||||
setTitle "hledger-web journal"
|
||||
addHamlet [$hamlet|
|
||||
@ -112,13 +112,13 @@ getJournalRawR = do
|
||||
^{importform}
|
||||
|]
|
||||
|
||||
-- | The raw journal view, no sidebar.
|
||||
-- | The journal entries view, no sidebar.
|
||||
getJournalOnlyR :: Handler RepHtml
|
||||
getJournalOnlyR = do
|
||||
vd@VD{..} <- getViewData
|
||||
defaultLayout $ do
|
||||
setTitle "hledger-web journal only"
|
||||
addHamlet $ rawJournalReportAsHtml opts vd $ rawJournalReport opts nullfilterspec $ filterJournalTransactions2 m j
|
||||
addHamlet $ entriesReportAsHtml opts vd $ entriesReport opts nullfilterspec $ filterJournalTransactions2 m j
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
@ -209,7 +209,7 @@ accountsReportAsHtml _ vd@VD{..} (items',total) =
|
||||
<a href=@{JournalR} title="Show all transactions in journal format">Journal
|
||||
<span.hoverlinks
|
||||
|
||||
<a href=@{JournalRawR} title="Show raw journal entries">raw</a>
|
||||
<a href=@{JournalEntriesR} title="Show journal entries">entries</a>
|
||||
|
||||
<a href=@{JournalEditR} title="Edit the journal">edit
|
||||
|
||||
@ -271,15 +271,15 @@ accountOnlyQuery a = "inacctonly:" ++ quoteIfSpaced a -- (accountNameToAccountRe
|
||||
-- accountUrl :: AppRoute -> AccountName -> (AppRoute,[(String,ByteString)])
|
||||
accountUrl r a = (r, [("q",pack $ accountQuery a)])
|
||||
|
||||
-- | Render a "RawJournalReport" as HTML for the raw journal view.
|
||||
rawJournalReportAsHtml :: [Opt] -> ViewData -> RawJournalReport -> Hamlet AppRoute
|
||||
rawJournalReportAsHtml _ vd items = [$hamlet|
|
||||
-- | Render a "EntriesReport" as HTML for the journal entries view.
|
||||
entriesReportAsHtml :: [Opt] -> ViewData -> EntriesReport -> Hamlet AppRoute
|
||||
entriesReportAsHtml _ vd items = [$hamlet|
|
||||
<table.journalreport>
|
||||
$forall i <- numbered items
|
||||
^{itemAsHtml vd i}
|
||||
|]
|
||||
where
|
||||
itemAsHtml :: ViewData -> (Int, RawJournalReportItem) -> Hamlet AppRoute
|
||||
itemAsHtml :: ViewData -> (Int, EntriesReportItem) -> Hamlet AppRoute
|
||||
itemAsHtml _ (n, t) = [$hamlet|
|
||||
<tr.item.#{evenodd}>
|
||||
<td.transaction>
|
||||
|
@ -1,10 +1,10 @@
|
||||
/static StaticR Static getStatic
|
||||
/favicon.ico FaviconR GET
|
||||
/robots.txt RobotsR GET
|
||||
/ RootR GET
|
||||
/journal JournalR GET POST
|
||||
/journal/raw JournalRawR GET
|
||||
/journal/edit JournalEditR GET
|
||||
/register RegisterR GET
|
||||
/accounts AccountsR GET
|
||||
/api/accounts AccountsJsonR GET
|
||||
/static StaticR Static getStatic
|
||||
/favicon.ico FaviconR GET
|
||||
/robots.txt RobotsR GET
|
||||
/ RootR GET
|
||||
/journal JournalR GET POST
|
||||
/journal/entries JournalEntriesR GET
|
||||
/journal/edit JournalEditR GET
|
||||
/register RegisterR GET
|
||||
/accounts AccountsR GET
|
||||
/api/accounts AccountsJsonR GET
|
||||
|
@ -24,9 +24,9 @@ print' opts args j = do
|
||||
putStr $ showTransactions opts (optsToFilterSpec opts args d) j
|
||||
|
||||
showTransactions :: [Opt] -> FilterSpec -> Journal -> String
|
||||
showTransactions opts fspec j = rawJournalReportAsText opts fspec $ rawJournalReport opts fspec j
|
||||
showTransactions opts fspec j = entriesReportAsText opts fspec $ entriesReport opts fspec j
|
||||
|
||||
rawJournalReportAsText :: [Opt] -> FilterSpec -> RawJournalReport -> String
|
||||
rawJournalReportAsText opts _ items = concatMap (showTransactionForPrint effective) items
|
||||
entriesReportAsText :: [Opt] -> FilterSpec -> EntriesReport -> String
|
||||
entriesReportAsText opts _ items = concatMap (showTransactionForPrint effective) items
|
||||
where effective = Effective `elem` opts
|
||||
|
||||
|
@ -9,10 +9,10 @@ on the command-line options, should move to hledger-lib later.
|
||||
-}
|
||||
|
||||
module Hledger.Cli.Reports (
|
||||
-- * Raw journal report
|
||||
RawJournalReport,
|
||||
RawJournalReportItem,
|
||||
rawJournalReport,
|
||||
-- * Entries report
|
||||
EntriesReport,
|
||||
EntriesReportItem,
|
||||
entriesReport,
|
||||
-- * Postings report
|
||||
PostingsReport,
|
||||
PostingsReportItem,
|
||||
@ -53,15 +53,15 @@ import Hledger.Cli.Utils
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
-- | A raw journal report is a list of whole transactions used to generate
|
||||
-- a raw journal view. Used by eg hledger's print command and
|
||||
-- hledger-web's raw journal view.
|
||||
type RawJournalReport = [RawJournalReportItem]
|
||||
type RawJournalReportItem = Transaction
|
||||
-- | A journal entries report is a list of whole transactions as
|
||||
-- originally entered in the journal (mostly). Used by eg hledger's print
|
||||
-- command and hledger-web's journal entries view.
|
||||
type EntriesReport = [EntriesReportItem]
|
||||
type EntriesReportItem = Transaction
|
||||
|
||||
-- | Select transactions for a raw journal report.
|
||||
rawJournalReport :: [Opt] -> FilterSpec -> Journal -> RawJournalReport
|
||||
rawJournalReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j'
|
||||
-- | Select transactions for an entries report.
|
||||
entriesReport :: [Opt] -> FilterSpec -> Journal -> EntriesReport
|
||||
entriesReport opts fspec j = sortBy (comparing tdate) $ jtxns $ filterJournalTransactions fspec j'
|
||||
where
|
||||
j' = journalSelectingDateFromOpts opts $ journalSelectingAmountFromOpts opts j
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user