mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Simplified all quickbooks inporting
no more loops
This commit is contained in:
@@ -21,12 +21,11 @@ class QboEstimate < ActiveRecord::Base
|
||||
def self.update_all
|
||||
estimates = get_base.service.all
|
||||
|
||||
# Update the item table
|
||||
estimates.each { |estimate|
|
||||
qbo_estimate = QboEstimate.find_or_create_by(id: estimate.id)
|
||||
qbo_estimate.doc_number = estimate.doc_number
|
||||
qbo_estimate.save!
|
||||
}
|
||||
ids = estimates.map {|i| i.id}
|
||||
doc_numbers = estimates.map {|i| i.doc_number}
|
||||
|
||||
# Update the invoice table
|
||||
find_or_create_by(id: ids, doc_number: doc_numbers)
|
||||
|
||||
#remove deleted estimates
|
||||
where.not(estimates.map(&:id)).destroy_all
|
||||
|
||||
Reference in New Issue
Block a user