fix: balance-assigned amounts affect styles again (fix #2091)

This commit is contained in:
Simon Michael 2023-10-14 08:34:46 +01:00
parent dadb904b04
commit e8da1f9f25
3 changed files with 15 additions and 2 deletions

View File

@ -22,6 +22,7 @@ module Hledger.Data.Journal (
addPeriodicTransaction,
addTransaction,
journalInferMarketPricesFromTransactions,
journalInferCommodityStyles,
journalApplyCommodityStyles,
commodityStylesFromAmounts,
journalCommodityStyles,

View File

@ -332,7 +332,9 @@ journalFinalise iopts@InputOpts{..} f txt pj = do
-- >>= 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_ -- Balance all transactions and maybe check balance assertions.
>>= 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 journalApplyCommodityStyles ?)
-- >>= Right . dbg0With (pshow.journalCommodityStyles)
>>= (if infer_costs_ then journalInferCostsFromEquity else pure) -- Maybe infer costs from equity postings 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

View File

@ -121,7 +121,7 @@ $ hledger -f- print --explicit
>= 0
## 8. Here the price should be displayed with precision 7
# 8. Here the price should be displayed with precision 7
# (E's precision 4 + F's precision 3).
<
2015/1/1
@ -135,3 +135,13 @@ $ hledger -f- print --explicit
f F -320.000
>= 0
# 9. Posting amounts inferred from balance assignments also affect commodity styles. (#2091)
<
2023-01-01
(a) 1 A
2023-01-02
(a) = 2.2 A
$ hledger -f- reg
2023-01-01 (a) 1.0 A 1.0 A
2023-01-02 (a) 1.2 A 2.2 A