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
,regexpr >= 0.5.1
,safe >= 0.2
,shakespeare-text >= 1.0 && < 1.1
,split == 0.1.*
,time
,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.
@ -9,24 +10,23 @@ module Hledger.Cli.Incomestatement (
,tests_Hledger_Cli_Incomestatement
) where
import Data.List
import qualified Data.Text.Lazy.IO as LT
import Test.HUnit
import Text.Shakespeare.Text
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 (journalProfitAndLossAccountQuery j) j
putStr $ unlines lines
let report = accountsReport2 ropts (journalProfitAndLossAccountQuery j) j
LT.putStr $ [lt|Income Statement
#{unlines $ accountsReportAsText ropts report}|]
tests_Hledger_Cli_Incomestatement :: Test
tests_Hledger_Cli_Incomestatement = TestList
[
]