diff --git a/MANUAL.md b/MANUAL.md index bd1fde277..55031b913 100644 --- a/MANUAL.md +++ b/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 diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 269302a9d..a4abba533 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -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. diff --git a/hledger/Hledger/Cli.hs b/hledger/Hledger/Cli.hs index 6849c0b1c..bb7bd5cec 100644 --- a/hledger/Hledger/Cli.hs +++ b/hledger/Hledger/Cli.hs @@ -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 diff --git a/hledger/Hledger/Cli/Balancesheet.hs b/hledger/Hledger/Cli/Balancesheet.hs index af2662481..41811cabd 100644 --- a/hledger/Hledger/Cli/Balancesheet.hs +++ b/hledger/Hledger/Cli/Balancesheet.hs @@ -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 ... diff --git a/hledger/Hledger/Cli/Incomestatement.hs b/hledger/Hledger/Cli/Incomestatement.hs index 013b2a442..1f8a817d2 100644 --- a/hledger/Hledger/Cli/Incomestatement.hs +++ b/hledger/Hledger/Cli/Incomestatement.hs @@ -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 diff --git a/hledger/Hledger/Cli/Main.hs b/hledger/Hledger/Cli/Main.hs index b9928e7b3..d15154eab 100644 --- a/hledger/Hledger/Cli/Main.hs +++ b/hledger/Hledger/Cli/Main.hs @@ -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 diff --git a/hledger/Hledger/Cli/Options.hs b/hledger/Hledger/Cli/Options.hs index be611c546..f7eb3105d 100644 --- a/hledger/Hledger/Cli/Options.hs +++ b/hledger/Hledger/Cli/Options.hs @@ -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)