mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 08:54:23 -05:00
Added Estimate.sync_by_doc_number
This commit is contained in:
@@ -16,6 +16,8 @@ class EstimateController < ApplicationController
|
|||||||
skip_before_action :verify_authenticity_token, :check_if_login_required, :unless => proc {|c| session[:token].nil? }
|
skip_before_action :verify_authenticity_token, :check_if_login_required, :unless => proc {|c| session[:token].nil? }
|
||||||
|
|
||||||
def get_estimate
|
def get_estimate
|
||||||
|
# Force sync for estimate by doc number
|
||||||
|
Estimate.sync_by_doc_number if params[:search]
|
||||||
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
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Estimate < ActiveRecord::Base
|
|||||||
|
|
||||||
# sync all estimates
|
# sync all estimates
|
||||||
def self.sync
|
def self.sync
|
||||||
logger.debug "Syncing ALL estimates"
|
logger.info "Syncing ALL estimates"
|
||||||
qbo = Qbo.first
|
qbo = Qbo.first
|
||||||
estimates = qbo.perform_authenticated_request do |access_token|
|
estimates = 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)
|
||||||
@@ -37,13 +37,23 @@ class Estimate < ActiveRecord::Base
|
|||||||
|
|
||||||
# sync only one estimate
|
# sync only one estimate
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
logger.debug "Syncing estimate #{id}"
|
logger.info "Syncing estimate #{id}"
|
||||||
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.fetch_by_id(id))
|
process_estimate(service.fetch_by_id(id))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# sync only one estimate
|
||||||
|
def self.sync_by_doc_number(number)
|
||||||
|
logger.info "Syncing estimate by doc number #{number}"
|
||||||
|
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))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# update an estimate
|
# update an estimate
|
||||||
def self.update(id)
|
def self.update(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user