dev: transactionInferCostsFromEquity: clarify partitionPs

This commit is contained in:
Simon Michael 2023-01-24 22:53:23 -10:00
parent 6d849e06f5
commit 9c5bcfea85

View File

@ -245,8 +245,10 @@ transactionInferCostsFromEquity dryrun acctTypes t = first (annotateErrorWithTra
npostings = zip [0..] $ tpostings t npostings = zip [0..] $ tpostings t
transformIndexedPostingsF f = evalStateT . fmap (appEndo . foldMap Endo) . traverse f transformIndexedPostingsF f = evalStateT . fmap (appEndo . foldMap Endo) . traverse f
-- Sort postings into pairs of conversion postings, costful postings, and other postings -- Sort posting numbers into three lists (stored in two pairs), like so:
-- (conversion postings, (costful postings, other postings)).
partitionPs = fmap fst . foldrM select (([], ([], [])), Nothing) partitionPs = fmap fst . foldrM select (([], ([], [])), Nothing)
where
select np@(_, p) ((cs, others@(ps, os)), Nothing) select np@(_, p) ((cs, others@(ps, os)), Nothing)
| isConversion p = Right ((cs, others), Just np) | isConversion p = Right ((cs, others), Just np)
| hasCost p = Right ((cs, (np:ps, os)), Nothing) | hasCost p = Right ((cs, (np:ps, os)), Nothing)