Update customer.rb

This commit is contained in:
2016-05-17 07:06:22 -04:00
parent 798aea6a8b
commit 4ec8ceca1b

View File

@@ -105,25 +105,15 @@ class Customer < ActiveRecord::Base
customers = Qbo.get_base(:customer).service.query()
transaction do
# Update the customer table
customers.each { |customer|
background do
Customer.without_callback(:initialize, :after, :pull) do
Customer.without_callback(:save, :before, :push) do
qbo_customer = Customer.find_or_create_by(id: customer.id)
# only update if diffrent
if qbo_customer.new_record?
qbo_customer.name = customer.display_name
qbo_customer.id = customer.id
qbo_customer.save!
end
end
end
qbo_customer.update_column(:name, customer.display_name)
qbo_customer.update_column(:id, customer.id)
qbo_customer.save
end
}
end
# remove deleted customers
#where.not(customers.map(&:id)).destroy_all