From 6a41ed9e647984fe5010ba50f8461d13a8f9694a Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 6 Dec 2023 17:55:38 -1000 Subject: [PATCH] imp: drop the "a difference of ..." line from balance assertion errors Rationale: To satisfy the recentassertions check I'm often filling in a bunch of placeholder balance assertions, copy/pasting the correct amount from the balance assertion failure messages. In this situation the difference just repeats the amount in the line above, with opposite sign, which makes it harder for me to interpret the message and to copy-paste the right amount. And more generally I think showing the difference isn't really necessary. --- hledger-lib/Hledger/Data/Balancing.hs | 3 +-- hledger/test/errors/README.md | 1 - hledger/test/errors/assertions.test | 1 - hledger/test/journal/balance-assertions.test | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hledger-lib/Hledger/Data/Balancing.hs b/hledger-lib/Hledger/Data/Balancing.hs index bc5e28d72..19dc9dae2 100644 --- a/hledger-lib/Hledger/Data/Balancing.hs +++ b/hledger-lib/Hledger/Data/Balancing.hs @@ -664,7 +664,6 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt -- "display precision: %d", "this balance was asserted: %s", -- (at display precision: %s)", "but the calculated balance is: %s", -- (at display precision: %s)", - "a difference of: %s", "", "To troubleshoot, you can view this account's running balance. Eg:", "", @@ -680,7 +679,7 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt -- (showAmount assertedamt) (show $ aquantity actualbalincomm) -- (showAmount actualbalincommodity) - (show $ aquantity assertedamt - aquantity actualbalincomm) + -- (show $ aquantity assertedamt - aquantity actualbalincomm) (acct ++ if isinclusive then "" else "$") (if istotal then "" else (" cur:" ++ quoteForCommandLine (T.unpack assertedcomm))) where diff --git a/hledger/test/errors/README.md b/hledger/test/errors/README.md index 8c029cbe6..1e71430d0 100644 --- a/hledger/test/errors/README.md +++ b/hledger/test/errors/README.md @@ -186,7 +186,6 @@ In account: a and commodity: this balance was asserted: 1 but the calculated balance is: 0 -a difference of: 1 To troubleshoot, you can view this account's running balance. Eg: diff --git a/hledger/test/errors/assertions.test b/hledger/test/errors/assertions.test index 9cb6f4583..b9dc584a3 100644 --- a/hledger/test/errors/assertions.test +++ b/hledger/test/errors/assertions.test @@ -11,6 +11,5 @@ In account: a and commodity: this balance was asserted: 1 but the calculated balance is: 0 -a difference of: 1 / >= 1 diff --git a/hledger/test/journal/balance-assertions.test b/hledger/test/journal/balance-assertions.test index b3f6f9f37..6c232d537 100755 --- a/hledger/test/journal/balance-assertions.test +++ b/hledger/test/journal/balance-assertions.test @@ -398,7 +398,7 @@ commodity $1000.00 (a) $1.00 = $1.01 $ hledger -f- print ->2 /a difference of.*0\.004/ +>2 /balance assertion failed/ >=1 # ** 25. This fails @@ -412,7 +412,7 @@ commodity $1000.00 (a) $1.00 = $1.0061 $ hledger -f- print ->2 /a difference of.*0\.0001/ +>2 /balance assertion failed/ >=1 # ** 26. Inclusive assertions include balances from subaccounts.