mirror of
https://github.com/simonmichael/hledger.git
synced 2024-10-06 10:57:30 +03:00
dev: postingAddInferredEquityPostings: cleanup
This commit is contained in:
parent
4c7abc3d2f
commit
12e67e4859
@ -545,17 +545,17 @@ postingToCost ToCost p
|
||||
where
|
||||
nocosts = (not . any (isJust . acost) . amountsRaw) $ pamount p
|
||||
|
||||
-- | Generate inferred equity postings from a 'Posting' using transaction prices.
|
||||
-- Make sure not to generate equity postings when there are already matched
|
||||
-- conversion postings.
|
||||
-- | Generate inferred equity postings from a 'Posting''s costs.
|
||||
-- Make sure not to duplicate them when matching ones exist already.
|
||||
postingAddInferredEquityPostings :: Bool -> Text -> Posting -> [Posting]
|
||||
postingAddInferredEquityPostings verbosetags equityAcct p
|
||||
| "_price-matched" `elem` map fst (ptags p) = [p]
|
||||
| otherwise = taggedPosting : concatMap conversionPostings priceAmounts
|
||||
| otherwise = taggedPosting : concatMap conversionPostings costs
|
||||
where
|
||||
costs = filter (isJust . acost) . amountsRaw $ pamount p
|
||||
taggedPosting
|
||||
| null priceAmounts = p
|
||||
| otherwise = p{ ptags = ("_price-matched","") : ptags p }
|
||||
| null costs = p
|
||||
| otherwise = p{ ptags = ("_price-matched","") : ptags p }
|
||||
conversionPostings amt = case acost amt of
|
||||
Nothing -> []
|
||||
Just _ -> [ cp{ paccount = accountPrefix <> amtCommodity
|
||||
@ -581,8 +581,6 @@ postingAddInferredEquityPostings verbosetags equityAcct p
|
||||
-- Take the commodity of an amount and collapse consecutive spaces to a single space
|
||||
commodity = T.unwords . filter (not . T.null) . T.words . acommodity
|
||||
|
||||
priceAmounts = filter (isJust . acost) . amountsRaw $ pamount p
|
||||
|
||||
-- | Make a market price equivalent to this posting's amount's unit
|
||||
-- price, if any.
|
||||
postingPriceDirectivesFromCost :: Posting -> [PriceDirective]
|
||||
|
Loading…
Reference in New Issue
Block a user