From 63b939a201217fa1293d6187736da92b0dc378dc Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 29 Jan 2025 09:42:26 -1000 Subject: [PATCH] imp:print: --invert now also negates balance assertion/assignment amounts [#2314] --- hledger-lib/Hledger/Data/Transaction.hs | 4 ++-- hledger/test/print/print.test | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/hledger-lib/Hledger/Data/Transaction.hs b/hledger-lib/Hledger/Data/Transaction.hs index a937021f4..65b2b51aa 100644 --- a/hledger-lib/Hledger/Data/Transaction.hs +++ b/hledger-lib/Hledger/Data/Transaction.hs @@ -483,9 +483,9 @@ transactionMapPostingAmounts f = transactionMapPostings (postingTransformAmount transactionAmounts :: Transaction -> [MixedAmount] transactionAmounts = map pamount . tpostings --- | Flip the sign of this transaction's posting amounts. +-- | Flip the sign of this transaction's posting amounts (and balance assertion amounts). transactionNegate :: Transaction -> Transaction -transactionNegate = transactionMapPostingAmounts negate +transactionNegate = transactionMapPostings postingNegate -- | The file path from which this transaction was parsed. transactionFile :: Transaction -> FilePath diff --git a/hledger/test/print/print.test b/hledger/test/print/print.test index 0ef75c301..c9cece0d9 100644 --- a/hledger/test/print/print.test +++ b/hledger/test/print/print.test @@ -39,20 +39,18 @@ $ hledger -f- print --depth 1 >= -# ** 4. print --invert flips signs. +# ** 4. print --invert flips signs in postings' main and assertion/assignment amounts. < 2025-01-01 - a 1 A @ 2 B - b - c 0 C + a 1 A @ 2 B = 1 A @ 2 B + b = -2 B + c 0 C = 0 $ hledger -f- print --invert -x 2025-01-01 - a -1 A @ 2 B - b 2 B - c 0 C + a -1 A @ 2 B = -1 A @ 2 B + b 2 B = 2 B + c 0 C = 0 >= - -