fix: areg, ui: show transactions normally with a type: query (#1905)
accountTransactionsReport was not account types-aware. There might be more of these lurking.
This commit is contained in:
parent
0a43b4c624
commit
229fe6ac58
@ -37,6 +37,7 @@ module Hledger.Data.Journal (
|
|||||||
filterJournalAmounts,
|
filterJournalAmounts,
|
||||||
filterTransactionAmounts,
|
filterTransactionAmounts,
|
||||||
filterTransactionPostings,
|
filterTransactionPostings,
|
||||||
|
filterTransactionPostingsExtra,
|
||||||
filterTransactionRelatedPostings,
|
filterTransactionRelatedPostings,
|
||||||
filterPostingAmount,
|
filterPostingAmount,
|
||||||
-- * Mapping
|
-- * Mapping
|
||||||
|
|||||||
@ -153,7 +153,7 @@ accountTransactionsReport rspec@ReportSpec{_rsReportOpts=ropts} j thisacctq = it
|
|||||||
datelessreportq = filterQuery (not . queryIsDateOrDate2) reportq
|
datelessreportq = filterQuery (not . queryIsDateOrDate2) reportq
|
||||||
|
|
||||||
items =
|
items =
|
||||||
accountTransactionsReportItems reportq thisacctq startbal maNegate
|
accountTransactionsReportItems reportq thisacctq startbal maNegate (journalAccountType j)
|
||||||
-- sort by the transaction's register date, then index, for accurate starting balance
|
-- sort by the transaction's register date, then index, for accurate starting balance
|
||||||
. ptraceAtWith 5 (("ts4:\n"++).pshowTransactions.map snd)
|
. ptraceAtWith 5 (("ts4:\n"++).pshowTransactions.map snd)
|
||||||
. sortBy (comparing (Down . fst) <> comparing (Down . tindex . snd))
|
. sortBy (comparing (Down . fst) <> comparing (Down . tindex . snd))
|
||||||
@ -171,19 +171,21 @@ pshowTransactions = pshow . map (\t -> unwords [show $ tdate t, T.unpack $ tdesc
|
|||||||
-- in the report. This is not necessarily the transaction date - see
|
-- in the report. This is not necessarily the transaction date - see
|
||||||
-- transactionRegisterDate.
|
-- transactionRegisterDate.
|
||||||
accountTransactionsReportItems :: Query -> Query -> MixedAmount -> (MixedAmount -> MixedAmount)
|
accountTransactionsReportItems :: Query -> Query -> MixedAmount -> (MixedAmount -> MixedAmount)
|
||||||
-> [(Day, Transaction)] -> [AccountTransactionsReportItem]
|
-> (AccountName -> Maybe AccountType) -> [(Day, Transaction)]
|
||||||
accountTransactionsReportItems reportq thisacctq bal signfn =
|
-> [AccountTransactionsReportItem]
|
||||||
catMaybes . snd . mapAccumR (accountTransactionsReportItem reportq thisacctq signfn) bal
|
accountTransactionsReportItems reportq thisacctq bal signfn accttypefn =
|
||||||
|
catMaybes . snd . mapAccumR (accountTransactionsReportItem reportq thisacctq signfn accttypefn) bal
|
||||||
|
|
||||||
accountTransactionsReportItem :: Query -> Query -> (MixedAmount -> MixedAmount) -> MixedAmount
|
accountTransactionsReportItem :: Query -> Query -> (MixedAmount -> MixedAmount)
|
||||||
-> (Day, Transaction) -> (MixedAmount, Maybe AccountTransactionsReportItem)
|
-> (AccountName -> Maybe AccountType) -> MixedAmount -> (Day, Transaction)
|
||||||
accountTransactionsReportItem reportq thisacctq signfn bal (d, torig)
|
-> (MixedAmount, Maybe AccountTransactionsReportItem)
|
||||||
|
accountTransactionsReportItem reportq thisacctq signfn accttypefn bal (d, torig)
|
||||||
-- 201407: I've lost my grip on this, let's just hope for the best
|
-- 201407: I've lost my grip on this, let's just hope for the best
|
||||||
-- 201606: we now calculate change and balance from filtered postings, check this still works well for all callers XXX
|
-- 201606: we now calculate change and balance from filtered postings, check this still works well for all callers XXX
|
||||||
| null reportps = (bal, Nothing) -- no matched postings in this transaction, skip it
|
| null reportps = (bal, Nothing) -- no matched postings in this transaction, skip it
|
||||||
| otherwise = (b, Just (torig, tacct{tdate=d}, numotheraccts > 1, otheracctstr, a, b))
|
| otherwise = (b, Just (torig, tacct{tdate=d}, numotheraccts > 1, otheracctstr, a, b))
|
||||||
where
|
where
|
||||||
tacct@Transaction{tpostings=reportps} = filterTransactionPostings reportq torig -- TODO needs to consider --date2, #1731
|
tacct@Transaction{tpostings=reportps} = filterTransactionPostingsExtra accttypefn reportq torig -- TODO needs to consider --date2, #1731
|
||||||
(thisacctps, otheracctps) = partition (matchesPosting thisacctq) reportps
|
(thisacctps, otheracctps) = partition (matchesPosting thisacctq) reportps
|
||||||
numotheraccts = length $ nub $ map paccount otheracctps
|
numotheraccts = length $ nub $ map paccount otheracctps
|
||||||
otheracctstr | thisacctq == None = summarisePostingAccounts reportps -- no current account ? summarise all matched postings
|
otheracctstr | thisacctq == None = summarisePostingAccounts reportps -- no current account ? summarise all matched postings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user