lib,cli: Fix ledgerDateSpan, so that in takes transaction dates into account.

This commit is contained in:
Stephen Morgan 2021-04-03 16:35:58 +11:00 committed by Simon Michael
parent 5fbb67b893
commit edbb713cf8
2 changed files with 2 additions and 4 deletions

View File

@ -31,9 +31,7 @@ import Text.Printf
import Hledger.Utils.Test
import Hledger.Data.Types
import Hledger.Data.Account
import Hledger.Data.Dates (daysSpan)
import Hledger.Data.Journal
import Hledger.Data.Posting (postingDate)
import Hledger.Query
@ -94,7 +92,7 @@ ledgerPostings = journalPostings . ljournal
-- | The (fully specified) date span containing all the ledger's (filtered) transactions,
-- or DateSpan Nothing Nothing if there are none.
ledgerDateSpan :: Ledger -> DateSpan
ledgerDateSpan = daysSpan . map postingDate . ledgerPostings
ledgerDateSpan = journalDateSpanBothDates . ljournal
-- | All commodities used in this ledger.
ledgerCommodities :: Ledger -> [CommoditySymbol]

View File

@ -46,7 +46,7 @@ stats opts@CliOpts{reportspec_=rspec} j = do
d <- getCurrentDay
let q = rsQuery rspec
l = ledgerFromJournal q j
reportspan = (ledgerDateSpan l) `spanDefaultsFrom` (queryDateSpan False q)
reportspan = ledgerDateSpan l `spanDefaultsFrom` queryDateSpan False q
intervalspans = splitSpan (interval_ $ rsOpts rspec) reportspan
showstats = showLedgerStats l d
s = intercalate "\n" $ map showstats intervalspans