Fix: Paired transactions must be updated with negative sum

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-02-07 15:01:48 +01:00
parent e1de837967
commit d101c24b85
Signed by: luzifer
SSH key fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E

View file

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