bugfix for #514, is and cf are now period reports, and bs, as a snapshot report, is treated as a special case
This commit is contained in:
parent
3dab20c654
commit
f5a530d620
@ -31,7 +31,9 @@ data BalanceView = BalanceView {
|
|||||||
bvaliases :: [String], -- ^ command line aliases
|
bvaliases :: [String], -- ^ command line aliases
|
||||||
bvhelp :: String, -- ^ command line help message
|
bvhelp :: String, -- ^ command line help message
|
||||||
bvtitle :: String, -- ^ title of the view
|
bvtitle :: String, -- ^ title of the view
|
||||||
bvqueries :: [(String, Journal -> Query)] -- ^ named queries that make up the view
|
bvqueries :: [(String, Journal -> Query)], -- ^ named queries that make up the view
|
||||||
|
bvsnapshot :: Bool -- ^ whether or not the view is a snapshot,
|
||||||
|
-- ignoring begin date in reporting period
|
||||||
}
|
}
|
||||||
|
|
||||||
balanceviewmode :: BalanceView -> Mode RawOpts
|
balanceviewmode :: BalanceView -> Mode RawOpts
|
||||||
@ -52,14 +54,14 @@ balanceviewmode BalanceView{..} = (defCommandMode $ bvmode : bvaliases) {
|
|||||||
|
|
||||||
balanceviewQueryReport
|
balanceviewQueryReport
|
||||||
:: ReportOpts
|
:: ReportOpts
|
||||||
-> Day
|
-> Query
|
||||||
-> Journal
|
-> Journal
|
||||||
-> String
|
-> String
|
||||||
-> (Journal -> Query)
|
-> (Journal -> Query)
|
||||||
-> ([String], Sum MixedAmount)
|
-> ([String], Sum MixedAmount)
|
||||||
balanceviewQueryReport ropts currDay j t q = ([view], Sum amt)
|
balanceviewQueryReport ropts q0 j t q = ([view], Sum amt)
|
||||||
where
|
where
|
||||||
q' = And [queryFromOpts currDay (withoutBeginDate ropts), q j]
|
q' = And [q0, q j]
|
||||||
rep@(_ , amt) = balanceReport ropts q' j
|
rep@(_ , amt) = balanceReport ropts q' j
|
||||||
view = intercalate "\n" [t <> ":", balanceReportAsText ropts rep]
|
view = intercalate "\n" [t <> ":", balanceReportAsText ropts rep]
|
||||||
|
|
||||||
@ -67,8 +69,10 @@ balanceviewQueryReport ropts currDay j t q = ([view], Sum amt)
|
|||||||
balanceviewReport :: BalanceView -> CliOpts -> Journal -> IO ()
|
balanceviewReport :: BalanceView -> CliOpts -> Journal -> IO ()
|
||||||
balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts} j = do
|
balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts} j = do
|
||||||
currDay <- getCurrentDay
|
currDay <- getCurrentDay
|
||||||
let (views, amt) =
|
let q0 | bvsnapshot = queryFromOpts currDay (withoutBeginDate ropts)
|
||||||
foldMap (uncurry (balanceviewQueryReport ropts currDay j))
|
| otherwise = queryFromOpts currDay ropts
|
||||||
|
(views, amt) =
|
||||||
|
foldMap (uncurry (balanceviewQueryReport ropts q0 j))
|
||||||
bvqueries
|
bvqueries
|
||||||
mapM_ putStrLn (bvtitle : "" : views)
|
mapM_ putStrLn (bvtitle : "" : views)
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,8 @@ bsBV = BalanceView {
|
|||||||
bvtitle = "Balance Sheet",
|
bvtitle = "Balance Sheet",
|
||||||
bvqueries = [ ("Assets" , journalAssetAccountQuery),
|
bvqueries = [ ("Assets" , journalAssetAccountQuery),
|
||||||
("Liabilities", journalLiabilityAccountQuery)
|
("Liabilities", journalLiabilityAccountQuery)
|
||||||
]
|
],
|
||||||
|
bvsnapshot = True
|
||||||
}
|
}
|
||||||
|
|
||||||
balancesheetmode :: Mode RawOpts
|
balancesheetmode :: Mode RawOpts
|
||||||
|
|||||||
@ -26,7 +26,8 @@ cfBV = BalanceView {
|
|||||||
bvaliases = ["cf"],
|
bvaliases = ["cf"],
|
||||||
bvhelp = "show a cashflow statement",
|
bvhelp = "show a cashflow statement",
|
||||||
bvtitle = "Cashflow Statement",
|
bvtitle = "Cashflow Statement",
|
||||||
bvqueries = [("Cash flows", journalCashAccountQuery)]
|
bvqueries = [("Cash flows", journalCashAccountQuery)],
|
||||||
|
bvsnapshot = False
|
||||||
}
|
}
|
||||||
|
|
||||||
cashflowmode :: Mode RawOpts
|
cashflowmode :: Mode RawOpts
|
||||||
|
|||||||
@ -25,7 +25,8 @@ isBV = BalanceView {
|
|||||||
bvtitle = "Income Statement",
|
bvtitle = "Income Statement",
|
||||||
bvqueries = [ ("Revenues", journalIncomeAccountQuery),
|
bvqueries = [ ("Revenues", journalIncomeAccountQuery),
|
||||||
("Expenses", journalExpenseAccountQuery)
|
("Expenses", journalExpenseAccountQuery)
|
||||||
]
|
],
|
||||||
|
bvsnapshot = False
|
||||||
}
|
}
|
||||||
|
|
||||||
incomestatementmode :: Mode RawOpts
|
incomestatementmode :: Mode RawOpts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user