diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 54e19ef23..134011568 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -327,13 +327,13 @@ journalFinalise iopts@InputOpts{..} f txt pj = do & journalStyleAmounts -- Infer and apply commodity styles (but don't round) - should be done early <&> journalAddForecast (verbose_tags_) (forecastPeriod iopts pj) -- Add forecast transactions if enabled <&> journalPostingsAddAccountTags -- Add account tags to postings, so they can be matched by auto postings. + >>= journalMarkRedundantCosts -- Mark redundant costs, to help journalBalanceTransactions ignore them >>= (if auto_ && not (null $ jtxnmodifiers pj) - then journalAddAutoPostings verbose_tags_ _ioDay balancingopts_ -- Add auto postings if enabled, and account tags if needed + then journalAddAutoPostings verbose_tags_ _ioDay balancingopts_ -- Add auto postings if enabled, and account tags if needed. Does preliminary transaction balancing. else pure) -- XXX how to force debug output here ? -- >>= Right . dbg0With (concatMap (T.unpack.showTransaction).jtxns) -- >>= \j -> deepseq (concatMap (T.unpack.showTransaction).jtxns $ j) (return j) - >>= journalMarkRedundantCosts -- Mark redundant costs, to help journalBalanceTransactions ignore them >>= journalBalanceTransactions balancingopts_ -- infer balance assignments and missing amounts and maybe check balance assertions. >>= journalInferCommodityStyles -- infer commodity styles once more now that all posting amounts are present (XXX or journalStyleAmounts ?) -- >>= Right . dbg0With (pshow.journalCommodityStyles) diff --git a/hledger/test/journal/auto-postings.test b/hledger/test/journal/auto-postings.test index 919965b15..4746ebaeb 100644 --- a/hledger/test/journal/auto-postings.test +++ b/hledger/test/journal/auto-postings.test @@ -411,3 +411,16 @@ $ hledger -f- print --forecast --auto --explicit (Auto) 10 >=0 + +# ** 21. Redundant costs are still detected properly with --auto. (#2110) +< +2023-01-01 + assets:shares 1 TEST @ 50.00€ + equity:conversion -1 TEST + equity:conversion 50.00€ + equity:opening -50.00€ + += foo + a 1 + +$ hledger -f- --auto check