Update customer.rb

This commit is contained in:
2016-05-24 06:50:08 -04:00
parent d0adb4ed4e
commit 948c5d0146

View File

@@ -107,16 +107,18 @@ class Customer < ActiveRecord::Base
query = "Select Id, DisplayName From Customer"
query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last
query << " Order By DisplayName "
#query << " Order By DisplayName "
without_callback(:save, :before, :save) do
Qbo.get_base(:customer).service.query_in_batches(query, per_page: 100) do |batch|
batch.each do |customer|
# Update the customer table
qbo_customer = Customer.find_or_create_by(id: customer.id)
qbo_customer.name = customer.display_name
qbo_customer.id = customer.id
qbo_customer.save
Customer.transaction do
# Update the customer table
qbo_customer = Customer.find_or_create_by(id: customer.id)
qbo_customer.name = customer.display_name
qbo_customer.id = customer.id
qbo_customer.save
end
end
end
end
@@ -144,6 +146,7 @@ class Customer < ActiveRecord::Base
def pull
begin
#tries ||= 3
raise Exception if self.id
@details = Qbo.get_base(:customer).find_by_id(self.id)
rescue
#retry unless (tries -= 1).zero?