hledger/hledger/Hledger/Cli/Commands/Balancesheetequity.hs
Stephen Morgan c966a0f413 fix!: cbr: Remove old account type query code. (#1921)
This replaces the old journal*AccountQuery with the new Type query. This
enables uniform treatment of account type, and fixes a subtle bug
(#1921).

Note that cbcsubreportquery no longer takes Journal as an argument.
2022-08-21 08:27:51 +01:00

56 lines
1.7 KiB
Haskell

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-|
The @balancesheetequity@ command prints a simple balance sheet.
-}
module Hledger.Cli.Commands.Balancesheetequity (
balancesheetequitymode
,balancesheetequity
) where
import System.Console.CmdArgs.Explicit
import Hledger
import Hledger.Cli.CliOptions
import Hledger.Cli.CompoundBalanceCommand
balancesheetequitySpec = CompoundBalanceCommandSpec {
cbcdoc = $(embedFileRelative "Hledger/Cli/Commands/Balancesheetequity.txt"),
cbctitle = "Balance Sheet With Equity",
cbcqueries = [
CBCSubreportSpec{
cbcsubreporttitle="Assets"
,cbcsubreportquery=Type [Asset]
,cbcsubreportoptions=(\ropts -> ropts{normalbalance_=Just NormallyPositive})
,cbcsubreporttransform=id
,cbcsubreportincreasestotal=True
}
,CBCSubreportSpec{
cbcsubreporttitle="Liabilities"
,cbcsubreportquery=Type [Liability]
,cbcsubreportoptions=(\ropts -> ropts{normalbalance_=Just NormallyNegative})
,cbcsubreporttransform=fmap maNegate
,cbcsubreportincreasestotal=False
}
,CBCSubreportSpec{
cbcsubreporttitle="Equity"
,cbcsubreportquery=Type [Equity]
,cbcsubreportoptions=(\ropts -> ropts{normalbalance_=Just NormallyNegative})
,cbcsubreporttransform=fmap maNegate
,cbcsubreportincreasestotal=False
}
],
cbcaccum = Historical
}
balancesheetequitymode :: Mode RawOpts
balancesheetequitymode = compoundBalanceCommandMode balancesheetequitySpec
balancesheetequity :: CliOpts -> Journal -> IO ()
balancesheetequity = compoundBalanceCommand balancesheetequitySpec