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