mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Use the first result
This commit is contained in:
@@ -17,7 +17,11 @@ class EstimateController < ApplicationController
|
|||||||
|
|
||||||
def get_estimate
|
def get_estimate
|
||||||
# Force sync for estimate by doc number
|
# Force sync for estimate by doc number
|
||||||
|
begin
|
||||||
Estimate.sync_by_doc_number(params[:search]) if params[:search]
|
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_id(params[:id]) if params[:id]
|
||||||
estimate = Estimate.find_by_doc_number(params[:search]) if params[:search]
|
estimate = Estimate.find_by_doc_number(params[:search]) if params[:search]
|
||||||
return estimate
|
return estimate
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class Estimate < ActiveRecord::Base
|
|||||||
qbo = Qbo.first
|
qbo = Qbo.first
|
||||||
qbo.perform_authenticated_request do |access_token|
|
qbo.perform_authenticated_request do |access_token|
|
||||||
service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user