From 1cfcb7fa761b65d53323b4471191f0f6d6e1ddf7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 4 Jul 2023 13:21:55 -1000 Subject: [PATCH] ;cln: journalAddInferredEquityPostings -> journalInferEquityFromCosts --- hledger-lib/Hledger/Data/Journal.hs | 11 ++++++----- hledger-lib/Hledger/Read/Common.hs | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 3183d0c34..e978e7c1d 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -26,7 +26,7 @@ module Hledger.Data.Journal ( commodityStylesFromAmounts, journalCommodityStyles, journalToCost, - journalAddInferredEquityPostings, + journalInferEquityFromCosts, journalInferCostsFromEquity, journalMarkRedundantCosts, journalReverse, @@ -915,14 +915,15 @@ journalToCost cost j@Journal{jtxns=ts} = j{jtxns=map (transactionToCost styles c where styles = journalCommodityStyles j --- | Add inferred equity postings to a 'Journal' using transaction prices. -journalAddInferredEquityPostings :: Bool -> Journal -> Journal -journalAddInferredEquityPostings verbosetags j = journalMapTransactions (transactionAddInferredEquityPostings verbosetags equityAcct) j +-- | Add equity postings inferred from costs, where needed and possible. +-- See hledger manual > Cost reporting. +journalInferEquityFromCosts :: Bool -> Journal -> Journal +journalInferEquityFromCosts verbosetags j = journalMapTransactions (transactionAddInferredEquityPostings verbosetags equityAcct) j where equityAcct = journalConversionAccount j -- | Add costs inferred from equity conversion postings, where needed and possible. --- See hledger manual > Inferring cost from equity postings. +-- See hledger manual > Cost reporting. journalInferCostsFromEquity :: Journal -> Either String Journal journalInferCostsFromEquity j = do ts <- mapM (transactionInferCostsFromEquity False $ jaccounttypes j) $ jtxns j diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 851b42723..c55103d2a 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -334,7 +334,7 @@ journalFinalise iopts@InputOpts{..} f txt pj = do >>= journalMarkRedundantCosts -- Mark redundant costs, to help journalBalanceTransactions ignore them >>= journalBalanceTransactions balancingopts_ -- Balance all transactions and maybe check balance assertions. >>= (if infer_costs_ then journalInferCostsFromEquity else pure) -- Maybe infer costs from equity postings where possible - <&> (if infer_equity_ then journalAddInferredEquityPostings verbose_tags_ else id) -- Maybe infer equity postings from costs where possible + <&> (if infer_equity_ then journalInferEquityFromCosts verbose_tags_ else id) -- Maybe infer equity postings from costs where possible <&> journalInferMarketPricesFromTransactions -- infer market prices from commodity-exchanging transactions <&> traceOrLogAt 6 ("journalFinalise: " <> takeFileName f) -- debug logging <&> dbgJournalAcctDeclOrder ("journalFinalise: " <> takeFileName f <> " acct decls : ")