imp:print: --invert now also negates balance assertion/assignment amounts [#2314]

This commit is contained in:
Simon Michael 2025-01-29 09:42:26 -10:00
parent bbb06209e7
commit 63b939a201
2 changed files with 9 additions and 11 deletions

View File

@ -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

View File

@ -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
>=