You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def self.same_as_caller(job)
caller = job.caller
return if caller.nil?
# check if old customer exists
if job.customer_id
# FIXME: it's not a good idea to destroy object from database. Maybe just inactive?
Customer.find_by(id: job.customer_id).destroy
end
caller_phones = caller.phones
caller_address = Address.find_by(id: caller.address_id)
customer = Customer.new(first_name: caller.first_name, last_name: caller.last_name, email: caller.email)
customer.address = Address.new(address_1: caller_address.address_1, address_2: caller_address.address_2, zip_code: caller_address.zip_code, city: caller_address.city, county: caller_address.county, state_id: caller_address.state_id) if caller_address.present?
job.customer = customer
caller_phones.each do |phone|
customer.phones.build(number: phone.number, extension: phone.extension, type_id: phone.type_id)
end
job.save
end
No description provided.
The text was updated successfully, but these errors were encountered: