;cln: journalAddInferredEquityPostings -> journalInferEquityFromCosts

This commit is contained in:
Simon Michael 2023-07-04 13:21:55 -10:00
parent 4988179dac
commit 1cfcb7fa76
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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 : ")