mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0513763607 | |||
| b7e3ea9e3d | |||
| 3ea2cd14d1 | |||
| 7b7875991f | |||
| b1a106d4d8 | |||
| 0281d86f1a | |||
| 2231156873 | |||
| ecc8930bec | |||
| 5814740a5d |
@@ -12,17 +12,23 @@ class EstimateController < ApplicationController
|
|||||||
|
|
||||||
include AuthHelper
|
include AuthHelper
|
||||||
|
|
||||||
before_action :require_user
|
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
|
# Downloads and forwards the estimate pdf
|
||||||
#
|
#
|
||||||
def show
|
def show
|
||||||
e = Estimate.find_by_id(params[:id]) if params[:id]
|
estimate = get_estimate
|
||||||
e = Estimate.find_by_doc_number(params[:search]) if params[:search]
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
send_data e.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
|
rescue
|
||||||
redirect_to :back, :flash => { :error => "Estimate not found" }
|
redirect_to :back, :flash => { :error => "Estimate not found" }
|
||||||
end
|
end
|
||||||
@@ -32,11 +38,10 @@ class EstimateController < ApplicationController
|
|||||||
# Downloads estimate by document number
|
# Downloads estimate by document number
|
||||||
#
|
#
|
||||||
def doc
|
def doc
|
||||||
e = Estimate.find_by_doc_number(params[:id]) if params[:id]
|
estimate = get_estimate
|
||||||
e = Estimate.find_by_doc_number(params[:search]) if params[:search]
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
send_data e.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
|
rescue
|
||||||
redirect_to :back, :flash => { :error => "Estimate not found" }
|
redirect_to :back, :flash => { :error => "Estimate not found" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class QboController < ApplicationController
|
|||||||
qbo.expire = 1.hour.from_now.utc
|
qbo.expire = 1.hour.from_now.utc
|
||||||
|
|
||||||
if qbo.save!
|
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
|
else
|
||||||
redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => "Error" }
|
redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => "Error" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= form_tag("/qbo/estimate/doc", :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" %>
|
<%= text_field_tag :search, params[:search], placeholder: t(:label_search_estimates), :autocomplete => "off" %>
|
||||||
<%= submit_tag t(:label_search), :formtarget => "_blank" %>
|
<%= submit_tag t(:label_search), :formtarget => "_blank" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ post 'qbo/webhook', :to => 'qbo#webhook'
|
|||||||
|
|
||||||
# Estimate & Invoice PDF
|
# Estimate & Invoice PDF
|
||||||
get 'estimates/:id', :to => 'estimate#show', as: :estimate
|
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
|
get 'invoices/:id', :to => 'invoice#show', as: :invoice
|
||||||
|
|
||||||
#manual billing
|
#manual billing
|
||||||
|
|||||||
2
init.rb
2
init.rb
@@ -22,7 +22,7 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
name 'Redmine Quickbooks Online plugin'
|
name 'Redmine Quickbooks Online plugin'
|
||||||
author 'Rick Barrette'
|
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'
|
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'
|
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||||
author_url 'http://rickbarrette.org'
|
author_url 'http://rickbarrette.org'
|
||||||
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ class IssuesSaveHookListener < Redmine::Hook::ViewListener
|
|||||||
# Called After Issue Saved
|
# Called After Issue Saved
|
||||||
def controller_issues_edit_after_save(context={})
|
def controller_issues_edit_after_save(context={})
|
||||||
issue = context[:issue]
|
issue = context[:issue]
|
||||||
issue.bill_time if issue.status.is_closed?
|
begin
|
||||||
|
issue.bill_time if issue.status.is_closed?
|
||||||
|
rescue
|
||||||
|
# TODO flash[:error] = "Unable to bill, check QBO Auth"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user