1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Only update account balance if changed (#1676)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Only update balance if changed

* Update test assertions
This commit is contained in:
Zach Gollwitzer 2025-01-23 21:14:01 -05:00 committed by GitHub
parent 61321f6b16
commit 43dd16e3fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -135,9 +135,11 @@ class Account < ApplicationRecord
end
def update_with_sync!(attributes)
should_update_balance = attributes[:balance] && attributes[:balance].to_d != balance
transaction do
update!(attributes)
update_balance!(attributes[:balance]) if attributes[:balance]
update_balance!(attributes[:balance]) if should_update_balance
end
sync_later