mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 17:34:23 -05:00
Update qbo_estimate.rb
This commit is contained in:
@@ -19,24 +19,17 @@ class QboEstimate < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.update_all
|
def self.update_all
|
||||||
service = get_base.service
|
estimates = get_base.service.all
|
||||||
|
|
||||||
# Update the item table
|
# Update the item table
|
||||||
service.all.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.save!
|
qbo_estimate.save!
|
||||||
}
|
}
|
||||||
|
|
||||||
#remove deleted estimates
|
#remove deleted estimates
|
||||||
all.each { |estimate|
|
where.not(estimates.map(&:id)).destroy_all
|
||||||
begin
|
|
||||||
service.fetch_by_id(estimate.id)
|
|
||||||
rescue
|
|
||||||
delete_all(id: estimate.id)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.update(id)
|
def self.update(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user