Update customer.rb

This commit is contained in:
2016-08-05 08:46:48 -04:00
committed by GitHub
parent 7237d2e643
commit 33db0a53ba

View File

@@ -142,18 +142,18 @@ class Customer < ActiveRecord::Base
# Searchs the database for a customer by name
def self.search(search)
customers = where("name LIKE ?", "%#{search}%").order(:name)
customers = where("name LIKE ?", "%#{search}%")
if customers.empty?
service = Qbo.get_base(:customer).service
results = service.query("Select Id From Customer Where ((PrimaryPhone LIKE '%#{search}%') OR (Mobile LIKE '%#{search}%') Order By DisplayName")
results = service.query("Select Id From Customer Where PrimaryPhone LIKE '%#{search}%' OR Mobile LIKE '%#{search}%'")
results.each do |customer|
customers << Customer.find_by_id(customer.id)
end
end
return customers
return customers.order(:name)
end
# proforms a bruteforce sync operation