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