From d101c24b856c42e5613cf1d5a52e89a45273aecf Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 7 Feb 2024 15:01:48 +0100 Subject: [PATCH] Fix: Paired transactions must be updated with negative sum Signed-off-by: Knut Ahlers --- pkg/database/database.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/database/database.go b/pkg/database/database.go index bf4b92d..dcebb5e 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -500,7 +500,8 @@ func (c *Client) UpdateTransaction(txID uuid.UUID, tx Transaction) (err error) { if err = db.Model(&Transaction{}). Where("pair_key = ?", oldTX.PairKey.UUID). - Update("amount", tx.Amount). + Where("id <> ?", oldTX.ID). + Update("amount", -tx.Amount). Error; err != nil { return fmt.Errorf("updating amount for paired transaction: %w", err) }