{-# LANGUAGE RecordWildCards, DeriveDataTypeable, FlexibleInstances #-}
module Hledger.Reports.BalanceHistoryReport (
accountBalanceHistory
)
where
import Data.Time.Calendar
import Hledger.Data
import Hledger.Query
import Hledger.Reports.ReportOptions
import Hledger.Reports.TransactionsReports
accountBalanceHistory :: ReportOpts -> Journal -> Account -> [(Day, MixedAmount)]
accountBalanceHistory ropts j a = [(getdate t, bal) | (t,_,_,_,_,bal) <- items]
where
(_,items) = journalTransactionsReport ropts j acctquery
inclusivebal = True
acctquery = Acct $ (if inclusivebal then accountNameToAccountRegex else accountNameToAccountOnlyRegex) $ aname a
getdate = if date2_ ropts then transactionDate2 else tdate