    {-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-}
    {-|

    The @incomestatement@ command prints a simple income statement (profit & loss report).

    -}

    module Hledger.Cli.Commands.Incomestatement (
      incomestatementmode
     ,incomestatement
    ) where

    import System.Console.CmdArgs.Explicit

    import Hledger
    import Hledger.Cli.CliOptions
    import Hledger.Cli.CompoundBalanceCommand

    incomestatementSpec :: CompoundBalanceCommandSpec
    incomestatementSpec = CompoundBalanceCommandSpec :: CommandDoc
    -> CommandDoc
    -> [CBCSubreportSpec]
    -> BalanceType
    -> CompoundBalanceCommandSpec
    CompoundBalanceCommandSpec {
      cbcdoc :: CommandDoc
    cbcdoc      = $(embedFileRelative "Hledger/Cli/Commands/Incomestatement.txt"),
      cbctitle :: CommandDoc
    cbctitle    = "Income Statement",
      cbcqueries :: [CBCSubreportSpec]
    cbcqueries  = [
         CBCSubreportSpec :: CommandDoc
    -> (Journal -> Query) -> NormalSign -> Bool -> CBCSubreportSpec
    CBCSubreportSpec{
          cbcsubreporttitle :: CommandDoc
    cbcsubreporttitle="Revenues"
         ,cbcsubreportquery :: Journal -> Query
    cbcsubreportquery=Journal -> Query
    journalRevenueAccountQuery
         ,cbcsubreportnormalsign :: NormalSign
    cbcsubreportnormalsign=NormalSign
    NormallyNegative
         ,cbcsubreportincreasestotal :: Bool
    cbcsubreportincreasestotal=Bool
    True
         }
        ,CBCSubreportSpec :: CommandDoc
    -> (Journal -> Query) -> NormalSign -> Bool -> CBCSubreportSpec
    CBCSubreportSpec{
          cbcsubreporttitle :: CommandDoc
    cbcsubreporttitle="Expenses"
         ,cbcsubreportquery :: Journal -> Query
    cbcsubreportquery=Journal -> Query
    journalExpenseAccountQuery
         ,cbcsubreportnormalsign :: NormalSign
    cbcsubreportnormalsign=NormalSign
    NormallyPositive
         ,cbcsubreportincreasestotal :: Bool
    cbcsubreportincreasestotal=Bool
    False
         }
        ],
      cbctype :: BalanceType
    cbctype     = BalanceType
    PeriodChange
    }

    incomestatementmode :: Mode RawOpts
    incomestatementmode :: Mode RawOpts
    incomestatementmode = CompoundBalanceCommandSpec -> Mode RawOpts
    compoundBalanceCommandMode CompoundBalanceCommandSpec
    incomestatementSpec

    incomestatement :: CliOpts -> Journal -> IO ()
    incomestatement :: CliOpts -> Journal -> IO ()
    incomestatement = CompoundBalanceCommandSpec -> CliOpts -> Journal -> IO ()
    compoundBalanceCommand CompoundBalanceCommandSpec
    incomestatementSpec