@@ -70,6 +70,7 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{_rsReportOpts=ReportO
70
70
71
71
let
72
72
ropts = _rsReportOpts rspec
73
+ wd = whichDate ropts
73
74
showCashFlow = boolopt " cashflow" rawopts
74
75
prettyTables = pretty_
75
76
makeQuery flag = do
@@ -83,7 +84,7 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{_rsReportOpts=ReportO
83
84
trans = dbg3 " investments" $ jtxns $ filterJournalTransactions investmentsQuery j
84
85
85
86
journalSpan =
86
- let dates = map transactionDate2 trans in
87
+ let dates = map (transactionDateOrDate2 wd) trans in
87
88
DateSpan (Just $ minimum dates) (Just $ addDays 1 $ maximum dates)
88
89
89
90
requestedSpan = periodAsDateSpan period_
@@ -121,16 +122,16 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{_rsReportOpts=ReportO
121
122
cashFlow =
122
123
((map (,nullmixedamt) priceDates)++ ) $
123
124
cashFlowApplyCostValue $
124
- calculateCashFlow trans (And [ Not investmentsQuery
125
- , Not pnlQuery
126
- , Date span ] )
125
+ calculateCashFlow wd trans (And [ Not investmentsQuery
126
+ , Not pnlQuery
127
+ , Date span ] )
127
128
128
129
129
130
pnl =
130
131
cashFlowApplyCostValue $
131
- calculateCashFlow trans (And [ Not investmentsQuery
132
- , pnlQuery
133
- , Date span ] )
132
+ calculateCashFlow wd trans (And [ Not investmentsQuery
133
+ , pnlQuery
134
+ , Date span ] )
134
135
135
136
thisSpan = dbg3 " processing span" $
136
137
OneSpan spanBegin spanEnd valueBefore valueAfter cashFlow pnl
@@ -290,9 +291,9 @@ interestSum referenceDay cf rate = sum $ map go cf
290
291
where go (t,m) = realToFrac (unMix m) * rate ** (fromIntegral (referenceDay `diffDays` t) / 365 )
291
292
292
293
293
- calculateCashFlow :: [Transaction ] -> Query -> CashFlow
294
- calculateCashFlow trans query = filter (maIsNonZero . snd ) $ map go trans
295
- where go t = (transactionDate2 t, total [t] query)
294
+ calculateCashFlow :: WhichDate -> [Transaction ] -> Query -> CashFlow
295
+ calculateCashFlow wd trans query =
296
+ [ (postingDateOrDate2 wd p, pamount p) | p <- filter (matchesPosting query) ( concatMap realPostings trans), maIsNonZero (pamount p) ]
296
297
297
298
total :: [Transaction ] -> Query -> MixedAmount
298
299
total trans query = sumPostings . filter (matchesPosting query) $ concatMap realPostings trans
0 commit comments