module Hledger.Reports.EntriesReport (
EntriesReport,
EntriesReportItem,
entriesReport,
tests_Hledger_Reports_EntriesReport
)
where
import Data.List
import Data.Ord
import Test.HUnit
import Hledger.Data
import Hledger.Query
import Hledger.Reports.ReportOptions
type EntriesReport = [EntriesReportItem]
type EntriesReportItem = Transaction
entriesReport :: ReportOpts -> Query -> Journal -> EntriesReport
entriesReport opts q j =
sortBy (comparing date) $ filter (q `matchesTransaction`) ts
where
date = transactionDateFn opts
ts = jtxns $ journalSelectingAmountFromOpts opts j
tests_entriesReport :: [Test]
tests_entriesReport = [
"entriesReport" ~: do
assertEqual "not acct" 1 (length $ entriesReport defreportopts (Not $ Acct "bank") samplejournal)
let sp = mkdatespan "2008/06/01" "2008/07/01"
assertEqual "date" 3 (length $ entriesReport defreportopts (Date sp) samplejournal)
]
tests_Hledger_Reports_EntriesReport :: Test
tests_Hledger_Reports_EntriesReport = TestList $
tests_entriesReport