mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-27 04:13:11 +03:00
a simplistic cashflow statement to complete the trio
This commit is contained in:
parent
483eb09a82
commit
d30cd5847a
10
MANUAL.md
10
MANUAL.md
@ -764,6 +764,16 @@ This is intended to display a standard-looking
|
||||
[balance sheet](http://en.wikipedia.org/wiki/Balance_sheet). Currently
|
||||
it is similar to doing `hledger balance '^(assets?|liabilit(y|ies)|equity)(:|$)'`.
|
||||
|
||||
#### cashflow
|
||||
|
||||
This command displays a simplified
|
||||
[cashflow statement](http://en.wikipedia.org/wiki/Cash_flow_statement),
|
||||
showing the change in all "cash" accounts for the period (without the
|
||||
traditional segmentation into operating, investing, and financing cash
|
||||
flows.) It currently assumes that cash accounts are under a top-level
|
||||
account named `asset` and do not contain `receivable` or `A/R` (plural
|
||||
forms also allowed.)
|
||||
|
||||
#### stats
|
||||
|
||||
The stats command displays summary information for the whole journal, or
|
||||
|
@ -41,6 +41,7 @@ module Hledger.Data.Journal (
|
||||
journalAssetAccountQuery,
|
||||
journalLiabilityAccountQuery,
|
||||
journalEquityAccountQuery,
|
||||
journalCashAccountQuery,
|
||||
-- * Misc
|
||||
groupPostings,
|
||||
matchpats,
|
||||
@ -193,6 +194,13 @@ journalLiabilityAccountQuery _ = Acct "^liabilit(y|ies)(:|$)"
|
||||
journalEquityAccountQuery :: Journal -> Query
|
||||
journalEquityAccountQuery _ = Acct "^equity(:|$)"
|
||||
|
||||
-- | A query for Cash (-equivalent) accounts in this journal (ie,
|
||||
-- accounts which appear on the cashflow statement.) This is currently
|
||||
-- hard-coded to be all the Asset accounts except for those containing the
|
||||
-- case-insensitive regex @(receivable|A/R)@.
|
||||
journalCashAccountQuery :: Journal -> Query
|
||||
journalCashAccountQuery j = And [journalAssetAccountQuery j, Not $ Acct "(receivable|A/R)"]
|
||||
|
||||
-- Various kinds of filtering on journals. We do it differently depending
|
||||
-- on the command.
|
||||
|
||||
|
@ -11,6 +11,7 @@ module Hledger.Cli (
|
||||
module Hledger.Cli.Add,
|
||||
module Hledger.Cli.Balance,
|
||||
module Hledger.Cli.Balancesheet,
|
||||
module Hledger.Cli.Cashflow,
|
||||
module Hledger.Cli.Histogram,
|
||||
module Hledger.Cli.Incomestatement,
|
||||
module Hledger.Cli.Print,
|
||||
@ -31,6 +32,7 @@ import Hledger
|
||||
import Hledger.Cli.Add
|
||||
import Hledger.Cli.Balance
|
||||
import Hledger.Cli.Balancesheet
|
||||
import Hledger.Cli.Cashflow
|
||||
import Hledger.Cli.Histogram
|
||||
import Hledger.Cli.Incomestatement
|
||||
import Hledger.Cli.Print
|
||||
@ -48,6 +50,7 @@ tests_Hledger_Cli = TestList
|
||||
-- ,tests_Hledger_Cli_Add
|
||||
-- ,tests_Hledger_Cli_Balance
|
||||
,tests_Hledger_Cli_Balancesheet
|
||||
,tests_Hledger_Cli_Cashflow
|
||||
-- ,tests_Hledger_Cli_Histogram
|
||||
,tests_Hledger_Cli_Incomestatement
|
||||
,tests_Hledger_Cli_Options
|
||||
|
@ -1,7 +1,7 @@
|
||||
{-# LANGUAGE QuasiQuotes, RecordWildCards #-}
|
||||
{-|
|
||||
|
||||
The @balancesheet@ command prints a fairly standard balance sheet.
|
||||
The @balancesheet@ command prints a simple balance sheet.
|
||||
|
||||
-}
|
||||
|
||||
@ -21,7 +21,7 @@ import Hledger.Cli.Options
|
||||
import Hledger.Cli.Balance
|
||||
|
||||
|
||||
-- | Print a standard balancesheet.
|
||||
-- | Print a simple balance sheet.
|
||||
balancesheet :: CliOpts -> Journal -> IO ()
|
||||
balancesheet CliOpts{reportopts_=ropts} j = do
|
||||
-- let lines = case formatFromOpts ropts of Left err, Right ...
|
||||
|
@ -1,7 +1,7 @@
|
||||
{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-}
|
||||
{-|
|
||||
|
||||
The @incomestatement@ command prints a fairly standard income statement (profit & loss) report.
|
||||
The @incomestatement@ command prints a simple income statement (profit & loss) report.
|
||||
|
||||
-}
|
||||
|
||||
@ -18,7 +18,7 @@ import Hledger
|
||||
import Hledger.Cli.Options
|
||||
import Hledger.Cli.Balance
|
||||
|
||||
-- | Print a standard income statement.
|
||||
-- | Print a simple income statement.
|
||||
incomestatement :: CliOpts -> Journal -> IO ()
|
||||
incomestatement CliOpts{reportopts_=ropts} j = do
|
||||
d <- getCurrentDay
|
||||
|
@ -50,6 +50,7 @@ import Hledger (ensureJournalFileExists)
|
||||
import Hledger.Cli.Add
|
||||
import Hledger.Cli.Balance
|
||||
import Hledger.Cli.Balancesheet
|
||||
import Hledger.Cli.Cashflow
|
||||
import Hledger.Cli.Histogram
|
||||
import Hledger.Cli.Incomestatement
|
||||
import Hledger.Cli.Print
|
||||
@ -88,8 +89,9 @@ main = do
|
||||
| any (cmd `isPrefixOf`) ["entries","print"] = showModeHelpOr entriesmode $ withJournalDo opts print'
|
||||
| any (cmd `isPrefixOf`) ["postings","register"] = showModeHelpOr postingsmode $ withJournalDo opts register
|
||||
| any (cmd `isPrefixOf`) ["activity","histogram"] = showModeHelpOr activitymode $ withJournalDo opts histogram
|
||||
| cmd `isPrefixOf` "incomestatement" = showModeHelpOr incomestatementmode $ withJournalDo opts incomestatement
|
||||
| any (cmd `isPrefixOf`) ["incomestatement","is"] = showModeHelpOr incomestatementmode $ withJournalDo opts incomestatement
|
||||
| any (cmd `isPrefixOf`) ["balancesheet","bs"] = showModeHelpOr balancesheetmode $ withJournalDo opts balancesheet
|
||||
| any (cmd `isPrefixOf`) ["cashflow","cf"] = showModeHelpOr cashflowmode $ withJournalDo opts cashflow
|
||||
| cmd `isPrefixOf` "stats" = showModeHelpOr statsmode $ withJournalDo opts stats
|
||||
| not (null matchedaddon) = do
|
||||
when (debug_ opts) $ printf "running %s\n" shellcmd
|
||||
|
@ -74,6 +74,7 @@ mainmode addons = defmode {
|
||||
,activitymode
|
||||
,incomestatementmode
|
||||
,balancesheetmode
|
||||
,cashflowmode
|
||||
,statsmode
|
||||
])
|
||||
]
|
||||
@ -237,7 +238,7 @@ activitymode = (commandmode ["activity","histogram"]) {
|
||||
}
|
||||
}
|
||||
|
||||
incomestatementmode = (commandmode ["incomestatement"]) {
|
||||
incomestatementmode = (commandmode ["incomestatement","is"]) {
|
||||
modeHelp = "show a standard income statement"
|
||||
,modeArgs = ([], Just commandargsflag)
|
||||
,modeGroupFlags = Group {
|
||||
@ -257,6 +258,16 @@ balancesheetmode = (commandmode ["balancesheet","bs"]) {
|
||||
}
|
||||
}
|
||||
|
||||
cashflowmode = (commandmode ["cashflow","cf"]) {
|
||||
modeHelp = "show a simple cashflow statement"
|
||||
,modeArgs = ([], Just commandargsflag)
|
||||
,modeGroupFlags = Group {
|
||||
groupUnnamed = []
|
||||
,groupHidden = []
|
||||
,groupNamed = [(generalflagstitle, generalflags1)]
|
||||
}
|
||||
}
|
||||
|
||||
statsmode = (commandmode ["stats"]) {
|
||||
modeHelp = "show quick statistics for a journal (or part of it)"
|
||||
,modeArgs = ([], Just commandargsflag)
|
||||
|
Loading…
Reference in New Issue
Block a user