mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-10 01:44:23 -05:00
Update customer.rb
This commit is contained in:
@@ -85,6 +85,8 @@ class Customer < ActiveRecord::Base
|
|||||||
pn = Quickbooks::Model::TelephoneNumber.new
|
pn = Quickbooks::Model::TelephoneNumber.new
|
||||||
pn.free_form_number = n
|
pn.free_form_number = n
|
||||||
@details.mobile_phone = pn
|
@details.mobile_phone = pn
|
||||||
|
#update our locally stored number too
|
||||||
|
update_mobile_phone_number
|
||||||
end
|
end
|
||||||
|
|
||||||
# update the localy stored phone number as a plain string with no special chars
|
# update the localy stored phone number as a plain string with no special chars
|
||||||
@@ -96,6 +98,15 @@ class Customer < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# update the localy stored phone number as a plain string with no special chars
|
||||||
|
def update_mobile_phone_number
|
||||||
|
begin
|
||||||
|
self.mobile_phone_number = self.mobile_phone.tr('^0-9', '')
|
||||||
|
rescue
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Convenience Method
|
# Convenience Method
|
||||||
# Updates Both local DB name & QBO display_name
|
# Updates Both local DB name & QBO display_name
|
||||||
def name=(s)
|
def name=(s)
|
||||||
@@ -155,7 +166,7 @@ class Customer < ActiveRecord::Base
|
|||||||
|
|
||||||
# Searchs the database for a customer by name or phone number with out special chars
|
# Searchs the database for a customer by name or phone number with out special chars
|
||||||
def self.search(search)
|
def self.search(search)
|
||||||
customers = where("name LIKE ? OR phone_number LIKE ?", "%#{search}%", "%#{search}%")
|
customers = where("name LIKE ? OR phone_number LIKE ? OR mobile_phone_number LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%")
|
||||||
return customers.order(:name)
|
return customers.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user