From e2bf42e66b0492ad67d0dfb98b897f07c1b04e93 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 30 Dec 2023 23:04:43 -0500 Subject: [PATCH] Fixed invoice pdf --- app/controllers/invoice_controller.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/controllers/invoice_controller.rb b/app/controllers/invoice_controller.rb index d5a93b8..0f4017a 100644 --- a/app/controllers/invoice_controller.rb +++ b/app/controllers/invoice_controller.rb @@ -21,15 +21,12 @@ class InvoiceController < ApplicationController def show begin qbo = Qbo.first - @pdf = qbo.perform_authenticated_request do |access_token| + qbo.perform_authenticated_request do |access_token| service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token) invoice = service.fetch_by_id(params[:id]) - service.pdf(invoice) + @pdf = service.pdf(invoice) + send_data @pdf, filename: "invoice #{invoice.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" end - - return unless @pdf - - send_data @pdf, filename: "invoice #{invoice.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" rescue redirect_to :back, :flash => { :error => "Invoice not found" } end