From 22311568738206cccb88d251cc1c8e7b256b96c4 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:01:20 -0400 Subject: [PATCH 1/7] use estimate_doc_path not a hard coded path --- app/views/estimates/_search.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/estimates/_search.html.erb b/app/views/estimates/_search.html.erb index 4567ab7..2e4fba0 100644 --- a/app/views/estimates/_search.html.erb +++ b/app/views/estimates/_search.html.erb @@ -1,4 +1,4 @@ -<%= form_tag("/qbo/estimate/doc", :method => "get", id: "est-search-form") do %> +<%= form_tag(estimate_doc_path, :method => "get", id: "est-search-form") do %> <%= text_field_tag :search, params[:search], placeholder: t(:label_search_estimates), :autocomplete => "off" %> <%= submit_tag t(:label_search), :formtarget => "_blank" %> <% end %> From 0281d86f1ad49cf3721bae222b9a4c3cf8cee47e Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:25:20 -0400 Subject: [PATCH 2/7] No id required --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 9134c3d..ee9844e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,7 @@ post 'qbo/webhook', :to => 'qbo#webhook' # Estimate & Invoice PDF get 'estimates/:id', :to => 'estimate#show', as: :estimate -get 'estimates/doc/:id', :to => 'estimate#doc', as: :estimate_doc +get 'estimates/doc/', :to => 'estimate#doc', as: :estimate_doc get 'invoices/:id', :to => 'invoice#show', as: :invoice #manual billing From b1a106d4d86154945de02104731477359c7d95f7 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:27:31 -0400 Subject: [PATCH 3/7] No id required --- app/views/estimates/_search.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/estimates/_search.html.erb b/app/views/estimates/_search.html.erb index 2e4fba0..7a1a418 100644 --- a/app/views/estimates/_search.html.erb +++ b/app/views/estimates/_search.html.erb @@ -1,4 +1,4 @@ -<%= form_tag(estimate_doc_path, :method => "get", id: "est-search-form") do %> +<%= form_tag(estimate_doc_path, :method => "get") do %> <%= text_field_tag :search, params[:search], placeholder: t(:label_search_estimates), :autocomplete => "off" %> <%= submit_tag t(:label_search), :formtarget => "_blank" %> <% end %> From 7b7875991fdae656b5c9b3e26c20ebc3915dce02 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:28:40 -0400 Subject: [PATCH 4/7] created get_estimate to remove redundant code --- app/controllers/estimate_controller.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/estimate_controller.rb b/app/controllers/estimate_controller.rb index cfab872..07b9816 100644 --- a/app/controllers/estimate_controller.rb +++ b/app/controllers/estimate_controller.rb @@ -14,16 +14,21 @@ class EstimateController < ApplicationController before_action :require_user, :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 + estimate = Estimate.find_by_id(params[:id]) if params[:id] + estimate = Estimate.find_by_doc_number(params[:search]) if params[:search] + return estimate + end # # Downloads and forwards the estimate pdf # def show - e = Estimate.find_by_id(params[:id]) if params[:id] - e = Estimate.find_by_doc_number(params[:search]) if params[:search] + estimate = get_estimate begin - send_data e.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" + send_data estimate.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" rescue redirect_to :back, :flash => { :error => "Estimate not found" } end @@ -33,11 +38,10 @@ class EstimateController < ApplicationController # Downloads estimate by document number # def doc - e = Estimate.find_by_doc_number(params[:id]) if params[:id] - e = Estimate.find_by_doc_number(params[:search]) if params[:search] + estimate = get_estimate begin - send_data e.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" + send_data estimate.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" rescue redirect_to :back, :flash => { :error => "Estimate not found" } end From 3ea2cd14d1036777bba7f54bc25b4d9436dc0e15 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:33:20 -0400 Subject: [PATCH 5/7] Fixed accidental removal of qbo prefix --- app/controllers/qbo_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/qbo_controller.rb b/app/controllers/qbo_controller.rb index fd9e625..4be1b46 100644 --- a/app/controllers/qbo_controller.rb +++ b/app/controllers/qbo_controller.rb @@ -55,7 +55,7 @@ class QboController < ApplicationController qbo.expire = 1.hour.from_now.utc if qbo.save! - redirect_to sync_path, :flash => { :notice => "Successfully connected to Quickbooks" } + redirect_to qbo_sync_path, :flash => { :notice => "Successfully connected to Quickbooks" } else redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => "Error" } end From b7e3ea9e3da799be1df3384dad3bc7b4eda8d525 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:39:36 -0400 Subject: [PATCH 6/7] estimate not e --- app/controllers/estimate_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/estimate_controller.rb b/app/controllers/estimate_controller.rb index 07b9816..fd37dd0 100644 --- a/app/controllers/estimate_controller.rb +++ b/app/controllers/estimate_controller.rb @@ -28,7 +28,7 @@ class EstimateController < ApplicationController estimate = get_estimate begin - send_data estimate.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" + send_data estimate.pdf, filename: "estimate #{estimate.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" rescue redirect_to :back, :flash => { :error => "Estimate not found" } end @@ -41,7 +41,7 @@ class EstimateController < ApplicationController estimate = get_estimate begin - send_data estimate.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" + send_data estimate.pdf, filename: "estimate #{estimate.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf" rescue redirect_to :back, :flash => { :error => "Estimate not found" } end From 0513763607a9363d554978d52619ce1e656d8c61 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Mon, 14 Mar 2022 19:41:53 -0400 Subject: [PATCH 7/7] Version 1.1.5 --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.rb b/init.rb index 01dd0c9..45fd9e0 100644 --- a/init.rb +++ b/init.rb @@ -22,7 +22,7 @@ Redmine::Plugin.register :redmine_qbo do name 'Redmine Quickbooks Online plugin' author 'Rick Barrette' description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues' - version '1.1.4' + version '1.1.5' url 'https://github.com/rickbarrette/redmine_qbo' author_url 'http://rickbarrette.org' settings :default => {'empty' => true}, :partial => 'qbo/settings'