lib: refactor

This commit is contained in:
Simon Michael 2018-01-15 14:14:21 -08:00
parent 79812f974a
commit 3b2a9eaba4
2 changed files with 21 additions and 23 deletions

View File

@ -367,10 +367,7 @@ data Account = Account {
-- Assets and expenses are normally positive (debit), while liabilities, equity
-- and income are normally negative (credit).
-- https://en.wikipedia.org/wiki/Normal_balance
data NormalSign =
NormallyPositive -- ^ normally debit - assets, expenses...
| NormallyNegative -- ^ normally credit - liabilities, equity, income...
deriving (Show, Data, Eq)
data NormalSign = NormallyPositive | NormallyNegative deriving (Show, Data, Eq)
-- | A Ledger has the journal it derives from, and the accounts
-- derived from that. Accounts are accessible both list-wise and

View File

@ -45,6 +45,26 @@ data CompoundBalanceCommandSpec = CompoundBalanceCommandSpec {
cbctype :: BalanceType -- ^ the type of "balance" this report shows (overrides command line flags)
}
-- | A compound balance report has:
--
-- * an overall title
--
-- * the period (date span) of each column
--
-- * one or more named multi balance reports, with columns corresponding to the above
--
-- * a list of overall totals for each column, and their grand total and average
--
-- It is used in compound balance report commands like balancesheet,
-- cashflow and incomestatement.
type CompoundBalanceReport =
( String
, [DateSpan]
, [(String, MultiBalanceReport)]
, ([MixedAmount], MixedAmount, MixedAmount)
)
-- | Generate a cmdargs option-parsing mode from a compound balance command
-- specification.
compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts
@ -212,25 +232,6 @@ compoundBalanceCommandSingleColumnReport ropts userq j subreporttitle subreportq
| otherwise = balanceReport ropts' q j
subreportstr = intercalate "\n" [subreporttitle <> ":", balanceReportAsText ropts r]
-- | A compound balance report has:
--
-- * an overall title
--
-- * the period (date span) of each column
--
-- * one or more named multi balance reports, with columns corresponding to the above
--
-- * a list of overall totals for each column, and their grand total and average
--
-- It is used in compound balance report commands like balancesheet,
-- cashflow and incomestatement.
type CompoundBalanceReport =
( String
, [DateSpan]
, [(String, MultiBalanceReport)]
, ([MixedAmount], MixedAmount, MixedAmount)
)
-- | Run one subreport for a compound balance command in multi-column mode.
-- This returns a MultiBalanceReport.
compoundBalanceSubreport :: ReportOpts -> Query -> Journal -> (Journal -> Query) -> Maybe NormalSign -> MultiBalanceReport