mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Update qbo_customer.rb
Added Transaction
This commit is contained in:
@@ -25,6 +25,8 @@ class QboCustomer < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.update_all
|
def self.update_all
|
||||||
customers = get_base.service.all
|
customers = get_base.service.all
|
||||||
|
|
||||||
|
transaction do
|
||||||
# Update the customer table
|
# Update the customer table
|
||||||
customers.each { |customer|
|
customers.each { |customer|
|
||||||
qbo_customer = QboCustomer.find_or_create_by(id: customer.id)
|
qbo_customer = QboCustomer.find_or_create_by(id: customer.id)
|
||||||
@@ -32,6 +34,8 @@ class QboCustomer < ActiveRecord::Base
|
|||||||
qbo_customer.id = customer.id
|
qbo_customer.id = customer.id
|
||||||
qbo_customer.save!
|
qbo_customer.save!
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
#remove deleted customers
|
#remove deleted customers
|
||||||
where.not(customers.map(&:id)).destroy_all
|
where.not(customers.map(&:id)).destroy_all
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user