diff --git a/Gemfile b/Gemfile index 6edad09..c0d4696 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,6 @@ source 'https://rubygems.org' - -gem 'quickbooks-ruby'#, :git => 'https://github.com/rickbarrette/quickbooks-ruby.git', :branch => " rickbarrette-estimate-pdf-patch" +gem 'quickbooks-ruby', :git => 'https://github.com/rickbarrette/quickbooks-ruby.git' gem 'quickbooks-ruby-base' gem 'oauth-plugin'#, '~> 0.5.1' gem 'oauth' diff --git a/app/controllers/qbo_controller.rb b/app/controllers/qbo_controller.rb index 28a5d4e..188dd4f 100644 --- a/app/controllers/qbo_controller.rb +++ b/app/controllers/qbo_controller.rb @@ -10,6 +10,8 @@ class QboController < ApplicationController unloadable + + require 'open-uri' # # Called when the QBO Top Menu us shown @@ -75,9 +77,13 @@ class QboController < ApplicationController redirect_to qbo_path(:redmine_qbo), :flash => { :notice => "Successfully synced to Quickbooks" } end - def pdf - @pdf = "#{base.url_for_resource('estimate')}/#{params['qbo_estimate_id']}/pdf" - send_data @pdf, filename: "estimate.pdf", type: :pdf + # + # Downloads and forwards the estimate pdf + # + def estimate_pdf + base = QboEstimate.get_base.service + @pdf = base.pdf(base.fetch_by_id(params[:id])) + send_data @pdf, filename: "estimate.pdf", :disposition => 'inline', :type => "application/pdf" end end diff --git a/config/routes.rb b/config/routes.rb index 68fe3bd..a2983d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,4 +15,4 @@ get 'qbo', :to=> 'qbo#index' get 'qbo/authenticate', :to => 'qbo#authenticate' get 'qbo/oauth_callback', :to => 'qbo#oauth_callback' get 'qbo/sync', :to => 'qbo#sync' - +get 'qbo/estimate/:id', :to => 'qbo#estimate_pdf', :as => :qbo_estimate_pdf \ No newline at end of file diff --git a/lib/issues_show_hook_listener.rb b/lib/issues_show_hook_listener.rb index 9eb5d67..ed8f45f 100644 --- a/lib/issues_show_hook_listener.rb +++ b/lib/issues_show_hook_listener.rb @@ -35,8 +35,6 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener QboEstimate.update(issue.qbo_estimate.id) @estimate = issue.qbo_estimate.doc_number end - base = QboEstimate.get_base.service - #base.initialize return "