Update customer.rb

This commit is contained in:
2016-04-29 08:38:15 -04:00
parent 9750ef2f3b
commit 916a9bdb70

View File

@@ -24,8 +24,10 @@ class Customer < ActiveRecord::Base
# returns true if the customer is active
def active?
mutex.synchronize do
return @details.active? if @details
end
end
# returns a human readable string
def to_s
@@ -35,7 +37,9 @@ class Customer < ActiveRecord::Base
# returns the customer's email
def email
begin
mutex.synchronize do
return @details.email_address.address
end
rescue
return nil
end
@@ -44,7 +48,9 @@ class Customer < ActiveRecord::Base
# returns the customer's primary phone
def primary_phone
begin
mutex.synchronize do
return @details.primary_phone.free_form_number
end
rescue
return nil
end
@@ -53,7 +59,9 @@ class Customer < ActiveRecord::Base
# returns the customer's mobile phone
def mobile_phone
begin
mutex.synchronize do
return @details.mobile_phone.free_form_number
end
rescue
return nil
end
@@ -61,8 +69,10 @@ class Customer < ActiveRecord::Base
# returns the customer's notes
def notes
mutex.synchronize do
return @details.notes if @details
end
end
# updates the customer's notes in QBO
def notes=(s)
@@ -119,10 +129,12 @@ class Customer < ActiveRecord::Base
# update's the customers name if updated
def update
begin
mutex.synchronize do
if not self.name == @detils.display_name
self.name = @details.display_name
self.save
end
}
rescue
return nil
end