mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-03 08:41:58 -04:00
refactor(sync): improve attribute mapping to support dynamic fields and custom transformations
This commit is contained in:
@@ -17,16 +17,13 @@ class CustomerSyncService < SyncServiceBase
|
||||
Customer
|
||||
end
|
||||
|
||||
# Determine if the remote entity should be deleted locally (e.g. if it's marked inactive in QBO)
|
||||
def destroy_remote?(remote)
|
||||
# Determine if the local entity should be deleted (e.g. if it's marked inactive in QBO)
|
||||
def destroy_local?(remote)
|
||||
!remote.active?
|
||||
end
|
||||
|
||||
# Map relevant attributes from the QBO Customer to the local Customer model
|
||||
def process_attributes(local, remote)
|
||||
local.name = remote.display_name
|
||||
local.phone_number = remote.primary_phone&.free_form_number&.gsub(/\D/, '')
|
||||
local.mobile_phone_number = remote.mobile_phone&.free_form_number&.gsub(/\D/, '')
|
||||
end
|
||||
map_attribute :name, ->(remote) { remote.display_name }
|
||||
map_attribute :phone_number, ->(remote) { remote.primary_phone&.free_form_number&.gsub(/\D/, '') }
|
||||
map_attribute :mobile_phone_number, ->(remote) { remote.mobile_phone&.free_form_number&.gsub(/\D/, '') }
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user