mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Update qbo_estimate.rb
Added Transaction
This commit is contained in:
@@ -22,12 +22,14 @@ class QboEstimate < ActiveRecord::Base
|
|||||||
estimates = get_base.service.all
|
estimates = get_base.service.all
|
||||||
|
|
||||||
# Update the item table
|
# Update the item table
|
||||||
|
transaction do
|
||||||
estimates.each { |estimate|
|
estimates.each { |estimate|
|
||||||
qbo_estimate = QboEstimate.find_or_create_by(id: estimate.id)
|
qbo_estimate = QboEstimate.find_or_create_by(id: estimate.id)
|
||||||
qbo_estimate.doc_number = estimate.doc_number
|
qbo_estimate.doc_number = estimate.doc_number
|
||||||
qbo_estimate.id = estimate.id
|
qbo_estimate.id = estimate.id
|
||||||
qbo_estimate.save!
|
qbo_estimate.save!
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
#remove deleted estimates
|
#remove deleted estimates
|
||||||
where.not(estimates.map(&:id)).destroy_all
|
where.not(estimates.map(&:id)).destroy_all
|
||||||
|
|||||||
Reference in New Issue
Block a user