{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
module Hledger.Cli.Commands.Balancesheet (
balancesheetmode
,balancesheet
,balancesheetSpec
) where
import System.Console.CmdArgs.Explicit
import Hledger.Utils.I18n (i18n)
import Hledger
import Hledger.Cli.CliOptions
import Hledger.Cli.CompoundBalanceCommand
balancesheetSpec :: CompoundBalanceCommandSpec
balancesheetSpec :: CompoundBalanceCommandSpec
balancesheetSpec = CompoundBalanceCommandSpec {
cbcdoc :: CommandHelpStr
cbcdoc = $(embedFileRelative "Hledger/Cli/Commands/Balancesheet.txt"),
cbctitle :: Interval -> Text
cbctitle = \case
Interval
NoInterval -> Text -> Text
i18n Text
"Balance Sheet"
Days Int
1 -> Text -> Text
i18n Text
"Daily Balance Sheet"
Weeks Int
1 -> Text -> Text
i18n Text
"Weekly Balance Sheet"
Weeks Int
2 -> Text -> Text
i18n Text
"Biweekly Balance Sheet"
Months Int
1 -> Text -> Text
i18n Text
"Monthly Balance Sheet"
Months Int
2 -> Text -> Text
i18n Text
"Bimonthly Balance Sheet"
Months Int
3 -> Text -> Text
i18n Text
"Quarterly Balance Sheet"
Months Int
6 -> Text -> Text
i18n Text
"Half-yearly Balance Sheet"
Years Int
1 -> Text -> Text
i18n Text
"Yearly Balance Sheet"
Years Int
2 -> Text -> Text
i18n Text
"Biennial Balance Sheet"
Interval
_ -> Text -> Text
i18n Text
"Periodic Balance Sheet",
cbcqueries :: [CBCSubreportSpec DisplayName]
cbcqueries = [
CBCSubreportSpec{
cbcsubreporttitle :: Text
cbcsubreporttitle=Text -> Text
i18n Text
"Assets"
,cbcsubreportquery :: Query
cbcsubreportquery=[AccountType] -> Query
Type [AccountType
Asset]
,cbcsubreportoptions :: ReportOpts -> ReportOpts
cbcsubreportoptions=(\ReportOpts
ropts -> ReportOpts
ropts{normalbalance_=Just NormallyPositive})
,cbcsubreporttransform :: PeriodicReport DisplayName MixedAmount
-> PeriodicReport DisplayName MixedAmount
cbcsubreporttransform=PeriodicReport DisplayName MixedAmount
-> PeriodicReport DisplayName MixedAmount
forall a. a -> a
id
,cbcsubreportincreasestotal :: Bool
cbcsubreportincreasestotal=Bool
True
}
,CBCSubreportSpec{
cbcsubreporttitle :: Text
cbcsubreporttitle=Text -> Text
i18n Text
"Liabilities"
,cbcsubreportquery :: Query
cbcsubreportquery=[AccountType] -> Query
Type [AccountType
Liability]
,cbcsubreportoptions :: ReportOpts -> ReportOpts
cbcsubreportoptions=(\ReportOpts
ropts -> ReportOpts
ropts{normalbalance_=Just NormallyNegative})
,cbcsubreporttransform :: PeriodicReport DisplayName MixedAmount
-> PeriodicReport DisplayName MixedAmount
cbcsubreporttransform=(MixedAmount -> MixedAmount)
-> PeriodicReport DisplayName MixedAmount
-> PeriodicReport DisplayName MixedAmount
forall a b.
(a -> b)
-> PeriodicReport DisplayName a -> PeriodicReport DisplayName b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap MixedAmount -> MixedAmount
maNegate
,cbcsubreportincreasestotal :: Bool
cbcsubreportincreasestotal=Bool
False
}
],
cbcaccum :: BalanceAccumulation
cbcaccum = BalanceAccumulation
Historical
}
balancesheetmode :: Mode RawOpts
balancesheetmode :: Mode RawOpts
balancesheetmode = CompoundBalanceCommandSpec -> Mode RawOpts
compoundBalanceCommandMode CompoundBalanceCommandSpec
balancesheetSpec
balancesheet :: CliOpts -> Journal -> IO ()
balancesheet :: CliOpts -> Journal -> IO ()
balancesheet = CompoundBalanceCommandSpec -> CliOpts -> Journal -> IO ()
compoundBalanceCommand CompoundBalanceCommandSpec
balancesheetSpec