From d3ad743b36fc0ff161c677d1a3dcf8ae1662c766 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 25 Feb 2024 16:47:58 -1000 Subject: [PATCH] imp: print, close: disambiguate balance assertion/assignment amount also (#2176) Add a trailing decimal mark when necessary to disambiguate a single digit group mark in the balance assertion/assignment amount, also. --- hledger-lib/Hledger/Data/Posting.hs | 2 +- hledger/test/close.test | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index 64e80d3de..fb9cfed76 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -188,7 +188,7 @@ balassertTotInc amt = Just $ nullassertion{baamount=amt, batotal=True, bainclusi -- | Render a balance assertion, as the =[=][*] symbol and expected amount. showBalanceAssertion :: BalanceAssertion -> WideBuilder showBalanceAssertion ba = - singleton '=' <> eq <> ast <> singleton ' ' <> showAmountB def{displayZeroCommodity=True} (baamount ba) + singleton '=' <> eq <> ast <> singleton ' ' <> showAmountB def{displayZeroCommodity=True, displayForceDecimalMark=True} (baamount ba) where eq = if batotal ba then singleton '=' else mempty ast = if bainclusive ba then singleton '*' else mempty diff --git a/hledger/test/close.test b/hledger/test/close.test index 681f81619..1591b1b19 100644 --- a/hledger/test/close.test +++ b/hledger/test/close.test @@ -234,7 +234,28 @@ $ hledger -f- close > /999999-12-31 closing balances/ >= -# ** 15. "override the closing date ... by specifying a report period, where last day of the report period will be the closing date" +# ** 16. "override the closing date ... by specifying a report period, where last day of the report period will be the closing date" $ hledger -f- close -e 100000-01-01 > /99999-12-31 closing balances/ >= + +# ** 17. Not specific to close, but easy to reproduce with it: trailing decimal marks should be added +# in balance assertion/assignment amounts also, like posting amounts. (#2076) +< +2000-01-01 + (assets:a) $1,000.00 + (assets:b) $1000 + +$ hledger -f- close --migrate -e 2001 +2000-12-31 closing balances ; start: + assets:a $-1,000.00 = $0.00 + assets:b $-1,000. = $0 + equity:opening/closing balances + +2001-01-01 opening balances ; start: + assets:a $1,000.00 = $1,000.00 + assets:b $1,000. = $1,000. + equity:opening/closing balances + +>= +