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:
@@ -109,13 +109,11 @@ class Customer < ActiveRecord::Base
|
|||||||
query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last
|
query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last
|
||||||
|
|
||||||
Qbo.get_base(:customer).service.query(query).each do |customer|
|
Qbo.get_base(:customer).service.query(query).each do |customer|
|
||||||
Customer.transaction do
|
|
||||||
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
||||||
qbo_customer.name = customer.display_name
|
qbo_customer.name = customer.display_name
|
||||||
qbo_customer.id = customer.id
|
qbo_customer.id = customer.id
|
||||||
qbo_customer.save_without_push
|
qbo_customer.save_without_push
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# remove deleted customers
|
# remove deleted customers
|
||||||
#where.not(customers.map(&:id)).destroy_all
|
#where.not(customers.map(&:id)).destroy_all
|
||||||
@@ -128,8 +126,8 @@ class Customer < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Push the updates
|
# Push the updates
|
||||||
def save_with_push
|
def self.save_with_push
|
||||||
save_without_push
|
self.save_without_push
|
||||||
begin
|
begin
|
||||||
#tries ||= 3
|
#tries ||= 3
|
||||||
@details = Qbo.get_base(:customer).service.update(@details)
|
@details = Qbo.get_base(:customer).service.update(@details)
|
||||||
|
|||||||
Reference in New Issue
Block a user