prototypical incomestatement and balancesheet commands
This commit is contained in:
		
							parent
							
								
									b96e3ac85d
								
							
						
					
					
						commit
						ca5d5020e1
					
				
							
								
								
									
										12
									
								
								MANUAL.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								MANUAL.md
									
									
									
									
									
								
							| @ -734,6 +734,18 @@ Examples: | |||||||
| 
 | 
 | ||||||
|     $ hledger activity -p weekly dining |     $ hledger activity -p weekly dining | ||||||
| 
 | 
 | ||||||
|  | #### incomestatement | ||||||
|  | 
 | ||||||
|  | This is intended to display a standard-looking | ||||||
|  | [income statement](http://en.wikipedia.org/wiki/Income_statement). Currently | ||||||
|  | it is similar to doing `hledger balance '^(income|expenses?|profits?|loss(es)?)(:|$)'`. | ||||||
|  | 
 | ||||||
|  | #### balancesheet | ||||||
|  | 
 | ||||||
|  | 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)(:|$)'`. | ||||||
|  | 
 | ||||||
| #### stats | #### stats | ||||||
| 
 | 
 | ||||||
| The stats command displays summary information for the whole journal, or | The stats command displays summary information for the whole journal, or | ||||||
|  | |||||||
| @ -6,7 +6,9 @@ hledger command-line program. | |||||||
| module Hledger.Cli ( | module Hledger.Cli ( | ||||||
|                      module Hledger.Cli.Add, |                      module Hledger.Cli.Add, | ||||||
|                      module Hledger.Cli.Balance, |                      module Hledger.Cli.Balance, | ||||||
|  |                      module Hledger.Cli.Balancesheet, | ||||||
|                      module Hledger.Cli.Histogram, |                      module Hledger.Cli.Histogram, | ||||||
|  |                      module Hledger.Cli.Incomestatement, | ||||||
|                      module Hledger.Cli.Print, |                      module Hledger.Cli.Print, | ||||||
|                      module Hledger.Cli.Register, |                      module Hledger.Cli.Register, | ||||||
|                      module Hledger.Cli.Stats, |                      module Hledger.Cli.Stats, | ||||||
| @ -25,7 +27,9 @@ import Test.HUnit | |||||||
| import Hledger | import Hledger | ||||||
| import Hledger.Cli.Add | import Hledger.Cli.Add | ||||||
| import Hledger.Cli.Balance | import Hledger.Cli.Balance | ||||||
|  | import Hledger.Cli.Balancesheet | ||||||
| import Hledger.Cli.Histogram | import Hledger.Cli.Histogram | ||||||
|  | import Hledger.Cli.Incomestatement | ||||||
| import Hledger.Cli.Print | import Hledger.Cli.Print | ||||||
| import Hledger.Cli.Register | import Hledger.Cli.Register | ||||||
| import Hledger.Cli.Stats | import Hledger.Cli.Stats | ||||||
| @ -42,7 +46,9 @@ tests_Hledger_Cli = TestList | |||||||
|    ,tests_Hledger_Read |    ,tests_Hledger_Read | ||||||
|    -- ,tests_Hledger_Cli_Add |    -- ,tests_Hledger_Cli_Add | ||||||
|    -- ,tests_Hledger_Cli_Balance |    -- ,tests_Hledger_Cli_Balance | ||||||
|  |    ,tests_Hledger_Cli_Balancesheet | ||||||
|    -- ,tests_Hledger_Cli_Histogram |    -- ,tests_Hledger_Cli_Histogram | ||||||
|  |    ,tests_Hledger_Cli_Incomestatement | ||||||
|    ,tests_Hledger_Cli_Options |    ,tests_Hledger_Cli_Options | ||||||
|    -- ,tests_Hledger_Cli_Print |    -- ,tests_Hledger_Cli_Print | ||||||
|    ,tests_Hledger_Cli_Register |    ,tests_Hledger_Cli_Register | ||||||
|  | |||||||
							
								
								
									
										32
									
								
								hledger/Hledger/Cli/Balancesheet.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								hledger/Hledger/Cli/Balancesheet.hs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | {-| | ||||||
|  | 
 | ||||||
|  | The @balancesheet@ command prints a fairly standard balance sheet. | ||||||
|  | 
 | ||||||
|  | -} | ||||||
|  | 
 | ||||||
|  | module Hledger.Cli.Balancesheet ( | ||||||
|  |   balancesheet | ||||||
|  |  ,tests_Hledger_Cli_Balancesheet | ||||||
|  | ) where | ||||||
|  | 
 | ||||||
|  | import Data.List | ||||||
|  | import Test.HUnit | ||||||
|  | 
 | ||||||
|  | import Hledger | ||||||
|  | import Prelude hiding (putStr) | ||||||
|  | import Hledger.Utils.UTF8IOCompat (putStr) | ||||||
|  | import Hledger.Cli.Options | ||||||
|  | import Hledger.Cli.Balance | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | -- | Print a standard balancesheet. | ||||||
|  | balancesheet :: CliOpts -> Journal -> IO () | ||||||
|  | balancesheet CliOpts{reportopts_=ropts} j = do | ||||||
|  |   let lines = case formatFromOpts ropts of | ||||||
|  |             Left err -> [err] | ||||||
|  |             Right _ -> accountsReportAsText ropts $ accountsReport2 ropts (journalBalanceSheetAccountMatcher j) j | ||||||
|  |   putStr $ unlines lines | ||||||
|  | 
 | ||||||
|  | tests_Hledger_Cli_Balancesheet = TestList | ||||||
|  |  [ | ||||||
|  |  ] | ||||||
							
								
								
									
										32
									
								
								hledger/Hledger/Cli/Incomestatement.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								hledger/Hledger/Cli/Incomestatement.hs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | {-| | ||||||
|  | 
 | ||||||
|  | The @incomestatement@ command prints a fairly standard income statement (profit & loss) report. | ||||||
|  | 
 | ||||||
|  | -} | ||||||
|  | 
 | ||||||
|  | module Hledger.Cli.Incomestatement ( | ||||||
|  |   incomestatement | ||||||
|  |  ,tests_Hledger_Cli_Incomestatement | ||||||
|  | ) where | ||||||
|  | 
 | ||||||
|  | import Data.List | ||||||
|  | import Test.HUnit | ||||||
|  | 
 | ||||||
|  | import Hledger | ||||||
|  | import Prelude hiding (putStr) | ||||||
|  | import Hledger.Utils.UTF8IOCompat (putStr) | ||||||
|  | import Hledger.Cli.Options | ||||||
|  | import Hledger.Cli.Balance | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | -- | Print a standard income statement. | ||||||
|  | incomestatement :: CliOpts -> Journal -> IO () | ||||||
|  | incomestatement CliOpts{reportopts_=ropts} j = do | ||||||
|  |   let lines = case formatFromOpts ropts of | ||||||
|  |             Left err -> [err] | ||||||
|  |             Right _ -> accountsReportAsText ropts $ accountsReport2 ropts (journalProfitAndLossAccountMatcher j) j | ||||||
|  |   putStr $ unlines lines | ||||||
|  | 
 | ||||||
|  | tests_Hledger_Cli_Incomestatement = TestList | ||||||
|  |  [ | ||||||
|  |  ] | ||||||
| @ -49,7 +49,9 @@ import Text.Printf | |||||||
| import Hledger (ensureJournalFileExists) | import Hledger (ensureJournalFileExists) | ||||||
| import Hledger.Cli.Add | import Hledger.Cli.Add | ||||||
| import Hledger.Cli.Balance | import Hledger.Cli.Balance | ||||||
|  | import Hledger.Cli.Balancesheet | ||||||
| import Hledger.Cli.Histogram | import Hledger.Cli.Histogram | ||||||
|  | import Hledger.Cli.Incomestatement | ||||||
| import Hledger.Cli.Print | import Hledger.Cli.Print | ||||||
| import Hledger.Cli.Register | import Hledger.Cli.Register | ||||||
| import Hledger.Cli.Stats | import Hledger.Cli.Stats | ||||||
| @ -78,6 +80,8 @@ main = do | |||||||
|        | any (cmd `isPrefixOf`) ["entries","print"]      = showModeHelpOr entriesmode  $ withJournalDo opts print' |        | any (cmd `isPrefixOf`) ["entries","print"]      = showModeHelpOr entriesmode  $ withJournalDo opts print' | ||||||
|        | any (cmd `isPrefixOf`) ["postings","register"]  = showModeHelpOr postingsmode $ withJournalDo opts register |        | any (cmd `isPrefixOf`) ["postings","register"]  = showModeHelpOr postingsmode $ withJournalDo opts register | ||||||
|        | any (cmd `isPrefixOf`) ["activity","histogram"] = showModeHelpOr activitymode $ withJournalDo opts histogram |        | any (cmd `isPrefixOf`) ["activity","histogram"] = showModeHelpOr activitymode $ withJournalDo opts histogram | ||||||
|  |        | cmd `isPrefixOf` "incomestatement"              = showModeHelpOr activitymode $ withJournalDo opts incomestatement | ||||||
|  |        | any (cmd `isPrefixOf`) ["balancesheet","bs"]    = showModeHelpOr activitymode $ withJournalDo opts balancesheet | ||||||
|        | cmd `isPrefixOf` "stats"                        = showModeHelpOr statsmode    $ withJournalDo opts stats |        | cmd `isPrefixOf` "stats"                        = showModeHelpOr statsmode    $ withJournalDo opts stats | ||||||
|        | not (null matchedaddon)                           = do |        | not (null matchedaddon)                           = do | ||||||
|                                                              when (debug_ opts) $ printf "running %s\n" shellcmd |                                                              when (debug_ opts) $ printf "running %s\n" shellcmd | ||||||
|  | |||||||
| @ -72,6 +72,8 @@ mainmode addons = defmode { | |||||||
|        ,postingsmode |        ,postingsmode | ||||||
|        -- ,transactionsmode |        -- ,transactionsmode | ||||||
|        ,activitymode |        ,activitymode | ||||||
|  |        ,incomestatementmode | ||||||
|  |        ,balancesheetmode | ||||||
|        ,statsmode |        ,statsmode | ||||||
|        ]) |        ]) | ||||||
|      ] |      ] | ||||||
| @ -235,6 +237,26 @@ activitymode = (commandmode ["activity","histogram"]) { | |||||||
|     } |     } | ||||||
|  } |  } | ||||||
| 
 | 
 | ||||||
|  | incomestatementmode = (commandmode ["incomestatement"]) { | ||||||
|  |   modeHelp = "show a standard income statement" | ||||||
|  |  ,modeArgs = ([], Just commandargsflag) | ||||||
|  |  ,modeGroupFlags = Group { | ||||||
|  |      groupUnnamed = [] | ||||||
|  |     ,groupHidden = [] | ||||||
|  |     ,groupNamed = [(generalflagstitle, generalflags1)] | ||||||
|  |     } | ||||||
|  |  } | ||||||
|  | 
 | ||||||
|  | balancesheetmode = (commandmode ["balancesheet","bs"]) { | ||||||
|  |   modeHelp = "show a standard balance sheet" | ||||||
|  |  ,modeArgs = ([], Just commandargsflag) | ||||||
|  |  ,modeGroupFlags = Group { | ||||||
|  |      groupUnnamed = [] | ||||||
|  |     ,groupHidden = [] | ||||||
|  |     ,groupNamed = [(generalflagstitle, generalflags1)] | ||||||
|  |     } | ||||||
|  |  } | ||||||
|  | 
 | ||||||
| statsmode = (commandmode ["stats"]) { | statsmode = (commandmode ["stats"]) { | ||||||
|   modeHelp = "show quick statistics for a journal (or part of it)" |   modeHelp = "show quick statistics for a journal (or part of it)" | ||||||
|  ,modeArgs = ([], Just commandargsflag) |  ,modeArgs = ([], Just commandargsflag) | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| # | # | ||||||
| bin/hledger -f- bal | bin/hledger -f- balance | ||||||
| <<< | <<< | ||||||
| 1/1 | 1/1 | ||||||
|   a   1.00 |   a   1.00 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user