mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 09:24:23 -05:00
Update customer.rb
This commit is contained in:
@@ -107,16 +107,18 @@ class Customer < ActiveRecord::Base
|
|||||||
|
|
||||||
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
|
||||||
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.each do |customer|
|
batch.each do |customer|
|
||||||
# Update the customer table
|
Customer.transaction do
|
||||||
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
# Update the customer table
|
||||||
qbo_customer.name = customer.display_name
|
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
||||||
qbo_customer.id = customer.id
|
qbo_customer.name = customer.display_name
|
||||||
qbo_customer.save
|
qbo_customer.id = customer.id
|
||||||
|
qbo_customer.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -144,6 +146,7 @@ class Customer < ActiveRecord::Base
|
|||||||
def pull
|
def pull
|
||||||
begin
|
begin
|
||||||
#tries ||= 3
|
#tries ||= 3
|
||||||
|
raise Exception if self.id
|
||||||
@details = Qbo.get_base(:customer).find_by_id(self.id)
|
@details = Qbo.get_base(:customer).find_by_id(self.id)
|
||||||
rescue
|
rescue
|
||||||
#retry unless (tries -= 1).zero?
|
#retry unless (tries -= 1).zero?
|
||||||
|
|||||||
Reference in New Issue
Block a user