Debian Codegraph @

Hledger/Cli/Commands/Balancesheet.hs

raw
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE RecordWildCards #-}
3 {-# LANGUAGE TemplateHaskell #-}
4 {-|
5
6 The @balancesheet@ command prints a simple balance sheet.
7
8 -}
9
10 module Hledger.Cli.Commands.Balancesheet (
11 balancesheetmode
12 ,balancesheet
13 ) where
14
15 import System.Console.CmdArgs.Explicit
16
17 import Hledger
18 import Hledger.Cli.CliOptions
19 import Hledger.Cli.CompoundBalanceCommand
20
21 balancesheetSpec = CompoundBalanceCommandSpec {
22 cbcdoc = $(embedFileRelative "Hledger/Cli/Commands/Balancesheet.txt"),
23 cbctitle = "Balance Sheet",
24 cbcqueries = [
25 CBCSubreportSpec{
26 cbcsubreporttitle="Assets"
27 ,cbcsubreportquery=Type [Asset]
28 ,cbcsubreportoptions=(\ropts -> ropts{normalbalance_=Just NormallyPositive})
29 ,cbcsubreporttransform=id
30 ,cbcsubreportincreasestotal=True
31 }
32 ,CBCSubreportSpec{
33 cbcsubreporttitle="Liabilities"
34 ,cbcsubreportquery=Type [Liability]
35 ,cbcsubreportoptions=(\ropts -> ropts{normalbalance_=Just NormallyNegative})
36 ,cbcsubreporttransform=fmap maNegate
37 ,cbcsubreportincreasestotal=False
38 }
39 ],
40 cbcaccum = Historical
41 }
42
43 balancesheetmode :: Mode RawOpts
44 balancesheetmode = compoundBalanceCommandMode balancesheetSpec
45
46 balancesheet :: CliOpts -> Journal -> IO ()
47 balancesheet = compoundBalanceCommand balancesheetSpec