mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Harden SimpleFIN sync: protect user data, fix stuck syncs, optimize API calls (#671)
* Implement entry protection flags for sync overwrites - Added `user_modified` and `import_locked` flags to `entries` table to prevent provider sync from overwriting user-edited and imported data. - Introduced backfill migration to mark existing entries based on conditions. - Enhanced sync and processing logic to respect protection flags, track skipped entries, and log detailed stats. - Updated UI to display skipped/protected entries and reasons in sync summaries. * Localize error details summary text and adjust `sync_account_later` method placement * Restored schema.rb --------- Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
This commit is contained in:
@@ -3,9 +3,11 @@ require "digest/md5"
|
||||
class SimplefinEntry::Processor
|
||||
include CurrencyNormalizable
|
||||
# simplefin_transaction is the raw hash fetched from SimpleFin API and converted to JSONB
|
||||
def initialize(simplefin_transaction, simplefin_account:)
|
||||
# @param import_adapter [Account::ProviderImportAdapter, nil] Optional shared adapter for accumulating skipped entries
|
||||
def initialize(simplefin_transaction, simplefin_account:, import_adapter: nil)
|
||||
@simplefin_transaction = simplefin_transaction
|
||||
@simplefin_account = simplefin_account
|
||||
@shared_import_adapter = import_adapter
|
||||
end
|
||||
|
||||
def process
|
||||
@@ -76,7 +78,8 @@ class SimplefinEntry::Processor
|
||||
end
|
||||
|
||||
def import_adapter
|
||||
@import_adapter ||= Account::ProviderImportAdapter.new(account)
|
||||
# Use shared adapter if provided, otherwise create new one
|
||||
@import_adapter ||= @shared_import_adapter || Account::ProviderImportAdapter.new(account)
|
||||
end
|
||||
|
||||
def account
|
||||
|
||||
Reference in New Issue
Block a user