Update customer.rb

This commit is contained in:
2016-05-17 13:46:25 -04:00
parent 2995060ec6
commit 4ac76a62a2

View File

@@ -106,12 +106,11 @@ class Customer < ActiveRecord::Base
last = Qbo.first.last_sync last = Qbo.first.last_sync
query = "Select Id, DisplayName From Customer" query = "Select Id, DisplayName From Customer"
query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last #query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last
query << " Order By DisplayName " query << " Order By DisplayName "
#without_callback(:save, :before, :save) do without_callback(:save, :before, :save) do
#customers = Qbo.get_base(:customer).service.query_in_batches(query, per_page: 100) do |batch| Qbo.get_base(:customer).service.query_in_batches(query, per_page: 100) do |batch|
batch = Qbo.get_base(:customer).service.all
batch.each do |customer| batch.each do |customer|
# Update the customer table # Update the customer table
qbo_customer = Customer.find_or_create_by(id: customer.id) qbo_customer = Customer.find_or_create_by(id: customer.id)
@@ -119,8 +118,8 @@ class Customer < ActiveRecord::Base
qbo_customer.id = customer.id qbo_customer.id = customer.id
qbo_customer.save qbo_customer.save
end end
#end end
#end end
# remove deleted customers # remove deleted customers
#where.not(customers.map(&:id)).destroy_all #where.not(customers.map(&:id)).destroy_all