From 9acc33e373ce445cb10162869aebe71e6bbe25af Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:19:17 -0500 Subject: [PATCH 01/20] Update qbo_employee.rb Fixed removal of customers --- app/models/qbo_employee.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/models/qbo_employee.rb b/app/models/qbo_employee.rb index 69453bf..8ef41a7 100644 --- a/app/models/qbo_employee.rb +++ b/app/models/qbo_employee.rb @@ -19,23 +19,16 @@ class QboEmployee < ActiveRecord::Base end def self.update_all - service = get_base.service + customers = get_base.service.all # Update the item table - service.all.each { |employee| + customers.each { |employee| qbo_employee = QboEmployee.find_or_create_by(id: employee.id) qbo_employee.name = employee.display_name - qbo_employee.id = employee.id qbo_employee.save! } #remove deleted employees - all.each { |employee| - begin - service.fetch_by_id(employee.id) - rescue - delete_all(id: employee.id) - end - } + where.not(customers.map(&:id)).destroy_all end end From 49f2baed9fd1b3688fce0646be6234e55431c4fe Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:20:34 -0500 Subject: [PATCH 02/20] Update qbo_employee.rb Fixed noob mistake --- app/models/qbo_employee.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/qbo_employee.rb b/app/models/qbo_employee.rb index 8ef41a7..29edff1 100644 --- a/app/models/qbo_employee.rb +++ b/app/models/qbo_employee.rb @@ -19,16 +19,16 @@ class QboEmployee < ActiveRecord::Base end def self.update_all - customers = get_base.service.all + employees = get_base.service.all # Update the item table - customers.each { |employee| - qbo_employee = QboEmployee.find_or_create_by(id: employee.id) + employee.each { |employee| + qbo_employees = QboEmployee.find_or_create_by(id: employee.id) qbo_employee.name = employee.display_name qbo_employee.save! } #remove deleted employees - where.not(customers.map(&:id)).destroy_all + where.not(employees.map(&:id)).destroy_all end end From f25fac1190ebe0d83a83d1a8c3083168d2374788 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:21:49 -0500 Subject: [PATCH 03/20] Update qbo_estimate.rb --- app/models/qbo_estimate.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/models/qbo_estimate.rb b/app/models/qbo_estimate.rb index 724e623..b30ded6 100644 --- a/app/models/qbo_estimate.rb +++ b/app/models/qbo_estimate.rb @@ -19,24 +19,17 @@ class QboEstimate < ActiveRecord::Base end def self.update_all - service = get_base.service + estimates = get_base.service.all # Update the item table - service.all.each { |estimate| + estimates.each { |estimate| qbo_estimate = QboEstimate.find_or_create_by(id: estimate.id) qbo_estimate.doc_number = estimate.doc_number - qbo_estimate.id = estimate.id qbo_estimate.save! } #remove deleted estimates - all.each { |estimate| - begin - service.fetch_by_id(estimate.id) - rescue - delete_all(id: estimate.id) - end - } + where.not(estimates.map(&:id)).destroy_all end def self.update(id) From c6ac6141d95d761aaeb9d38210003cff77f7f4a0 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:23:28 -0500 Subject: [PATCH 04/20] Update qbo_item.rb --- app/models/qbo_item.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/models/qbo_item.rb b/app/models/qbo_item.rb index 626d7f0..d99560b 100644 --- a/app/models/qbo_item.rb +++ b/app/models/qbo_item.rb @@ -19,23 +19,16 @@ class QboItem < ActiveRecord::Base end def self.update_all - service = get_base.service + items = get_base.service.find_by(:type, "Service") # Update the item table - service.find_by(:type, "Service").each { |item| + items.each { |item| qbo_item = QboItem.find_or_create_by(id: item.id) qbo_item.name = item.name - qbo_item.id = item.id qbo_item.save! } #remove deleted items - all.each { |item| - begin - service.fetch_by_id(item.id) - rescue - delete_all(id: item.id) - end - } + where.not(items.map(&:id)).destroy_all end end From 9ce8fa466170cd064fce8ae105eee6a884f6c511 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:24:42 -0500 Subject: [PATCH 05/20] Update issues_form_hook_listener.rb Remove automatic sync of items. --- lib/issues_form_hook_listener.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/issues_form_hook_listener.rb b/lib/issues_form_hook_listener.rb index d57a9bb..d992eda 100644 --- a/lib/issues_form_hook_listener.rb +++ b/lib/issues_form_hook_listener.rb @@ -15,7 +15,7 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener def view_issues_form_details_bottom(context={}) # Update the customer and item database QboCustomer.update_all - QboItem.update_all + #QboItem.update_all QboInvoice.update_all QboEstimate.update_all From 95fbad525d33e530efb9e43fe10ed3439bc0397a Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:26:35 -0500 Subject: [PATCH 06/20] Update qbo_invoice.rb Fixed id --- app/models/qbo_invoice.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/qbo_invoice.rb b/app/models/qbo_invoice.rb index 630b310..20a723d 100644 --- a/app/models/qbo_invoice.rb +++ b/app/models/qbo_invoice.rb @@ -24,6 +24,7 @@ class QboInvoice < ActiveRecord::Base invoices.each { | invoice | qbo_invoice = find_or_create_by(id: invoice.id) qbo_invoice.doc_number = invoice.doc_number + qbo_invoice.id = invoice.id qbo_invoice.save! } #remove deleted invoices From 37371d2373a737990ebcb8d6003b61ea83fef9e8 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:27:16 -0500 Subject: [PATCH 07/20] Update qbo_employee.rb Fixed ID --- app/models/qbo_employee.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/qbo_employee.rb b/app/models/qbo_employee.rb index 29edff1..c59cc69 100644 --- a/app/models/qbo_employee.rb +++ b/app/models/qbo_employee.rb @@ -25,6 +25,7 @@ class QboEmployee < ActiveRecord::Base employee.each { |employee| qbo_employees = QboEmployee.find_or_create_by(id: employee.id) qbo_employee.name = employee.display_name + qbo_employee.id = employee.id qbo_employee.save! } From 897810b029b3260547a6cc78aee44fa32fc76875 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:27:43 -0500 Subject: [PATCH 08/20] Update qbo_customer.rb Fixed ID --- app/models/qbo_customer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/qbo_customer.rb b/app/models/qbo_customer.rb index 27a7cd3..b78ab1a 100644 --- a/app/models/qbo_customer.rb +++ b/app/models/qbo_customer.rb @@ -29,6 +29,7 @@ class QboCustomer < ActiveRecord::Base customers.each { |customer| qbo_customer = QboCustomer.find_or_create_by(id: customer.id) qbo_customer.name = customer.display_name + qbo_customer.id = customer.id qbo_customer.save! } #remove deleted customers From 77be0b9d4c511617d0da3d738e40c0c1b9a68c7e Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:28:18 -0500 Subject: [PATCH 09/20] Update qbo_item.rb Fixed ID --- app/models/qbo_item.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/qbo_item.rb b/app/models/qbo_item.rb index d99560b..1f5a3e4 100644 --- a/app/models/qbo_item.rb +++ b/app/models/qbo_item.rb @@ -25,6 +25,7 @@ class QboItem < ActiveRecord::Base items.each { |item| qbo_item = QboItem.find_or_create_by(id: item.id) qbo_item.name = item.name + qbo_item.id = item.id qbo_item.save! } From 5104509106d355176b3fb8d27d5622a747dd1253 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 12:29:21 -0500 Subject: [PATCH 10/20] Update qbo_estimate.rb Fixed ID --- app/models/qbo_estimate.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/qbo_estimate.rb b/app/models/qbo_estimate.rb index b30ded6..4977a25 100644 --- a/app/models/qbo_estimate.rb +++ b/app/models/qbo_estimate.rb @@ -25,6 +25,7 @@ class QboEstimate < ActiveRecord::Base estimates.each { |estimate| qbo_estimate = QboEstimate.find_or_create_by(id: estimate.id) qbo_estimate.doc_number = estimate.doc_number + qbo_estimate.id = estimate.id qbo_estimate.save! } From 2c3503f4acb33e50bda9ae4de1ed691b208d8875 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 20:38:15 -0500 Subject: [PATCH 11/20] Added garbage colllection for instance variables --- lib/issues_form_hook_listener.rb | 4 ++-- lib/issues_show_hook_listener.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/issues_form_hook_listener.rb b/lib/issues_form_hook_listener.rb index d992eda..600e9e3 100644 --- a/lib/issues_form_hook_listener.rb +++ b/lib/issues_form_hook_listener.rb @@ -22,8 +22,8 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener # Check to see if there is a quickbooks user attached to the issue @selected_customer = context[:issue].qbo_customer.id if context[:issue].qbo_customer @selected_item = context[:issue].qbo_item.id if context[:issue].qbo_item - @selected_invoice = context[:issue].qbo_invoice.id if context[:issue].qbo_invoice - @selected_estimate = context[:issue].qbo_estimate.id if context[:issue].qbo_estimate + @selected_invoice = context[:issue].qbo_invoice ? context[:issue].qbo_invoice.id : nil + @selected_estimate = context[:issue].qbo_estimate ? context[:issue].qbo_estimate.id : nil # Generate the drop down list of quickbooks customers @select_customer = context[:form].select :qbo_customer_id, QboCustomer.all.pluck(:name, :id), :selected => @selected_customer, include_blank: true diff --git a/lib/issues_show_hook_listener.rb b/lib/issues_show_hook_listener.rb index 921eae1..1a45245 100644 --- a/lib/issues_show_hook_listener.rb +++ b/lib/issues_show_hook_listener.rb @@ -21,11 +21,13 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener issue = context[:issue] # Check to see if there is a quickbooks user attached to the issue - @customer = issue.qbo_customer.name if issue.qbo_customer + @customer = issue.qbo_customer ? issue.qbo_customer.name : nil # Check to see if there is a quickbooks item attached to the issue - @item = issue.qbo_item.name if issue.qbo_item + @item = issue.qbo_item ? issue.qbo_item.name : nil + @estimate = nil + @estimate_link = nil # Estimate Number if issue.qbo_estimate QboEstimate.update(issue.qbo_estimate.id) @@ -33,6 +35,8 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener @estimate_link = link_to @estimate, "#{Redmine::Utils::relative_url_root }/qbo/estimate/#{issue.qbo_estimate.id}", :target => "_blank" end + @invoice = nil + @invo = nil # Invoice Number if issue.qbo_invoice QboInvoice.update(issue.qbo_invoice.id) From cc9af5dc3680b59e67eaad3aa4587dd2c16eb248 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 10 Mar 2016 21:00:54 -0500 Subject: [PATCH 12/20] Added more garbage collection & removed automatic sync from show hook --- lib/issues_form_hook_listener.rb | 8 ++++---- lib/issues_show_hook_listener.rb | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/issues_form_hook_listener.rb b/lib/issues_form_hook_listener.rb index 600e9e3..51ef934 100644 --- a/lib/issues_form_hook_listener.rb +++ b/lib/issues_form_hook_listener.rb @@ -16,12 +16,12 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener # Update the customer and item database QboCustomer.update_all #QboItem.update_all - QboInvoice.update_all - QboEstimate.update_all + #QboInvoice.update_all + #QboEstimate.update_all # Check to see if there is a quickbooks user attached to the issue - @selected_customer = context[:issue].qbo_customer.id if context[:issue].qbo_customer - @selected_item = context[:issue].qbo_item.id if context[:issue].qbo_item + @selected_customer = context[:issue].qbo_customer ? context[:issue].qbo_customer.id : nil + @selected_item = context[:issue].qbo_item ? context[:issue].qbo_item.id : nil @selected_invoice = context[:issue].qbo_invoice ? context[:issue].qbo_invoice.id : nil @selected_estimate = context[:issue].qbo_estimate ? context[:issue].qbo_estimate.id : nil diff --git a/lib/issues_show_hook_listener.rb b/lib/issues_show_hook_listener.rb index 1a45245..bdba610 100644 --- a/lib/issues_show_hook_listener.rb +++ b/lib/issues_show_hook_listener.rb @@ -30,7 +30,6 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener @estimate_link = nil # Estimate Number if issue.qbo_estimate - QboEstimate.update(issue.qbo_estimate.id) @estimate = issue.qbo_estimate.doc_number @estimate_link = link_to @estimate, "#{Redmine::Utils::relative_url_root }/qbo/estimate/#{issue.qbo_estimate.id}", :target => "_blank" end @@ -39,7 +38,6 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener @invo = nil # Invoice Number if issue.qbo_invoice - QboInvoice.update(issue.qbo_invoice.id) @invoice = issue.qbo_invoice.doc_number @invoice_link = link_to @invoice, "#{Redmine::Utils::relative_url_root }/qbo/invoice/#{issue.qbo_invoice.id}", :target => "_blank" end From 79d990dd010ded84b636fb4f505570195334e5b9 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:02:54 -0400 Subject: [PATCH 13/20] Added Sorting to drop downs --- lib/issues_form_hook_listener.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/issues_form_hook_listener.rb b/lib/issues_form_hook_listener.rb index 51ef934..c5f4f58 100644 --- a/lib/issues_form_hook_listener.rb +++ b/lib/issues_form_hook_listener.rb @@ -14,7 +14,7 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener # Show a dropdown for quickbooks contacts def view_issues_form_details_bottom(context={}) # Update the customer and item database - QboCustomer.update_all + #QboCustomer.update_all #QboItem.update_all #QboInvoice.update_all #QboEstimate.update_all From ed5959d8e0adffd9718570d212c3081b4d5934d2 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:05:04 -0400 Subject: [PATCH 14/20] Added transaction to items --- app/models/qbo_item.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/qbo_item.rb b/app/models/qbo_item.rb index 1f5a3e4..9448e42 100644 --- a/app/models/qbo_item.rb +++ b/app/models/qbo_item.rb @@ -21,6 +21,7 @@ class QboItem < ActiveRecord::Base def self.update_all items = get_base.service.find_by(:type, "Service") +transaction do # Update the item table items.each { |item| qbo_item = QboItem.find_or_create_by(id: item.id) @@ -28,6 +29,7 @@ class QboItem < ActiveRecord::Base qbo_item.id = item.id qbo_item.save! } +end #remove deleted items where.not(items.map(&:id)).destroy_all From 3070192485212210add9f43fb19880b0a9af8bb3 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:05:38 -0400 Subject: [PATCH 15/20] Update qbo_item.rb Formatting --- app/models/qbo_item.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/qbo_item.rb b/app/models/qbo_item.rb index 9448e42..5c0742a 100644 --- a/app/models/qbo_item.rb +++ b/app/models/qbo_item.rb @@ -21,15 +21,15 @@ class QboItem < ActiveRecord::Base def self.update_all items = get_base.service.find_by(:type, "Service") -transaction do - # Update the item table - items.each { |item| - qbo_item = QboItem.find_or_create_by(id: item.id) - qbo_item.name = item.name - qbo_item.id = item.id - qbo_item.save! - } -end + transaction do + # Update the item table + items.each { |item| + qbo_item = QboItem.find_or_create_by(id: item.id) + qbo_item.name = item.name + qbo_item.id = item.id + qbo_item.save! + } + end #remove deleted items where.not(items.map(&:id)).destroy_all From 39a2e1564ff1a35626da0ef2c6204adab6363b9a Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:07:30 -0400 Subject: [PATCH 16/20] Update qbo_invoice.rb Added Transaction --- app/models/qbo_invoice.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/qbo_invoice.rb b/app/models/qbo_invoice.rb index 20a723d..9739ce8 100644 --- a/app/models/qbo_invoice.rb +++ b/app/models/qbo_invoice.rb @@ -20,13 +20,17 @@ class QboInvoice < ActiveRecord::Base def self.update_all invoices = get_base.service.all + # Update the invoice table - invoices.each { | invoice | - qbo_invoice = find_or_create_by(id: invoice.id) - qbo_invoice.doc_number = invoice.doc_number - qbo_invoice.id = invoice.id - qbo_invoice.save! - } + transaction do + invoices.each { | invoice | + qbo_invoice = find_or_create_by(id: invoice.id) + qbo_invoice.doc_number = invoice.doc_number + qbo_invoice.id = invoice.id + qbo_invoice.save! + } + end + #remove deleted invoices where.not(invoices.map(&:id)).destroy_all end From d33eba2b20252d8e6107b62decd76761c6c20283 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:08:56 -0400 Subject: [PATCH 17/20] Update qbo_customer.rb Added Transaction --- app/models/qbo_customer.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/models/qbo_customer.rb b/app/models/qbo_customer.rb index b78ab1a..afb7555 100644 --- a/app/models/qbo_customer.rb +++ b/app/models/qbo_customer.rb @@ -25,13 +25,17 @@ 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.id = customer.id - qbo_customer.save! - } + + transaction do + # 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.id = customer.id + qbo_customer.save! + } + end + #remove deleted customers where.not(customers.map(&:id)).destroy_all end From f89cdf8ab211fa79956f9e19dcc3eb3e8bf40103 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:09:52 -0400 Subject: [PATCH 18/20] Update qbo_employee.rb Added Transaction --- app/models/qbo_employee.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/qbo_employee.rb b/app/models/qbo_employee.rb index c59cc69..c80f19c 100644 --- a/app/models/qbo_employee.rb +++ b/app/models/qbo_employee.rb @@ -20,14 +20,16 @@ class QboEmployee < ActiveRecord::Base def self.update_all employees = get_base.service.all - - # Update the item table - employee.each { |employee| - qbo_employees = QboEmployee.find_or_create_by(id: employee.id) - qbo_employee.name = employee.display_name - qbo_employee.id = employee.id - qbo_employee.save! - } + + transaction do + # Update the item table + employee.each { |employee| + qbo_employees = QboEmployee.find_or_create_by(id: employee.id) + qbo_employee.name = employee.display_name + qbo_employee.id = employee.id + qbo_employee.save! + } + end #remove deleted employees where.not(employees.map(&:id)).destroy_all From 5be8d987b6cf6b91ccd1e21fcc348b4b3974f587 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:10:41 -0400 Subject: [PATCH 19/20] Update qbo_estimate.rb Added Transaction --- app/models/qbo_estimate.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/qbo_estimate.rb b/app/models/qbo_estimate.rb index 4977a25..cc7a566 100644 --- a/app/models/qbo_estimate.rb +++ b/app/models/qbo_estimate.rb @@ -22,12 +22,14 @@ class QboEstimate < ActiveRecord::Base 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.id = estimate.id - qbo_estimate.save! - } + transaction do + estimates.each { |estimate| + qbo_estimate = QboEstimate.find_or_create_by(id: estimate.id) + qbo_estimate.doc_number = estimate.doc_number + qbo_estimate.id = estimate.id + qbo_estimate.save! + } + end #remove deleted estimates where.not(estimates.map(&:id)).destroy_all From 1bc23ab553bb6ef3e1ed66ab0f81f009fbb7983f Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Thu, 31 Mar 2016 09:22:04 -0400 Subject: [PATCH 20/20] Fixed import errors --- app/models/qbo_customer.rb | 3 +++ app/models/qbo_employee.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/qbo_customer.rb b/app/models/qbo_customer.rb index afb7555..ae4c760 100644 --- a/app/models/qbo_customer.rb +++ b/app/models/qbo_customer.rb @@ -26,6 +26,9 @@ class QboCustomer < ActiveRecord::Base def self.update_all customers = get_base.service.all + delete_all + + transaction do # Update the customer table customers.each { |customer| diff --git a/app/models/qbo_employee.rb b/app/models/qbo_employee.rb index c80f19c..bb1a539 100644 --- a/app/models/qbo_employee.rb +++ b/app/models/qbo_employee.rb @@ -23,8 +23,8 @@ class QboEmployee < ActiveRecord::Base transaction do # Update the item table - employee.each { |employee| - qbo_employees = QboEmployee.find_or_create_by(id: employee.id) + employees.each { |employee| + qbo_employee = find_or_create_by(id: employee.id) qbo_employee.name = employee.display_name qbo_employee.id = employee.id qbo_employee.save!