From 1ee0e8071959a436b097d01897e8771ebf8215f6 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 29 Feb 2024 12:32:23 -1000 Subject: [PATCH] imp:errors:unbalanced transaction: show more precise amounts (#2135) Like we used to in 1.30, but better (show all available decimal digits, unless they're infinite in which case show 8, show trailing zeros, show commodity symbol with zero). --- hledger-lib/Hledger/Data/Balancing.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Data/Balancing.hs b/hledger-lib/Hledger/Data/Balancing.hs index 031a6e888..5f3c9767c 100644 --- a/hledger-lib/Hledger/Data/Balancing.hs +++ b/hledger-lib/Hledger/Data/Balancing.hs @@ -131,11 +131,17 @@ transactionCheckBalanced BalancingOpts{commodity_styles_} t = errs rmsg | rsumok = "" | not rsignsok = "The real postings all have the same sign. Consider negating some of them." - | otherwise = "The real postings' sum should be 0 but is: " ++ showMixedAmountOneLineWithoutCost False rsumcost + | otherwise = "The real postings' sum should be 0 but is: " ++ + (showMixedAmountWith oneLineNoCostFmt{displayCost=True, displayZeroCommodity=True} $ + mixedAmountSetFullPrecisionUpTo Nothing $ mixedAmountSetFullPrecision + rsumcost) bvmsg | bvsumok = "" | not bvsignsok = "The balanced virtual postings all have the same sign. Consider negating some of them." - | otherwise = "The balanced virtual postings' sum should be 0 but is: " ++ showMixedAmountOneLineWithoutCost False bvsumcost + | otherwise = "The balanced virtual postings' sum should be 0 but is: " ++ + (showMixedAmountWith oneLineNoCostFmt{displayCost=True, displayZeroCommodity=True} $ + mixedAmountSetFullPrecisionUpTo Nothing $ mixedAmountSetFullPrecision + bvsumcost) -- | Legacy form of transactionCheckBalanced. isTransactionBalanced :: BalancingOpts -> Transaction -> Bool