Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Created December 5, 2012 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmichael/4210558 to your computer and use it in GitHub Desktop.
Save simonmichael/4210558 to your computer and use it in GitHub Desktop.
draft of account historical balance calculation
-- Reports.hs:
-- | Get the historical running inclusive balance of a particular account,
-- from earliest to latest posting date.
-- XXX Accounts should know the Ledger & Journal they came from
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 effective_ ropts then transactionEffectiveDate else transactionActualDate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment