1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 05:25:24 +02:00

Account Sync should happen at login, 1x per day, OR on-demand (#594)

* Add last_sync_date to accounts table

* Always sync Account after Valuation or Transaction creation, update, or deletion.

Skip sync if user clicks "sync" button without changing anything

* Sync user accounts daily based on last_login_at
This commit is contained in:
Mattia 2024-04-04 23:00:12 +02:00 committed by GitHub
parent 4f0b2de4ef
commit 315c4bf1ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 48 additions and 8 deletions

View file

@ -43,4 +43,8 @@ class Family < ApplicationRecord
def liabilities
Money.new(accounts.active.liabilities.map { |account| account.balance_money.exchange_to(currency) || 0 }.sum, currency)
end
def sync_accounts
accounts.each { |account| account.sync_later if account.can_sync? }
end
end