mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-08-19 04:40:44 -04:00
Normalize customer name before saving and update QBO display name accordingly
This commit is contained in:
@@ -21,6 +21,9 @@ class Customer < QboBaseModel
|
|||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
qbo_sync push: true
|
qbo_sync push: true
|
||||||
|
|
||||||
|
# Normalize the local database column :name
|
||||||
|
normalizes :name, with: ->(name) { name.to_s.strip.titleize }
|
||||||
|
|
||||||
acts_as_searchable columns: %w[name phone_number mobile_phone_number ],
|
acts_as_searchable columns: %w[name phone_number mobile_phone_number ],
|
||||||
scope: ->(_context) { left_joins(:project) },
|
scope: ->(_context) { left_joins(:project) },
|
||||||
date_column: :updated_at
|
date_column: :updated_at
|
||||||
@@ -61,8 +64,9 @@ class Customer < QboBaseModel
|
|||||||
|
|
||||||
# Updates Both local DB name & QBO display_name
|
# Updates Both local DB name & QBO display_name
|
||||||
def name=(s)
|
def name=(s)
|
||||||
details.display_name = s
|
super(s)
|
||||||
super
|
# Write the normalized value from Active Record to QBO details
|
||||||
|
details.display_name = self.name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Normalizes phone numbers by removing non-digit characters. This method is called before validation to ensure that phone numbers are stored in a consistent format, which can help with searching and integration with external systems like QuickBooks Online.
|
# Normalizes phone numbers by removing non-digit characters. This method is called before validation to ensure that phone numbers are stored in a consistent format, which can help with searching and integration with external systems like QuickBooks Online.
|
||||||
|
|||||||
Reference in New Issue
Block a user