diff --git a/hledger-lib/Hledger/Data/DayPartition.hs b/hledger-lib/Hledger/Data/DayPartition.hs index d301772ba..fa85dcc43 100644 --- a/hledger-lib/Hledger/Data/DayPartition.hs +++ b/hledger-lib/Hledger/Data/DayPartition.hs @@ -15,7 +15,7 @@ module Hledger.Data.DayPartition -- * operations , unionDayPartitions , dayPartitionStartEnd -, lookupDayPartition +, dayPartitionFind , splitSpan , intervalBoundaryBefore -- * tests @@ -130,12 +130,12 @@ dayPartitionStartEnd (DayPartition (PeriodData _ ds)) = -- Guaranteed not to error because the IntMap is non-empty. (intToDay . fst $ IM.findMin ds, snd $ IM.findMax ds) -lookupDayPartition :: Day -> DayPartition -> (Maybe Day, Day) -lookupDayPartition d (DayPartition xs) = lookupPeriodDataOrHistorical d xs -- | Find the start and end dates of the period within a 'DayPartition' which contains a given day. -- If the day is after the end of the last period, it is assumed to be within the last period. -- If the day is before the start of the first period (ie, in the historical period), -- only the historical period's end date is returned. +dayPartitionFind :: Day -> DayPartition -> (Maybe Day, Day) +dayPartitionFind d (DayPartition xs) = lookupPeriodDataOrHistorical d xs -- | Split a 'DateSpan' into a 'DayPartition' consisting of consecutive exact -- spans of the specified Interval, or `Nothing` if the span is invalid. diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs index dd62c04d4..0e8586894 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs @@ -295,7 +295,7 @@ calculateReportAccount rspec@ReportSpec{_rsReportOpts=ropts} j priceoracle (Just mapPeriodData (padPeriodData mempty (dayPartitionToPeriodData colspans)) $ accountFromPostings getIntervalStartDate ps - getIntervalStartDate p = fst $ lookupDayPartition (getPostingDate p) colspans + getIntervalStartDate p = fst $ dayPartitionFind (getPostingDate p) colspans getPostingDate = postingDateOrDate2 (whichDate (_rsReportOpts rspec)) -- | The valuation function to use for the chosen report options. diff --git a/hledger-lib/Hledger/Reports/ReportOptions.hs b/hledger-lib/Hledger/Reports/ReportOptions.hs index 80bbc377a..6236f25b0 100644 --- a/hledger-lib/Hledger/Reports/ReportOptions.hs +++ b/hledger-lib/Hledger/Reports/ReportOptions.hs @@ -674,7 +674,7 @@ journalApplyValuationFromOptsWith rspec@ReportSpec{_rsReportOpts=ropts} j priceo where postingPeriodEnd d = fromMaybe err $ case interval_ ropts of NoInterval -> fmap (snd . dayPartitionStartEnd) . snd $ reportSpan j rspec - _ -> fmap (snd . lookupDayPartition d) . snd $ reportSpanBothDates j rspec + _ -> fmap (snd . dayPartitionFind d) . snd $ reportSpanBothDates j rspec -- Should never happen, because there are only invalid dayPartitions -- when there are no transactions, in which case this function is never called err = error' "journalApplyValuationFromOpts: expected all spans to have an end date"