mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 08:54:23 -05:00
Drop the Qbo prefix
This commit is contained in:
@@ -48,13 +48,13 @@ class CustomersController < ApplicationController
|
|||||||
# getter method for a customer's invoices
|
# getter method for a customer's invoices
|
||||||
# used for customer autocomplete field / issue form
|
# used for customer autocomplete field / issue form
|
||||||
def filter_invoices_by_customer
|
def filter_invoices_by_customer
|
||||||
@filtered_invoices = QboInvoice.all.where(customer_id: params[:selected_customer])
|
@filtered_invoices = Invoice.all.where(customer_id: params[:selected_customer])
|
||||||
end
|
end
|
||||||
|
|
||||||
# getter method for a customer's estimates
|
# getter method for a customer's estimates
|
||||||
# used for customer autocomplete field / issue form
|
# used for customer autocomplete field / issue form
|
||||||
def filter_estimates_by_customer
|
def filter_estimates_by_customer
|
||||||
@filtered_estimates = QboEstimate.all.where(customer_id: params[:selected_customer])
|
@filtered_estimates = Estimate.all.where(customer_id: params[:selected_customer])
|
||||||
end
|
end
|
||||||
|
|
||||||
# display a list of all customers
|
# display a list of all customers
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class EstimateController < ApplicationController
|
|||||||
# Downloads and forwards the estimate pdf
|
# Downloads and forwards the estimate pdf
|
||||||
#
|
#
|
||||||
def show
|
def show
|
||||||
e = QboEstimate.find_by_id(params[:id]) if params[:id]
|
e = Estimate.find_by_id(params[:id]) if params[:id]
|
||||||
e = QboEstimate.find_by_doc_number(params[:search]) if params[:search]
|
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 e.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf"
|
||||||
@@ -32,8 +32,8 @@ class EstimateController < ApplicationController
|
|||||||
# Downloads estimate by document number
|
# Downloads estimate by document number
|
||||||
#
|
#
|
||||||
def doc
|
def doc
|
||||||
e = QboEstimate.find_by_doc_number(params[:id]) if params[:id]
|
e = Estimate.find_by_doc_number(params[:id]) if params[:id]
|
||||||
e = QboEstimate.find_by_doc_number(params[:search]) if params[:search]
|
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 e.pdf, filename: "estimate #{e.doc_number}.pdf", :disposition => 'inline', :type => "application/pdf"
|
||||||
|
|||||||
@@ -19,9 +19,13 @@ class InvoiceController < ApplicationController
|
|||||||
# Downloads and forwards the invoice pdf
|
# Downloads and forwards the invoice pdf
|
||||||
#
|
#
|
||||||
def show
|
def show
|
||||||
base = QboInvoice.get_base
|
begin
|
||||||
|
base = Invoice.get_base
|
||||||
invoice = base.fetch_by_id(params[:id])
|
invoice = base.fetch_by_id(params[:id])
|
||||||
@pdf = base.pdf(invoice)
|
@pdf = base.pdf(invoice)
|
||||||
send_data @pdf, filename: "invoice #{invoice.doc_number}.pdf", :disposition => 'inline', :type => "application/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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ class QboController < ApplicationController
|
|||||||
|
|
||||||
include AuthHelper
|
include AuthHelper
|
||||||
|
|
||||||
before_action :require_user, :except => :qbo_webhook
|
before_action :require_user, :except => :webhook
|
||||||
skip_before_action :verify_authenticity_token, :check_if_login_required, :only => [:qbo_webhook]
|
skip_before_action :verify_authenticity_token, :check_if_login_required, :only => [:webhook]
|
||||||
|
|
||||||
def allowed_params
|
def allowed_params
|
||||||
params.permit(:code, :state, :realmId, :id)
|
params.permit(:code, :state, :realmId, :id)
|
||||||
@@ -28,10 +28,10 @@ class QboController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@qbo = Qbo.first
|
@qbo = Qbo.first
|
||||||
@customer_count = Customer.count
|
@customer_count = Customer.count
|
||||||
@qbo_item_count = QboItem.count
|
@item_count = QboItem.count
|
||||||
@qbo_employee_count = QboEmployee.count
|
@employee_count = Employee.count
|
||||||
@qbo_invoice_count = QboInvoice.count
|
@invoice_count = Invoice.count
|
||||||
@qbo_estimate_count = QboEstimate.count
|
@estimate_count = Estimate.count
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -40,7 +40,6 @@ class QboController < ApplicationController
|
|||||||
def authenticate
|
def authenticate
|
||||||
oauth2_client = Qbo.get_client
|
oauth2_client = Qbo.get_client
|
||||||
callback = Setting.host_name + "/qbo/oauth_callback/"
|
callback = Setting.host_name + "/qbo/oauth_callback/"
|
||||||
#callback = qbo_oauth_callback_url
|
|
||||||
grant_url = oauth2_client.auth_code.authorize_url(redirect_uri: callback, response_type: "code", state: SecureRandom.hex(12), scope: "com.intuit.quickbooks.accounting")
|
grant_url = oauth2_client.auth_code.authorize_url(redirect_uri: callback, response_type: "code", state: SecureRandom.hex(12), scope: "com.intuit.quickbooks.accounting")
|
||||||
redirect_to grant_url
|
redirect_to grant_url
|
||||||
end
|
end
|
||||||
@@ -52,7 +51,6 @@ class QboController < ApplicationController
|
|||||||
if params[:state].present?
|
if params[:state].present?
|
||||||
oauth2_client = Qbo.get_client
|
oauth2_client = Qbo.get_client
|
||||||
# use the state value to retrieve from your backend any information you need to identify the customer in your system
|
# use the state value to retrieve from your backend any information you need to identify the customer in your system
|
||||||
#redirect_uri = qbo_oauth_callback_url
|
|
||||||
redirect_uri = Setting.host_name + "/qbo/oauth_callback/"
|
redirect_uri = Setting.host_name + "/qbo/oauth_callback/"
|
||||||
if resp = oauth2_client.auth_code.get_token(params[:code], redirect_uri: redirect_uri)
|
if resp = oauth2_client.auth_code.get_token(params[:code], redirect_uri: redirect_uri)
|
||||||
|
|
||||||
@@ -69,7 +67,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 qbo_sync_path, :flash => { :notice => "Successfully connected to Quickbooks" }
|
redirect_to 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
|
||||||
@@ -90,7 +88,7 @@ class QboController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Quickbooks Webhook Callback
|
# Quickbooks Webhook Callback
|
||||||
def qbo_webhook
|
def webhook
|
||||||
|
|
||||||
logger.info "Quickbooks is calling webhook"
|
logger.info "Quickbooks is calling webhook"
|
||||||
|
|
||||||
@@ -161,10 +159,10 @@ class QboController < ApplicationController
|
|||||||
Thread.new do
|
Thread.new do
|
||||||
if Qbo.exists?
|
if Qbo.exists?
|
||||||
Customer.sync
|
Customer.sync
|
||||||
QboInvoice.sync
|
Invoice.sync
|
||||||
QboItem.sync
|
QboItem.sync
|
||||||
QboEmployee.sync
|
Employee.sync
|
||||||
QboEstimate.sync
|
Estimate.sync
|
||||||
|
|
||||||
# Record the last sync time
|
# Record the last sync time
|
||||||
Qbo.update_time_stamp
|
Qbo.update_time_stamp
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ class Customer < ActiveRecord::Base
|
|||||||
unloadable
|
unloadable
|
||||||
|
|
||||||
has_many :issues
|
has_many :issues
|
||||||
has_many :qbo_purchases
|
has_many :purchases
|
||||||
has_many :qbo_invoices
|
has_many :invoices
|
||||||
has_many :qbo_estimates
|
has_many :estimates
|
||||||
has_many :vehicles
|
has_many :vehicles
|
||||||
|
|
||||||
#attr_accessible :name, :notes, :email, :primary_phone, :mobile_phone, :phone_number
|
#attr_accessible :name, :notes, :email, :primary_phone, :mobile_phone, :phone_number
|
||||||
@@ -149,16 +149,16 @@ class Customer < ActiveRecord::Base
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
customers.each do |customer|
|
customers.each do |customer|
|
||||||
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
customer = Customer.find_or_create_by(id: customer.id)
|
||||||
if customer.active?
|
if customer.active?
|
||||||
if not qbo_customer.name.eql? customer.display_name
|
if not customer.name.eql? customer.display_name
|
||||||
qbo_customer.name = customer.display_name
|
customer.name = customer.display_name
|
||||||
qbo_customer.id = customer.id
|
customer.id = customer.id
|
||||||
qbo_customer.save_without_push
|
customer.save_without_push
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not qbo_customer.new_record?
|
if not customer.new_record?
|
||||||
qbo_customer.delete
|
customer.delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -176,16 +176,16 @@ class Customer < ActiveRecord::Base
|
|||||||
service = Qbo.get_base(:customer)
|
service = Qbo.get_base(:customer)
|
||||||
|
|
||||||
customer = service.fetch_by_id(id)
|
customer = service.fetch_by_id(id)
|
||||||
qbo_customer = Customer.find_or_create_by(id: customer.id)
|
customer = Customer.find_or_create_by(id: customer.id)
|
||||||
if customer.active?
|
if customer.active?
|
||||||
if not qbo_customer.name.eql? customer.display_name
|
if not customer.name.eql? customer.display_name
|
||||||
qbo_customer.name = customer.display_name
|
customer.name = customer.display_name
|
||||||
qbo_customer.id = customer.id
|
customer.id = customer.id
|
||||||
qbo_customer.save_without_push
|
customer.save_without_push
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not qbo_customer.new_record?
|
if not customer.new_record?
|
||||||
qbo_customer.delete
|
customer.delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class CustomerToken < ActiveRecord::Base
|
|||||||
validates_presence_of :expires_at, :issue_id
|
validates_presence_of :expires_at, :issue_id
|
||||||
before_create :generate_token
|
before_create :generate_token
|
||||||
|
|
||||||
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret'] || 'CONFIGURE_QBO__' + SecureRandom.uuid
|
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret'] || 'CONFIGURE__' + SecureRandom.uuid
|
||||||
|
|
||||||
def generate_token
|
def generate_token
|
||||||
self.token = SecureRandom.base64(15).tr('+/=lIO0', OAUTH_CONSUMER_SECRET)
|
self.token = SecureRandom.base64(15).tr('+/=lIO0', OAUTH_CONSUMER_SECRET)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
class QboEmployee < ActiveRecord::Base
|
class Employee < ActiveRecord::Base
|
||||||
unloadable
|
unloadable
|
||||||
has_many :users
|
has_many :users
|
||||||
#attr_accessible :name
|
#attr_accessible :name
|
||||||
@@ -24,19 +24,19 @@ class QboEmployee < ActiveRecord::Base
|
|||||||
transaction do
|
transaction do
|
||||||
# Update the item table
|
# Update the item table
|
||||||
employees.each { |employee|
|
employees.each { |employee|
|
||||||
qbo_employee = find_or_create_by(id: employee.id)
|
employee = find_or_create_by(id: employee.id)
|
||||||
qbo_employee.name = employee.display_name
|
employee.name = employee.display_name
|
||||||
qbo_employee.id = employee.id
|
employee.id = employee.id
|
||||||
qbo_employee.save!
|
employee.save!
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
employee = get_base.fetch_by_id(id)
|
employee = get_base.fetch_by_id(id)
|
||||||
qbo_employee = find_or_create_by(id: employee.id)
|
employee = find_or_create_by(id: employee.id)
|
||||||
qbo_employee.name = employee.display_name
|
employee.name = employee.display_name
|
||||||
qbo_employee.id = employee.id
|
employee.id = employee.id
|
||||||
qbo_employee.save!
|
employee.save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
class QboEstimate < ActiveRecord::Base
|
class Estimate < ActiveRecord::Base
|
||||||
unloadable
|
unloadable
|
||||||
|
|
||||||
has_and_belongs_to_many :issues
|
has_and_belongs_to_many :issues
|
||||||
@@ -44,26 +44,26 @@ class QboEstimate < ActiveRecord::Base
|
|||||||
def self.update(id)
|
def self.update(id)
|
||||||
# Update the item table
|
# Update the item table
|
||||||
estimate = get_base.fetch_by_id(id)
|
estimate = get_base.fetch_by_id(id)
|
||||||
qbo_estimate = find_or_create_by(id: id)
|
estimate = find_or_create_by(id: id)
|
||||||
qbo_estimate.doc_number = estimate.doc_number
|
estimate.doc_number = estimate.doc_number
|
||||||
qbo_estimate.txn_date = estimate.txn_date
|
estimate.txn_date = estimate.txn_date
|
||||||
qbo_estimate.save!
|
estimate.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
# process an estimate into the database
|
# process an estimate into the database
|
||||||
def self.process_estimate(estimate)
|
def self.process_estimate(estimate)
|
||||||
logger.info "Processing estimate #{estimate.id}"
|
logger.info "Processing estimate #{estimate.id}"
|
||||||
qbo_estimate = find_or_create_by(id: estimate.id)
|
estimate = find_or_create_by(id: estimate.id)
|
||||||
qbo_estimate.doc_number = estimate.doc_number
|
estimate.doc_number = estimate.doc_number
|
||||||
qbo_estimate.customer_id = estimate.customer_ref.value
|
estimate.customer_id = estimate.customer_ref.value
|
||||||
qbo_estimate.id = estimate.id
|
estimate.id = estimate.id
|
||||||
qbo_estimate.txn_date = estimate.txn_date
|
estimate.txn_date = estimate.txn_date
|
||||||
qbo_estimate.save!
|
estimate.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
# download the pdf from quickbooks
|
# download the pdf from quickbooks
|
||||||
def pdf
|
def pdf
|
||||||
base = QboEstimate.get_base
|
base = Estimate.get_base
|
||||||
estimate = base.fetch_by_id(id)
|
estimate = base.fetch_by_id(id)
|
||||||
return base.pdf(estimate)
|
return base.pdf(estimate)
|
||||||
end
|
end
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
class QboInvoice < ActiveRecord::Base
|
class Invoice < ActiveRecord::Base
|
||||||
unloadable
|
unloadable
|
||||||
has_and_belongs_to_many :issues
|
has_and_belongs_to_many :issues
|
||||||
belongs_to :customer
|
belongs_to :customer
|
||||||
@@ -59,10 +59,10 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
|
|
||||||
logger.debug "Attaching invoice #{invoice.id} to issue #{issue.id}"
|
logger.debug "Attaching invoice #{invoice.id} to issue #{issue.id}"
|
||||||
|
|
||||||
qbo_invoice = QboInvoice.find_or_create_by(id: invoice.id)
|
invoice = Invoice.find_or_create_by(id: invoice.id)
|
||||||
|
|
||||||
unless issue.qbo_invoices.include?(qbo_invoice)
|
unless issue.invoices.include?(invoice)
|
||||||
issue.qbo_invoices << qbo_invoice
|
issue.invoices << invoice
|
||||||
issue.save!
|
issue.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -74,12 +74,12 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
logger.info "Processing invoice #{invoice.id}"
|
logger.info "Processing invoice #{invoice.id}"
|
||||||
|
|
||||||
# Load the invoice into the database
|
# Load the invoice into the database
|
||||||
qbo_invoice = QboInvoice.find_or_create_by(id: invoice.id)
|
invoice = Invoice.find_or_create_by(id: invoice.id)
|
||||||
qbo_invoice.doc_number = invoice.doc_number
|
invoice.doc_number = invoice.doc_number
|
||||||
qbo_invoice.id = invoice.id
|
invoice.id = invoice.id
|
||||||
qbo_invoice.customer_id = invoice.customer_ref
|
invoice.customer_id = invoice.customer_ref
|
||||||
qbo_invoice.txn_date = invoice.txn_date
|
invoice.txn_date = invoice.txn_date
|
||||||
qbo_invoice.save!
|
invoice.save!
|
||||||
|
|
||||||
# Scan the private notes for hashtags and attach to the applicable issues
|
# Scan the private notes for hashtags and attach to the applicable issues
|
||||||
if not invoice.private_note.nil?
|
if not invoice.private_note.nil?
|
||||||
@@ -105,7 +105,7 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
# TODO maybe add a cf_sync_confict flag to invoices
|
# TODO maybe add a cf_sync_confict flag to invoices
|
||||||
def self.compare_custom_fields(issue, invoice)
|
def self.compare_custom_fields(issue, invoice)
|
||||||
logger.debug "Comparing custom fields"
|
logger.debug "Comparing custom fields"
|
||||||
# TODO break if QboInvoice.find(invoice.id).cf_sync_confict
|
# TODO break if Invoice.find(invoice.id).cf_sync_confict
|
||||||
is_changed = false
|
is_changed = false
|
||||||
|
|
||||||
# update the invoive custom fields with infomation from the issue if available
|
# update the invoive custom fields with infomation from the issue if available
|
||||||
@@ -160,7 +160,7 @@ class QboInvoice < ActiveRecord::Base
|
|||||||
# Do nothing, probaly custome field sync confict on the invoice.
|
# Do nothing, probaly custome field sync confict on the invoice.
|
||||||
# This is a problem with how it's billed
|
# This is a problem with how it's billed
|
||||||
# TODO Add notes in memo area
|
# TODO Add notes in memo area
|
||||||
# TODO flag QboInvoice.cf_sync_confict here
|
# TODO flag Invoice.cf_sync_confict here
|
||||||
logger.error "Failed to update invoice"
|
logger.error "Failed to update invoice"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2020 rick barrette
|
#Copyright (c) 2022 rick barrette
|
||||||
#
|
#
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
class Qbo < ActiveRecord::Base
|
class Qbo < ActiveRecord::Base
|
||||||
unloadable
|
unloadable
|
||||||
#validates_presence_of :qb_token, :qb_secret, :company_id, :token_expires_at, :reconnect_token_at
|
|
||||||
validates_presence_of :token, :company_id, :expire
|
validates_presence_of :token, :company_id, :expire
|
||||||
serialize :token
|
serialize :token
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
$('select#issue_qbo_estimate_id').html('<%= j content_tag(:option,'',:value=>"")+options_from_collection_for_select(@filtered_estimates, :id, :doc_number) %>');
|
$('select#issue_estimate_id').html('<%= j content_tag(:option,'',:value=>"")+options_from_collection_for_select(@filtered_estimates, :id, :doc_number) %>');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<% if @customer.present? %>
|
<% if @customer.present? %>
|
||||||
|
|
||||||
<% @customer.qbo_estimates.order(doc_number: :desc).each do |estimate| %>
|
<% @customer.estimates.order(doc_number: :desc).each do |estimate| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<b><%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %></b> <%= estimate.txn_date %>
|
<b><%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %></b> <%= estimate.txn_date %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<% if @customer.present? %>
|
<% if @customer.present? %>
|
||||||
|
|
||||||
<% @customer.qbo_invoices.order(doc_number: :desc).each do |invoice| %>
|
<% @customer.invoices.order(doc_number: :desc).each do |invoice| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<b><%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %></b> <%= invoice.txn_date %>
|
<b><%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %></b> <%= invoice.txn_date %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
<div class="value"><%= customer %></div>
|
<div class="value"><%= customer %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="qbo_estimate_id attribute">
|
<div class="estimate_id attribute">
|
||||||
<div class="label"><span><%=t(:field_qbo_estimate)%></span>:</div>
|
<div class="label"><span><%=t(:field_estimate)%></span>:</div>
|
||||||
<div class="value"><%= estimate_link %></div>
|
<div class="value"><%= estimate_link %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="qbo_invoice_id attribute">
|
<div class="invoice_id attribute">
|
||||||
<div class="label"><span><%=t(:field_qbo_invoice)%></span>:</div>
|
<div class="label"><span><%=t(:field_invoice)%></span>:</div>
|
||||||
<div class="value"><%= invoice_link %></div>
|
<div class="value"><%= invoice_link %></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
|
|
||||||
<!-- configure the Intuit object: 'grantUrl' is a URL in your application which kicks off the flow, see below -->
|
<!-- configure the Intuit object: 'grantUrl' is a URL in your application which kicks off the flow, see below -->
|
||||||
<script>
|
<script>
|
||||||
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= Setting.host_name %>/qbo/authenticate'});
|
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= Setting.host_name %>/qbo/authenticate'});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<table >
|
<table >
|
||||||
@@ -24,7 +24,10 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= Settin
|
|||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_client_id)%></th>
|
<th><%=t(:label_client_id)%></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" style="width:350px" id="settingsOAuthConsumerKey"
|
<input
|
||||||
|
type="text"
|
||||||
|
style="width:350px"
|
||||||
|
id="settingsOAuthConsumerKey"
|
||||||
value="<%= settings['settingsOAuthConsumerKey'] %>"
|
value="<%= settings['settingsOAuthConsumerKey'] %>"
|
||||||
name="settings[settingsOAuthConsumerKey]" >
|
name="settings[settingsOAuthConsumerKey]" >
|
||||||
</td>
|
</td>
|
||||||
@@ -33,7 +36,10 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= Settin
|
|||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_client_secret)%></th>
|
<th><%=t(:label_client_secret)%></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" style="width:350px" id="settingsOAuthConsumerSecret"
|
<input
|
||||||
|
type="text"
|
||||||
|
style="width:350px"
|
||||||
|
id="settingsOAuthConsumerSecret"
|
||||||
value="<%= settings['settingsOAuthConsumerSecret'] %>"
|
value="<%= settings['settingsOAuthConsumerSecret'] %>"
|
||||||
name="settings[settingsOAuthConsumerSecret]" >
|
name="settings[settingsOAuthConsumerSecret]" >
|
||||||
</td>
|
</td>
|
||||||
@@ -42,7 +48,10 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= Settin
|
|||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_webhook_token)%></th>
|
<th><%=t(:label_webhook_token)%></th>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" style="width:350px" id="settingsWebhookToken"
|
<input
|
||||||
|
type="text"
|
||||||
|
style="width:350px"
|
||||||
|
id="settingsWebhookToken"
|
||||||
value="<%= settings['settingsWebhookToken'] %>"
|
value="<%= settings['settingsWebhookToken'] %>"
|
||||||
name="settings[settingsWebhookToken]" >
|
name="settings[settingsWebhookToken]" >
|
||||||
</td>
|
</td>
|
||||||
@@ -72,19 +81,19 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= Settin
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_employee_count)%>:</b> <%= QboEmployee.count %>
|
<b><%=t(:label_employee_count)%>:</b> <%= Employee.count %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_invoice_count)%>:</b> <%= QboInvoice.count %>
|
<b><%=t(:label_invoice_count)%>:</b> <%= Invoice.count %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_estimate_count)%>:</b> <%= QboEstimate.count %>
|
<b><%=t(:label_estimate_count)%>:</b> <%= Estimate.count %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %> <%= link_to " Sync Now", qbo_sync_path %>
|
<b><%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %> <%= link_to t(:label_sync_now), qbo_sync_path %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<!--
|
<!--
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 rick barrette
|
Copyright (c) 2022 rick barrette
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
@@ -18,19 +18,19 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_item_count)%>:</b> <%= @qbo_item_count.to_s %>
|
<b><%=t(:label_item_count)%>:</b> <%= @item_count.to_s %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_employee_count)%>:</b> <%= @qbo_employee_count.to_s %>
|
<b><%=t(:label_employee_count)%>:</b> <%= @employee_count.to_s %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_invoice_count)%>:</b> <%= @qbo_invoice_count.to_s %>
|
<b><%=t(:label_invoice_count)%>:</b> <%= @invoice_count.to_s %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<b><%=t(:label_estimate_count)%>:</b> <%= @qbo_estimate_count.to_s %>
|
<b><%=t(:label_estimate_count)%>:</b> <%= @estimate_count.to_s %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
@@ -13,15 +13,15 @@
|
|||||||
en:
|
en:
|
||||||
# my_label: "My label"
|
# my_label: "My label"
|
||||||
field_customer: "Customer"
|
field_customer: "Customer"
|
||||||
field_qbo_item: "Item"
|
field_item: "Item"
|
||||||
field_qbo_employee: "Employee"
|
field_employee: "Employee"
|
||||||
field_qbo_invoice: "Invoice"
|
field_invoice: "Invoice"
|
||||||
field_qbo_estimate: "Estimate"
|
field_estimate: "Estimate"
|
||||||
field_vehicles: "Vehicles"
|
field_vehicles: "Vehicles"
|
||||||
field_vehicle: "Vehicle"
|
field_vehicle: "Vehicle"
|
||||||
field_vin: "VIN"
|
field_vin: "VIN"
|
||||||
field_notes: "Notes"
|
field_notes: "Notes"
|
||||||
field_qbo_billed: "Billed"
|
field_billed: "Billed"
|
||||||
label_week: "Week"
|
label_week: "Week"
|
||||||
label_search_estimates: "Search Estimates"
|
label_search_estimates: "Search Estimates"
|
||||||
label_search: "Search"
|
label_search: "Search"
|
||||||
@@ -82,4 +82,5 @@ en:
|
|||||||
label_trim: "Trim"
|
label_trim: "Trim"
|
||||||
label_bill_time: "Bill Time"
|
label_bill_time: "Bill Time"
|
||||||
label_share: "Share"
|
label_share: "Share"
|
||||||
|
label_sync_now: "Sync Now"
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ get 'customers/share/:id', :to => 'customers#share', as: :share
|
|||||||
resources :payments
|
resources :payments
|
||||||
|
|
||||||
#webhook
|
#webhook
|
||||||
post 'qbo/webhook', :to => 'qbo#qbo_webhook'
|
post 'qbo/webhook', :to => 'qbo#webhook'
|
||||||
|
|
||||||
#java script routes
|
#java script routes
|
||||||
get 'filter_vehicles_by_customer' => 'customers#filter_vehicles_by_customer'
|
get 'filter_vehicles_by_customer' => 'customers#filter_vehicles_by_customer'
|
||||||
|
|||||||
23
db/migrate/035_drop_qbo_prefix.rb
Normal file
23
db/migrate/035_drop_qbo_prefix.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2022 rick barrette
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
class DropQboPrefix < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
rename_table :qbo_invoices, :invoices
|
||||||
|
rename_table :qbo_estimates, :estimates
|
||||||
|
rename_table :qbo_employees, :employees
|
||||||
|
rename_table :issues_qbo_invoices, :invoices_issues
|
||||||
|
|
||||||
|
rename_column :issues, :qbo_estimate_id, :estimate_id
|
||||||
|
rename_column :users, :qbo_employee_id, :employee_id
|
||||||
|
rename_column :invoices_issues, :qbo_invoice_id, :invoice_id
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
10
init.rb
10
init.rb
@@ -30,12 +30,12 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
|
|
||||||
# Add safe attributes for core models
|
# Add safe attributes for core models
|
||||||
Issue.safe_attributes 'customer_id'
|
Issue.safe_attributes 'customer_id'
|
||||||
Issue.safe_attributes 'qbo_item_id'
|
Issue.safe_attributes 'item_id'
|
||||||
Issue.safe_attributes 'qbo_estimate_id'
|
Issue.safe_attributes 'estimate_id'
|
||||||
Issue.safe_attributes 'qbo_invoice_id'
|
Issue.safe_attributes 'invoice_id'
|
||||||
Issue.safe_attributes 'vehicles_id'
|
Issue.safe_attributes 'vehicles_id'
|
||||||
User.safe_attributes 'qbo_employee_id'
|
User.safe_attributes 'employee_id'
|
||||||
TimeEntry.safe_attributes 'qbo_billed'
|
TimeEntry.safe_attributes 'billed'
|
||||||
Project.safe_attributes 'customer_id'
|
Project.safe_attributes 'customer_id'
|
||||||
Project.safe_attributes 'vehicle_id'
|
Project.safe_attributes 'vehicle_id'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2017 rick barrette
|
#Copyright (c) 2022 rick barrette
|
||||||
#
|
#
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
@@ -14,6 +14,6 @@ class HeaderFooterHookListener < Redmine::Hook::ViewListener
|
|||||||
end
|
end
|
||||||
|
|
||||||
def view_layouts_base_body_bottom(context = {})
|
def view_layouts_base_body_bottom(context = {})
|
||||||
return "<div id='qbo_footer' align='center'><b>#{I18n.translate(:label_last_sync)}: </b> #{Qbo.last_sync if Qbo.exists?}</div>"
|
return "<div id='footer' align='center'><b>#{I18n.translate(:label_last_sync)}: </b> #{Qbo.last_sync if Qbo.exists?}</div>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2020 rick barrette
|
#Copyright (c) 2022 rick barrette
|
||||||
#
|
#
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
@@ -24,9 +24,9 @@ module IssuePatch
|
|||||||
unloadable # Send unloadable so it will not be unloaded in development
|
unloadable # Send unloadable so it will not be unloaded in development
|
||||||
belongs_to :customer, primary_key: :id
|
belongs_to :customer, primary_key: :id
|
||||||
belongs_to :customer_token, primary_key: :id
|
belongs_to :customer_token, primary_key: :id
|
||||||
belongs_to :qbo_estimate, primary_key: :id
|
belongs_to :estimate, primary_key: :id
|
||||||
has_and_belongs_to_many :qbo_invoices
|
has_and_belongs_to_many :invoices
|
||||||
#, :association_foreign_key => 'issue_id', :class_name => 'Issue', :join_table => 'issues_qbo_invoices'
|
#, :association_foreign_key => 'issue_id', :class_name => 'Issue', :join_table => 'issues_invoices'
|
||||||
|
|
||||||
belongs_to :vehicle, primary_key: :id
|
belongs_to :vehicle, primary_key: :id
|
||||||
end
|
end
|
||||||
@@ -49,7 +49,7 @@ module IssuePatch
|
|||||||
return unless customer
|
return unless customer
|
||||||
|
|
||||||
# Get unbilled time entries
|
# Get unbilled time entries
|
||||||
spent_time = time_entries.where(qbo_billed: [false, nil])
|
spent_time = time_entries.where(billed: [false, nil])
|
||||||
spent_hours ||= spent_time.sum(:hours) || 0
|
spent_hours ||= spent_time.sum(:hours) || 0
|
||||||
|
|
||||||
if spent_hours > 0 then
|
if spent_hours > 0 then
|
||||||
@@ -65,7 +65,7 @@ module IssuePatch
|
|||||||
spent_time.each do |entry|
|
spent_time.each do |entry|
|
||||||
h[entry.activity.name] += entry.hours
|
h[entry.activity.name] += entry.hours
|
||||||
# update time entries billed status
|
# update time entries billed status
|
||||||
entry.qbo_billed = true
|
entry.billed = true
|
||||||
entry.save
|
entry.save
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ module IssuePatch
|
|||||||
|
|
||||||
# Create the new billable time entry and upload it
|
# Create the new billable time entry and upload it
|
||||||
time_entry.description = "#{tracker} ##{id}: #{subject} #{"(Partial @ #{done_ratio}%)" if not closed?}"
|
time_entry.description = "#{tracker} ##{id}: #{subject} #{"(Partial @ #{done_ratio}%)" if not closed?}"
|
||||||
# TODO entry.user.qbo_employee.id
|
# TODO entry.user.employee.id
|
||||||
time_entry.employee_id = assigned_to.qbo_employee_id
|
time_entry.employee_id = assigned_to.employee_id
|
||||||
time_entry.customer_id = customer_id
|
time_entry.customer_id = customer_id
|
||||||
time_entry.billable_status = "Billable"
|
time_entry.billable_status = "Billable"
|
||||||
time_entry.hours = hours
|
time_entry.hours = hours
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
|
|||||||
|
|
||||||
# Check to see if the issue already belongs to a customer
|
# Check to see if the issue already belongs to a customer
|
||||||
selected_customer = context[:issue].customer ? context[:issue].customer.id : nil
|
selected_customer = context[:issue].customer ? context[:issue].customer.id : nil
|
||||||
selected_estimate = context[:issue].qbo_estimate ? context[:issue].qbo_estimate.id : nil
|
selected_estimate = context[:issue].estimate ? context[:issue].estimate.id : nil
|
||||||
selected_vehicle = context[:issue].vehicles_id ? context[:issue].vehicles_id : nil
|
selected_vehicle = context[:issue].vehicles_id ? context[:issue].vehicles_id : nil
|
||||||
|
|
||||||
# Load customer information
|
# Load customer information
|
||||||
@@ -59,14 +59,14 @@ class IssuesFormHookListener < Redmine::Hook::ViewListener
|
|||||||
else
|
else
|
||||||
vehicles = [nil].compact
|
vehicles = [nil].compact
|
||||||
end
|
end
|
||||||
estimates = customer.qbo_estimates.pluck(:doc_number, :id).sort! {|x, y| y <=> x}
|
estimates = customer.estimates.pluck(:doc_number, :id).sort! {|x, y| y <=> x}
|
||||||
else
|
else
|
||||||
vehicles = [nil].compact
|
vehicles = [nil].compact
|
||||||
estimates = [nil].compact
|
estimates = [nil].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate the drop down list of quickbooks estimates & vehicles
|
# Generate the drop down list of quickbooks estimates & vehicles
|
||||||
select_estimate = f.select :qbo_estimate_id, estimates, :selected => selected_estimate, include_blank: true
|
select_estimate = f.select :estimate_id, estimates, :selected => selected_estimate, include_blank: true
|
||||||
vehicle = f.select :vehicles_id, vehicles, :selected => selected_vehicle, include_blank: true
|
vehicle = f.select :vehicles_id, vehicles, :selected => selected_vehicle, include_blank: true
|
||||||
|
|
||||||
# Pass all prebuilt form components to our partial
|
# Pass all prebuilt form components to our partial
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ class IssuesShowHookListener < Redmine::Hook::ViewListener
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Estimate Number
|
# Estimate Number
|
||||||
if issue.qbo_estimate
|
if issue.estimate
|
||||||
estimate = issue.qbo_estimate.doc_number
|
estimate = issue.estimate.doc_number
|
||||||
estimate_link = link_to estimate, estimate_path( issue.qbo_estimate.id ), :target => "_blank"
|
estimate_link = link_to estimate, estimate_path( issue.estimate.id ), :target => "_blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Invoice Number
|
# Invoice Number
|
||||||
invoice_link = ""
|
invoice_link = ""
|
||||||
if issue.qbo_invoice_ids
|
if issue.invoice_ids
|
||||||
issue.qbo_invoice_ids.each do |i|
|
issue.invoice_ids.each do |i|
|
||||||
invoice = QboInvoice.find i
|
invoice = Invoice.find i
|
||||||
invoice_link = invoice_link + link_to( invoice.doc_number, invoice_path( i ), :target => "_blank").to_s + " "
|
invoice_link = invoice_link + link_to( invoice.doc_number, invoice_path( i ), :target => "_blank").to_s + " "
|
||||||
invoice_link = invoice_link.html_safe
|
invoice_link = invoice_link.html_safe
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ module QueryPatch
|
|||||||
unless @available_columns
|
unless @available_columns
|
||||||
@available_columns = self.class.available_columns.dup
|
@available_columns = self.class.available_columns.dup
|
||||||
@available_columns << QueryColumn.new(:customer, :sortable => "#{Issue.table_name}.customer_id", :groupable => true, :caption => :field_customer)
|
@available_columns << QueryColumn.new(:customer, :sortable => "#{Issue.table_name}.customer_id", :groupable => true, :caption => :field_customer)
|
||||||
@available_columns << QueryColumn.new(:qbo_billed, :sortable => "#{TimeEntry.table_name}.qbo_billed", :groupable => true, :caption => :field_qbo_billed)
|
@available_columns << QueryColumn.new(:billed, :sortable => "#{TimeEntry.table_name}.billed", :groupable => true, :caption => :field_billed)
|
||||||
end
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ module TimeEntryQueryPatch
|
|||||||
def available_columns
|
def available_columns
|
||||||
unless @available_columns
|
unless @available_columns
|
||||||
@available_columns = self.class.available_columns.dup
|
@available_columns = self.class.available_columns.dup
|
||||||
@available_columns << QueryColumn.new(:qbo_billed, :sortable => "#{TimeEntry.table_name}.name", :groupable => true, :caption => :field_qbo_billed)
|
@available_columns << QueryColumn.new(:billed, :sortable => "#{TimeEntry.table_name}.name", :groupable => true, :caption => :field_billed)
|
||||||
end
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add QBO options to the filter
|
# Add QBO options to the filter
|
||||||
def initialize_available_filters
|
def initialize_available_filters
|
||||||
add_available_filter "qbo_billed", :type => :boolean
|
add_available_filter "billed", :type => :boolean
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2017 rick barrette
|
#Copyright (c) 2022 rick barrette
|
||||||
#
|
#
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
@@ -21,7 +21,7 @@ module UserPatch
|
|||||||
# Same as typing in the class
|
# Same as typing in the class
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
unloadable # Send unloadable so it will not be unloaded in development
|
unloadable # Send unloadable so it will not be unloaded in development
|
||||||
belongs_to :qbo_employee, primary_key: :id
|
belongs_to :employee, primary_key: :id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2017 rick barrette
|
#Copyright (c) 2022 rick barrette
|
||||||
#
|
#
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
@@ -14,12 +14,12 @@ class UsersShowHookListener < Redmine::Hook::ViewListener
|
|||||||
def view_users_form(context={})
|
def view_users_form(context={})
|
||||||
|
|
||||||
# Update the users
|
# Update the users
|
||||||
#QboEmployee.update_all
|
#Employee.update_all
|
||||||
|
|
||||||
# Check to see if there is a quickbooks user attached to the issue
|
# Check to see if there is a quickbooks user attached to the issue
|
||||||
@selected = context[:user].qbo_employee.id if context[:user].qbo_employee
|
@selected = context[:user].employee.id if context[:user].employee
|
||||||
|
|
||||||
# Generate the drop down list of quickbooks contacts
|
# Generate the drop down list of quickbooks contacts
|
||||||
return "<p>#{context[:form].select :qbo_employee_id, QboEmployee.all.pluck(:name, :id), :selected => @selected, include_blank: true}</p>"
|
return "<p>#{context[:form].select :employee_id, Employee.all.pluck(:name, :id), :selected => @selected, include_blank: true}</p>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
class QboEmployeeTest < ActiveSupport::TestCase
|
class EmployeeTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
# Replace this with your real tests.
|
# Replace this with your real tests.
|
||||||
def test_truth
|
def test_truth
|
||||||
|
|||||||
Reference in New Issue
Block a user