From 7eb26facaf857dcc23918f408254674ed81e02b2 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 19 Aug 2024 22:49:20 -0400 Subject: [PATCH] Use the first result --- app/controllers/estimate_controller.rb | 6 +++++- app/models/estimate.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/estimate_controller.rb b/app/controllers/estimate_controller.rb index bda75e8..06d4c2b 100644 --- a/app/controllers/estimate_controller.rb +++ b/app/controllers/estimate_controller.rb @@ -17,7 +17,11 @@ class EstimateController < ApplicationController def get_estimate # Force sync for estimate by doc number - Estimate.sync_by_doc_number(params[:search]) if params[:search] + begin + Estimate.sync_by_doc_number(params[:search]) if params[:search] + rescue + logger.info "Estimate.find_by_doc_number failed" + end estimate = Estimate.find_by_id(params[:id]) if params[:id] estimate = Estimate.find_by_doc_number(params[:search]) if params[:search] return estimate diff --git a/app/models/estimate.rb b/app/models/estimate.rb index 3758909..43ebc0a 100644 --- a/app/models/estimate.rb +++ b/app/models/estimate.rb @@ -51,7 +51,7 @@ class Estimate < ActiveRecord::Base qbo = Qbo.first qbo.perform_authenticated_request do |access_token| service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => access_token) - process_estimate(service.find_by :doc_number, number) + process_estimate(service.find_by( :doc_number, number).first) end end