Simplified all quickbooks inporting

no more loops
This commit is contained in:
2016-03-02 21:11:38 -05:00
parent 7b63e64da0
commit 0308a67a86
4 changed files with 23 additions and 25 deletions

View File

@@ -25,12 +25,13 @@ class QboCustomer < ActiveRecord::Base
def self.update_all
customers = get_base.service.all
# Update the customer table
customers.each { |customer|
qbo_customer = QboCustomer.find_or_create_by(id: customer.id)
qbo_customer.name = customer.display_name
qbo_customer.save!
}
ids = customers.map {|i| i.id}
display_names = customers.map {|i| i.display_name}
# Update the customer table
find_or_create_by(id: ids, name: display_names)
#remove deleted customers
where.not(customers.map(&:id)).destroy_all
end