use shakespeare-text to help lay out incomestatement's output

This commit is contained in:
Simon Michael 2012-04-14 20:35:51 +00:00
parent a27eb7c29f
commit abb470aadb
2 changed files with 9 additions and 8 deletions

View File

@ -66,6 +66,7 @@ library
,parsec ,parsec
,regexpr >= 0.5.1 ,regexpr >= 0.5.1
,safe >= 0.2 ,safe >= 0.2
,shakespeare-text >= 1.0 && < 1.1
,split == 0.1.* ,split == 0.1.*
,time ,time
,utf8-string >= 0.3.5 && < 0.4 ,utf8-string >= 0.3.5 && < 0.4

View File

@ -1,3 +1,4 @@
{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-}
{-| {-|
The @incomestatement@ command prints a fairly standard income statement (profit & loss) report. The @incomestatement@ command prints a fairly standard income statement (profit & loss) report.
@ -9,24 +10,23 @@ module Hledger.Cli.Incomestatement (
,tests_Hledger_Cli_Incomestatement ,tests_Hledger_Cli_Incomestatement
) where ) where
import Data.List import qualified Data.Text.Lazy.IO as LT
import Test.HUnit import Test.HUnit
import Text.Shakespeare.Text
import Hledger import Hledger
import Prelude hiding (putStr)
import Hledger.Utils.UTF8IOCompat (putStr)
import Hledger.Cli.Options import Hledger.Cli.Options
import Hledger.Cli.Balance import Hledger.Cli.Balance
-- | Print a standard income statement. -- | Print a standard income statement.
incomestatement :: CliOpts -> Journal -> IO () incomestatement :: CliOpts -> Journal -> IO ()
incomestatement CliOpts{reportopts_=ropts} j = do incomestatement CliOpts{reportopts_=ropts} j = do
let lines = case formatFromOpts ropts of let report = accountsReport2 ropts (journalProfitAndLossAccountQuery j) j
Left err -> [err] LT.putStr $ [lt|Income Statement
Right _ -> accountsReportAsText ropts $ accountsReport2 ropts (journalProfitAndLossAccountQuery j) j
putStr $ unlines lines
#{unlines $ accountsReportAsText ropts report}|]
tests_Hledger_Cli_Incomestatement :: Test
tests_Hledger_Cli_Incomestatement = TestList tests_Hledger_Cli_Incomestatement = TestList
[ [
] ]