From e9db63ea821159751c3a65359b9a7835a3f04b23 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 29 Feb 2016 09:37:24 -0500 Subject: [PATCH] Update qbo_estimate.rb Simplified Estimate Deletion --- app/models/qbo_estimate.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/models/qbo_estimate.rb b/app/models/qbo_estimate.rb index 724e623..16c5b64 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| 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)