From c31ec82e6127cd81db0807c8ca5df4ca351a4053 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 10 Aug 2026 15:20:14 -0400 Subject: [PATCH] Normalize customer name before saving and update QBO display name accordingly --- app/models/customer.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index 0cd0ce0..9323ef1 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -20,6 +20,9 @@ class Customer < QboBaseModel before_validation :normalize_phone_numbers self.primary_key = :id 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 ], scope: ->(_context) { left_joins(:project) }, @@ -61,8 +64,9 @@ class Customer < QboBaseModel # Updates Both local DB name & QBO display_name def name=(s) - details.display_name = s - super + super(s) + # Write the normalized value from Active Record to QBO details + details.display_name = self.name 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.