@@ -44,7 +44,6 @@ module Hledger.Data.Journal (
4444 journalPostingsAddAccountTags ,
4545 journalPostingsKeepAccountTagsOnly ,
4646 journalPostingsAddCommodityTags ,
47- journalInferPostingsCostBasis ,
4847 journalInferPostingsTransactedCost ,
4948 journalCommodityUsesLots ,
5049 journalCommodityLotsMethod ,
@@ -157,7 +156,7 @@ import Data.List (foldl')
157156#endif
158157import Data.List.Extra (nubSort )
159158import Data.Map.Strict qualified as M
160- import Data.Maybe (catMaybes , fromMaybe , isJust , isNothing , mapMaybe , maybeToList )
159+ import Data.Maybe (catMaybes , fromMaybe , isNothing , mapMaybe , maybeToList )
161160import Data.Ord (comparing )
162161import Data.Set qualified as S
163162import Data.Text (Text )
@@ -716,10 +715,6 @@ journalCommodityTags Journal{jdeclaredcommoditytags} c =
716715journalCommodityUsesLots :: Journal -> CommoditySymbol -> Bool
717716journalCommodityUsesLots j c = any ((== " lots" ) . T. toLower . fst ) (journalCommodityTags j c)
718717
719- -- | Does this posting have a 'lots:' tag (eg inherited from its account) ?
720- postingUsesLots :: Posting -> Bool
721- postingUsesLots p = any ((== " lots" ) . T. toLower . fst ) (ptags p)
722-
723718-- | Get the reduction method from a commodity's lots: tag value, if any.
724719journalCommodityLotsMethod :: Journal -> CommoditySymbol -> Maybe ReductionMethod
725720journalCommodityLotsMethod j c =
@@ -795,32 +790,6 @@ journalPostingsAddCommodityTags j = journalMapPostings addtags j
795790 where
796791 addtags p = p `postingAddTags` concatMap (journalCommodityTags j) (postingCommodities p)
797792
798- -- | For acquire postings (positive amounts) whose commodity or account has a 'lots:' tag,
799- -- infer cost basis (cost only, no date or label) from transacted cost.
800- -- The lot date will later default to the transaction date.
801- -- Must be called before journalClassifyLotPostings.
802- journalInferPostingsCostBasis :: Journal -> Journal
803- journalInferPostingsCostBasis j = journalMapPostings (postingInferCostBasis j) j
804-
805- postingInferCostBasis :: Journal -> Posting -> Posting
806- postingInferCostBasis j p = p{pamount = mapMixedAmount amountInferCostBasis $ pamount p}
807- where
808- amountInferCostBasis :: Amount -> Amount
809- amountInferCostBasis a
810- | aquantity a <= 0 = a -- only positive (acquire) amounts
811- | isJust (acostbasis a) = a -- already has cost basis
812- | Nothing <- acost a = a -- no transacted cost
813- | not (journalCommodityUsesLots j (acommodity a) || postingUsesLots p) = a -- commodity/account not lot-tracked
814- | Just cost <- acost a = a{acostbasis = Just (costToCostBasis (aquantity a) cost)}
815-
816- costToCostBasis :: Quantity -> AmountCost -> CostBasis
817- costToCostBasis qty cost = CostBasis {cbCost= Just ucost, cbDate= Nothing , cbLabel= Nothing }
818- where
819- ucost = case cost of
820- UnitCost amt -> amt
821- TotalCost amt | qty /= 0 -> divideAmountAndCapPrecision (abs qty) amt
822- | otherwise -> amt
823-
824793-- | For positive postings with a cost basis, which are not lot transfers,
825794-- infer transacted cost from cost basis.
826795-- Must be called after journalClassifyLotPostings so ptype tags are available.
0 commit comments