mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fd1bc9dff | |||
| 04391f1c6e | |||
| e2bf42e66b | |||
| 0c72ca9294 | |||
| 2985fad77c | |||
| 02b5fb4d0e | |||
| bf417c163c | |||
| b35974e455 | |||
| 6d0abf865e | |||
| 275af9be82 | |||
| f4e44a1975 | |||
| 81f322b616 | |||
| f094ef57ec | |||
| 2e32d8f6e5 | |||
| 3e352f270d | |||
| 45056e8ff4 | |||
| b13abe51bf | |||
| c3513427de | |||
| 7a6b6882d2 | |||
| d6ec34cef9 | |||
| 84dfdd707a | |||
| 517a239485 | |||
| 47868051f8 | |||
| 96e4e9df66 | |||
| 7d510e4028 | |||
| 6760b29148 | |||
| 122063b1d5 | |||
| b304c3a175 | |||
| 5b89d73c20 | |||
| 8380dda25a |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 - 2022 Rick Barrette
|
Copyright (c) 2016 - 2023 Rick Barrette
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class CustomersController < ApplicationController
|
|||||||
autocomplete :customer, :name, :full => true, :extra_data => [:id]
|
autocomplete :customer, :name, :full => true, :extra_data => [:id]
|
||||||
|
|
||||||
def allowed_params
|
def allowed_params
|
||||||
params.require(:customer).permit(:name, :email, :primary_phone, :mobile_phone, :phone_number)
|
params.require(:customer).permit(:name, :email, :primary_phone, :mobile_phone, :phone_number, :notes)
|
||||||
end
|
end
|
||||||
|
|
||||||
# getter method for a customer's vehicles
|
# getter method for a customer's vehicles
|
||||||
@@ -115,7 +115,7 @@ class CustomersController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
begin
|
begin
|
||||||
@customer = Customer.find_by_id(params[:id])
|
@customer = Customer.find_by_id(params[:id])
|
||||||
if @customer.update_attributes(allowed_params)
|
if @customer.update(allowed_params)
|
||||||
flash[:notice] = "Customer updated"
|
flash[:notice] = "Customer updated"
|
||||||
redirect_to @customer
|
redirect_to @customer
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -20,10 +20,13 @@ class InvoiceController < ApplicationController
|
|||||||
#
|
#
|
||||||
def show
|
def show
|
||||||
begin
|
begin
|
||||||
base = Invoice.get_base
|
qbo = Qbo.first
|
||||||
invoice = base.fetch_by_id(params[:id])
|
qbo.perform_authenticated_request do |access_token|
|
||||||
@pdf = base.pdf(invoice)
|
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
invoice = service.fetch_by_id(params[:id])
|
||||||
|
@pdf = service.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"
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
redirect_to :back, :flash => { :error => "Invoice not found" }
|
redirect_to :back, :flash => { :error => "Invoice not found" }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -26,7 +26,7 @@ class QboController < ApplicationController
|
|||||||
# Called when the user requests that Redmine to connect to QBO
|
# Called when the user requests that Redmine to connect to QBO
|
||||||
#
|
#
|
||||||
def authenticate
|
def authenticate
|
||||||
oauth2_client = Qbo.get_client
|
oauth2_client = Qbo.construct_oauth2_client
|
||||||
callback = Setting.host_name + "/qbo/oauth_callback/"
|
callback = Setting.host_name + "/qbo/oauth_callback/"
|
||||||
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
|
||||||
@@ -37,7 +37,7 @@ class QboController < ApplicationController
|
|||||||
#
|
#
|
||||||
def oauth_callback
|
def oauth_callback
|
||||||
if params[:state].present?
|
if params[:state].present?
|
||||||
oauth2_client = Qbo.get_client
|
oauth2_client = Qbo.construct_oauth2_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 = 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)
|
||||||
@@ -47,12 +47,8 @@ class QboController < ApplicationController
|
|||||||
|
|
||||||
# Save the authentication information
|
# Save the authentication information
|
||||||
qbo = Qbo.new
|
qbo = Qbo.new
|
||||||
qbo.company_id = params[:realmId]
|
qbo.update(oauth2_access_token: resp.token, oauth2_refresh_token: resp.refresh_token, realm_id: params[:realmId])
|
||||||
|
qbo.refresh_token!
|
||||||
# Generate Access Token & Serialize it into the database
|
|
||||||
access_token = OAuth2::AccessToken.new(oauth2_client, resp.token, refresh_token: resp.refresh_token)
|
|
||||||
qbo.token = access_token.to_hash
|
|
||||||
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 qbo_sync_path, :flash => { :notice => "Successfully connected to Quickbooks" }
|
||||||
@@ -145,7 +141,6 @@ class QboController < ApplicationController
|
|||||||
if Qbo.exists?
|
if Qbo.exists?
|
||||||
Customer.sync
|
Customer.sync
|
||||||
Invoice.sync
|
Invoice.sync
|
||||||
QboItem.sync
|
|
||||||
Employee.sync
|
Employee.sync
|
||||||
Estimate.sync
|
Estimate.sync
|
||||||
|
|
||||||
@@ -155,6 +150,6 @@ class QboController < ApplicationController
|
|||||||
ActiveRecord::Base.connection.close
|
ActiveRecord::Base.connection.close
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to :home, :flash => { :notice => "Successfully synced to Quickbooks" }
|
redirect_to :home, :flash => { :notice => "Syncing Quickbooks" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module AuthHelper
|
|||||||
def require_user
|
def require_user
|
||||||
return unless session[:token].nil?
|
return unless session[:token].nil?
|
||||||
if !User.current.logged?
|
if !User.current.logged?
|
||||||
render :file => "public/401.html.erb", :status => :unauthorized, :layout =>true
|
render_403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,14 +27,14 @@ module AuthHelper
|
|||||||
|
|
||||||
def check_permission(permission)
|
def check_permission(permission)
|
||||||
if !allowed_to?(permission)
|
if !allowed_to?(permission)
|
||||||
render :file => "public/401.html.erb", :status => :unauthorized, :layout =>true
|
render_403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def global_check_permission(permission)
|
def global_check_permission(permission)
|
||||||
if !globaly_allowed_to?(permission)
|
if !globaly_allowed_to?(permission)
|
||||||
render :file => "public/401.html.erb", :status => :unauthorized, :layout =>true
|
render_403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
80
app/models/concerns/quickbooks_oauth.rb
Normal file
80
app/models/concerns/quickbooks_oauth.rb
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2023 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.
|
||||||
|
|
||||||
|
module QuickbooksOauth
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
OAUTH_CONSUMER_KEY = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey']
|
||||||
|
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret']
|
||||||
|
|
||||||
|
#== Instance Methods
|
||||||
|
|
||||||
|
def perform_authenticated_request(&block)
|
||||||
|
attempts = 0
|
||||||
|
begin
|
||||||
|
yield oauth_access_token
|
||||||
|
rescue OAuth2::Error, Quickbooks::AuthorizationFailure => ex
|
||||||
|
Rails.logger.info("QuickbooksOauth.perform: #{ex.message}")
|
||||||
|
|
||||||
|
# to prevent an infinite loop here keep a counter and bail out after N times...
|
||||||
|
attempts += 1
|
||||||
|
|
||||||
|
raise "QuickbooksOauth:ExceededAuthAttempts" if attempts >= 3
|
||||||
|
|
||||||
|
# check if its an invalid_grant first, but assume it is for now
|
||||||
|
refresh_token!
|
||||||
|
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def refresh_token!
|
||||||
|
t = oauth_access_token
|
||||||
|
refreshed = t.refresh!
|
||||||
|
|
||||||
|
if refreshed.params['x_refresh_token_expires_in'].to_i > 0
|
||||||
|
oauth2_refresh_token_expires_at = Time.now + refreshed.params['x_refresh_token_expires_in'].to_i.seconds
|
||||||
|
else
|
||||||
|
oauth2_refresh_token_expires_at = 100.days.from_now
|
||||||
|
end
|
||||||
|
|
||||||
|
update!(
|
||||||
|
oauth2_access_token: refreshed.token,
|
||||||
|
oauth2_access_token_expires_at: Time.at(refreshed.expires_at),
|
||||||
|
oauth2_refresh_token: refreshed.refresh_token,
|
||||||
|
oauth2_refresh_token_expires_at: oauth2_refresh_token_expires_at
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def oauth_client
|
||||||
|
self.class.construct_oauth2_client
|
||||||
|
end
|
||||||
|
|
||||||
|
def oauth_access_token
|
||||||
|
OAuth2::AccessToken.new(oauth_client, oauth2_access_token, refresh_token: oauth2_refresh_token)
|
||||||
|
end
|
||||||
|
|
||||||
|
def consumer
|
||||||
|
oauth_access_token
|
||||||
|
end
|
||||||
|
|
||||||
|
module ClassMethods
|
||||||
|
|
||||||
|
def construct_oauth2_client
|
||||||
|
options = {
|
||||||
|
site: "https://appcenter.intuit.com/connect/oauth2",
|
||||||
|
authorize_url: "https://appcenter.intuit.com/connect/oauth2",
|
||||||
|
token_url: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
|
||||||
|
}
|
||||||
|
OAuth2::Client.new(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -88,6 +88,13 @@ class Customer < ActiveRecord::Base
|
|||||||
update_mobile_phone_number
|
update_mobile_phone_number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Convenience Method
|
||||||
|
# Sets the notes
|
||||||
|
def notes=(s)
|
||||||
|
pull unless @details
|
||||||
|
@details.notes = s
|
||||||
|
end
|
||||||
|
|
||||||
# update the localy stored phone number as a plain string with no special chars
|
# update the localy stored phone number as a plain string with no special chars
|
||||||
def update_phone_number
|
def update_phone_number
|
||||||
begin
|
begin
|
||||||
@@ -135,28 +142,26 @@ class Customer < ActiveRecord::Base
|
|||||||
# proforms a bruteforce sync operation
|
# proforms a bruteforce sync operation
|
||||||
# This needs to be simplified
|
# This needs to be simplified
|
||||||
def self.sync
|
def self.sync
|
||||||
service = Qbo.get_base(:customer)
|
|
||||||
|
|
||||||
# Sync ALL customers if the database is empty
|
# Sync ALL customers if the database is empty
|
||||||
#if count == 0
|
qbo = Qbo.first
|
||||||
customers = service.all
|
customers = qbo.perform_authenticated_request do |access_token|
|
||||||
#else
|
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
# last = Qbo.first.last_sync
|
service.all
|
||||||
# query = "Select Id, DisplayName From Customer"
|
end
|
||||||
# query << " Where Metadata.LastUpdatedTime >= '#{last.iso8601}' " if last
|
|
||||||
# customers = service.query(query)
|
|
||||||
#end
|
|
||||||
|
|
||||||
customers.each do |customer|
|
return unless customers
|
||||||
customer = Customer.find_or_create_by(id: customer.id)
|
|
||||||
if customer.active?
|
customers.each do |c|
|
||||||
if not customer.name.eql? customer.display_name
|
logger.info "Processing customer #{c.id}"
|
||||||
customer.name = customer.display_name
|
customer = Customer.find_or_create_by(id: c.id)
|
||||||
customer.id = customer.id
|
if c.active?
|
||||||
|
if not customer.name.eql? c.display_name
|
||||||
|
customer.name = c.display_name
|
||||||
|
customer.id = c.id
|
||||||
customer.save_without_push
|
customer.save_without_push
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not customer.new_record?
|
if not c.new_record?
|
||||||
customer.delete
|
customer.delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -172,9 +177,14 @@ class Customer < ActiveRecord::Base
|
|||||||
# proforms a bruteforce sync operation
|
# proforms a bruteforce sync operation
|
||||||
# This needs to be simplified
|
# This needs to be simplified
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
service = Qbo.get_base(:customer)
|
qbo = Qbo.first
|
||||||
|
customer = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.fetch_by_id(id)
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless customer
|
||||||
|
|
||||||
customer = service.fetch_by_id(id)
|
|
||||||
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 customer.name.eql? customer.display_name
|
if not customer.name.eql? customer.display_name
|
||||||
@@ -192,7 +202,11 @@ class Customer < ActiveRecord::Base
|
|||||||
# Push the updates
|
# Push the updates
|
||||||
def save_with_push
|
def save_with_push
|
||||||
begin
|
begin
|
||||||
@details = Qbo.get_base(:customer).update(@details)
|
qbo = Qbo.first
|
||||||
|
@details = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
serivce.update(@details)
|
||||||
|
end
|
||||||
#raise "QBO Fault" if @details.fault?
|
#raise "QBO Fault" if @details.fault?
|
||||||
self.id = @details.id
|
self.id = @details.id
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@@ -210,7 +224,11 @@ class Customer < ActiveRecord::Base
|
|||||||
def pull
|
def pull
|
||||||
begin
|
begin
|
||||||
raise Exception unless self.id
|
raise Exception unless self.id
|
||||||
@details = Qbo.get_base(:customer).fetch_by_id(self.id)
|
qbo = Qbo.first
|
||||||
|
@details = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.fetch_by_id(self.id)
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@details = Quickbooks::Model::Customer.new
|
@details = Quickbooks::Model::Customer.new
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -13,26 +13,35 @@ class Employee < ActiveRecord::Base
|
|||||||
has_many :users
|
has_many :users
|
||||||
validates_presence_of :id, :name
|
validates_presence_of :id, :name
|
||||||
|
|
||||||
def self.get_base
|
def self.sync
|
||||||
Qbo.get_base(:employee)
|
qbo = Qbo.first
|
||||||
|
employees = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Employee.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sync
|
return unless employees
|
||||||
employees = get_base.all
|
|
||||||
|
|
||||||
transaction do
|
transaction do
|
||||||
# Update the item table
|
# Update the item table
|
||||||
employees.each { |employee|
|
employees.each { |e|
|
||||||
employee = find_or_create_by(id: employee.id)
|
logger.info "Processing employee #{e.id}"
|
||||||
employee.name = employee.display_name
|
employee = find_or_create_by(id: e.id)
|
||||||
employee.id = employee.id
|
employee.name = e.display_name
|
||||||
|
employee.id = e.id
|
||||||
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)
|
qbo = Qbo.first
|
||||||
|
employee = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Employee.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.fetch_by_id(id)
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless employee
|
||||||
employee = find_or_create_by(id: employee.id)
|
employee = find_or_create_by(id: employee.id)
|
||||||
employee.name = employee.display_name
|
employee.name = employee.display_name
|
||||||
employee.id = employee.id
|
employee.id = employee.id
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -16,15 +16,17 @@ class Estimate < ActiveRecord::Base
|
|||||||
validates_presence_of :doc_number, :id
|
validates_presence_of :doc_number, :id
|
||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
|
|
||||||
# return the QBO Estimate service
|
|
||||||
def self.get_base
|
|
||||||
Qbo.get_base(:estimate)
|
|
||||||
end
|
|
||||||
|
|
||||||
# sync all estimates
|
# sync all estimates
|
||||||
def self.sync
|
def self.sync
|
||||||
logger.debug "Syncing ALL estimates"
|
logger.debug "Syncing ALL estimates"
|
||||||
estimates = get_base.all
|
qbo = Qbo.first
|
||||||
|
estimates = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.all
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless estimates
|
||||||
|
|
||||||
estimates.each { |estimate|
|
estimates.each { |estimate|
|
||||||
process_estimate(estimate)
|
process_estimate(estimate)
|
||||||
}
|
}
|
||||||
@@ -36,17 +38,28 @@ class Estimate < ActiveRecord::Base
|
|||||||
# sync only one estimate
|
# sync only one estimate
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
logger.debug "Syncing estimate #{id}"
|
logger.debug "Syncing estimate #{id}"
|
||||||
process_estimate(get_base.fetch_by_id(id))
|
qbo = Qbo.first
|
||||||
|
qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
process_estimate(service.fetch_by_id(id))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# update an estimate
|
# update an estimate
|
||||||
def self.update(id)
|
def self.update(id)
|
||||||
# Update the item table
|
# Update the item table
|
||||||
estimate = get_base.fetch_by_id(id)
|
qbo = Qbo.first
|
||||||
estimate = find_or_create_by(id: id)
|
estimate = qbo.perform_authenticated_request do |access_token|
|
||||||
estimate.doc_number = estimate.doc_number
|
service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
estimate.txn_date = estimate.txn_date
|
service.fetch_by_id(id)
|
||||||
estimate.save!
|
end
|
||||||
|
|
||||||
|
return unless estimate
|
||||||
|
|
||||||
|
e = find_or_create_by(id: id)
|
||||||
|
e.doc_number = estimate.doc_number
|
||||||
|
e.txn_date = estimate.txn_date
|
||||||
|
e.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
# process an estimate into the database
|
# process an estimate into the database
|
||||||
@@ -62,9 +75,12 @@ class Estimate < ActiveRecord::Base
|
|||||||
|
|
||||||
# download the pdf from quickbooks
|
# download the pdf from quickbooks
|
||||||
def pdf
|
def pdf
|
||||||
base = Estimate.get_base
|
qbo = Qbo.first
|
||||||
estimate = base.fetch_by_id(id)
|
qbo.perform_authenticated_request do |access_token|
|
||||||
return base.pdf(estimate)
|
service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
estimate = service.fetch_by_id(id)
|
||||||
|
service.pdf(estimate)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Magic Method
|
# Magic Method
|
||||||
@@ -91,7 +107,11 @@ class Estimate < ActiveRecord::Base
|
|||||||
def pull
|
def pull
|
||||||
begin
|
begin
|
||||||
raise Exception unless self.id
|
raise Exception unless self.id
|
||||||
@details = Qbo.get_base(:estimate).fetch_by_id(self.id)
|
qbo = Qbo.first
|
||||||
|
@details = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Estimate.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service(:estimate).fetch_by_id(self.id)
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@details = Quickbooks::Model::Estimate.new
|
@details = Quickbooks::Model::Estimate.new
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -15,11 +15,6 @@ class Invoice < ActiveRecord::Base
|
|||||||
validates_presence_of :doc_number, :id, :customer_id, :txn_date
|
validates_presence_of :doc_number, :id, :customer_id, :txn_date
|
||||||
self.primary_key = :id
|
self.primary_key = :id
|
||||||
|
|
||||||
# Get the quickbooks-ruby base for invoice
|
|
||||||
def self.get_base
|
|
||||||
Qbo.get_base(:invoice)
|
|
||||||
end
|
|
||||||
|
|
||||||
# sync ALL the invoices
|
# sync ALL the invoices
|
||||||
def self.sync
|
def self.sync
|
||||||
logger.debug "Syncing all invoices"
|
logger.debug "Syncing all invoices"
|
||||||
@@ -30,12 +25,14 @@ class Invoice < ActiveRecord::Base
|
|||||||
|
|
||||||
# TODO actually do something with the above query
|
# TODO actually do something with the above query
|
||||||
# .all() is never called since count is never initialized
|
# .all() is never called since count is never initialized
|
||||||
if count == 0
|
qbo = Qbo.first
|
||||||
invoices = get_base.all
|
invoices = qbo.perform_authenticated_request do |access_token|
|
||||||
else
|
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
invoices = get_base.query()
|
service.all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return unless invoices
|
||||||
|
|
||||||
invoices.each { | invoice |
|
invoices.each { | invoice |
|
||||||
process_invoice invoice
|
process_invoice invoice
|
||||||
}
|
}
|
||||||
@@ -44,9 +41,13 @@ class Invoice < ActiveRecord::Base
|
|||||||
#sync by invoice ID
|
#sync by invoice ID
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
logger.debug "Syncing invoice #{id}"
|
logger.debug "Syncing invoice #{id}"
|
||||||
invoice = get_base.fetch_by_id(id)
|
qbo = Qbo.first
|
||||||
|
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(id)
|
||||||
process_invoice invoice
|
process_invoice invoice
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
@@ -155,7 +156,11 @@ class Invoice < ActiveRecord::Base
|
|||||||
# Push updates
|
# Push updates
|
||||||
begin
|
begin
|
||||||
logger.debug "Trying to update invoice"
|
logger.debug "Trying to update invoice"
|
||||||
get_base.update(invoice) if is_changed
|
qbo = Qbo.first
|
||||||
|
qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.update(invoice) if is_changed
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
# 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
|
||||||
@@ -187,7 +192,11 @@ class Invoice < ActiveRecord::Base
|
|||||||
def pull
|
def pull
|
||||||
begin
|
begin
|
||||||
raise Exception unless self.id
|
raise Exception unless self.id
|
||||||
@details = Qbo.get_base(:invoice).fetch_by_id(self.id)
|
qbo = Qbo.first
|
||||||
|
@details = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.fetch_by_id(self.id)
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@details = Quickbooks::Model::Invoice.new
|
@details = Quickbooks::Model::Invoice.new
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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,85 +10,15 @@
|
|||||||
|
|
||||||
class Qbo < ActiveRecord::Base
|
class Qbo < ActiveRecord::Base
|
||||||
unloadable
|
unloadable
|
||||||
validates_presence_of :token, :company_id, :expire
|
|
||||||
serialize :token
|
|
||||||
|
|
||||||
OAUTH_CONSUMER_KEY = Setting.plugin_redmine_qbo['settingsOAuthConsumerKey']
|
include QuickbooksOauth
|
||||||
OAUTH_CONSUMER_SECRET = Setting.plugin_redmine_qbo['settingsOAuthConsumerSecret']
|
|
||||||
|
|
||||||
#
|
|
||||||
# Getter for quickbooks OAuth2 client
|
|
||||||
#
|
|
||||||
def self.get_client
|
|
||||||
oauth_params = {
|
|
||||||
site: "https://appcenter.intuit.com/connect/oauth2",
|
|
||||||
authorize_url: "https://appcenter.intuit.com/connect/oauth2",
|
|
||||||
token_url: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer"
|
|
||||||
}
|
|
||||||
return OAuth2::Client.new(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, oauth_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
|
||||||
# Getter for oauth consumer
|
|
||||||
#
|
|
||||||
def self.get_oauth_consumer
|
|
||||||
# Quickbooks Config Info
|
|
||||||
return $qb_oauth_consumer
|
|
||||||
end
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get a quickbooks base service object for type
|
|
||||||
# @params type of base
|
|
||||||
#
|
|
||||||
def self.get_base(type)
|
|
||||||
# lets getnourbold access token from the database
|
|
||||||
oauth2_client = get_client
|
|
||||||
qbo = self.first
|
|
||||||
access_token = OAuth2::AccessToken.from_hash(oauth2_client, qbo.token)
|
|
||||||
|
|
||||||
# check to see if we need to refresh the acesstoken
|
|
||||||
if qbo.expire.to_time.utc.past?
|
|
||||||
puts "Updating access token"
|
|
||||||
new_access_token_object = access_token.refresh!
|
|
||||||
qbo.token = new_access_token_object.to_hash
|
|
||||||
qbo.expire = 1.hour.from_now.utc
|
|
||||||
qbo.save!
|
|
||||||
access_token = new_access_token_object
|
|
||||||
else
|
|
||||||
puts "Using current token"
|
|
||||||
end
|
|
||||||
|
|
||||||
# build the reqiested service
|
|
||||||
case type
|
|
||||||
when :item
|
|
||||||
return Quickbooks::Service::Item.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
when :time_activity
|
|
||||||
return Quickbooks::Service::TimeActivity.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
when :customer
|
|
||||||
return Quickbooks::Service::Customer.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
when :invoice
|
|
||||||
return Quickbooks::Service::Invoice.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
when :estimate
|
|
||||||
return Quickbooks::Service::Estimate.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
when :account
|
|
||||||
return Quickbooks::Service::Account.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
when :employee
|
|
||||||
return Quickbooks::Service::Employee.new(:company_id => qbo.company_id, :access_token => access_token)
|
|
||||||
else
|
|
||||||
return access_token
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Get the QBO account
|
|
||||||
def self.get_account
|
|
||||||
first
|
|
||||||
end
|
|
||||||
|
|
||||||
# Updates last sync time stamp
|
# Updates last sync time stamp
|
||||||
def self.update_time_stamp
|
def self.update_time_stamp
|
||||||
|
date = DateTime.now
|
||||||
|
logger.info "Updating QBO timestamp to #{date}"
|
||||||
qbo = Qbo.first
|
qbo = Qbo.first
|
||||||
qbo.last_sync = DateTime.now
|
qbo.last_sync = date
|
||||||
qbo.save
|
qbo.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<%= flash.now[:error] = t(:label_401) %>
|
|
||||||
@@ -59,7 +59,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_oauth_expires)%></th>
|
<th><%=t(:label_oauth_expires)%></th>
|
||||||
<td><%= if Qbo.exists? then Qbo.first.expire end %>
|
<td><%= if Qbo.exists? then Qbo.first.oauth2_access_token_expires_at end %>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><%=t(:label_oauth2_refresh_token_expires_at)%></th>
|
||||||
|
<td><%= if Qbo.exists? then Qbo.first.oauth2_refresh_token_expires_at end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ en:
|
|||||||
label_search_estimates: "Search Estimates"
|
label_search_estimates: "Search Estimates"
|
||||||
label_search: "Search"
|
label_search: "Search"
|
||||||
label_estimates: "Estimates"
|
label_estimates: "Estimates"
|
||||||
label_401: "Not Authorized"
|
|
||||||
warn_ru_sure: "You sure?"
|
warn_ru_sure: "You sure?"
|
||||||
label_delete: "Delete"
|
label_delete: "Delete"
|
||||||
label_edit: "Edit"
|
label_edit: "Edit"
|
||||||
@@ -88,4 +87,5 @@ en:
|
|||||||
label_billing_error: "Cannot bill without a customer assigned"
|
label_billing_error: "Cannot bill without a customer assigned"
|
||||||
label_qbo_sync_success: "Successfully synced to Quickbooks"
|
label_qbo_sync_success: "Successfully synced to Quickbooks"
|
||||||
label_hours: "Hours"
|
label_hours: "Hours"
|
||||||
|
label_oauth2_refresh_token_expires_at: "Refresh Token Expires At"
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -26,7 +26,13 @@ class AddTxnDates < ActiveRecord::Migration[5.1]
|
|||||||
|
|
||||||
say "Sync Invoices"
|
say "Sync Invoices"
|
||||||
|
|
||||||
invoices = QboInvoice.get_base.all
|
qbo = Qbo.first
|
||||||
|
invoices = qbo.perform_authenticated_request do |access_token|
|
||||||
|
service = Quickbooks::Service::Invoice.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
service.all
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless invoices
|
||||||
|
|
||||||
invoices.each { |invoice|
|
invoices.each { |invoice|
|
||||||
# Load the invoice into the database
|
# Load the invoice into the database
|
||||||
|
|||||||
22
db/migrate/037_update_qbo_token.rb
Normal file
22
db/migrate/037_update_qbo_token.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2023 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 UpdateQboToken < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
add_column :qbos, :oauth2_access_token, :text
|
||||||
|
add_column :qbos, :oauth2_access_token_expires_at, :datetime
|
||||||
|
add_column :qbos, :oauth2_refresh_token, :text
|
||||||
|
add_column :qbos, :oauth2_refresh_token_expires_at, :datetime
|
||||||
|
add_column :qbos, :realm_id, :text
|
||||||
|
remove_column :qbos, :company_id
|
||||||
|
remove_column :qbos, :token
|
||||||
|
remove_column :qbos, :expire
|
||||||
|
end
|
||||||
|
end
|
||||||
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 '2.0.0'
|
version '2.0.2'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo'
|
url 'https://github.com/rickbarrette/redmine_qbo'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
settings :default => {'empty' => true}, :partial => 'qbo/settings'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#The MIT License (MIT)
|
#The MIT License (MIT)
|
||||||
#
|
#
|
||||||
#Copyright (c) 2022 rick barrette
|
#Copyright (c) 2023 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:
|
||||||
#
|
#
|
||||||
@@ -52,8 +52,10 @@ module IssuePatch
|
|||||||
if spent_hours > 0 then
|
if spent_hours > 0 then
|
||||||
|
|
||||||
# Prepare to create a new Time Activity
|
# Prepare to create a new Time Activity
|
||||||
time_service = Qbo.get_base(:time_activity)
|
qbo = Qbo.first
|
||||||
item_service = Qbo.get_base(:item)
|
qbo.perform_authenticated_request do |access_token|
|
||||||
|
time_service = Quickbooks::Service::TimeActivity.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
|
item_service = Quickbooks::Service::Item.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
time_entry = Quickbooks::Model::TimeActivity.new
|
time_entry = Quickbooks::Model::TimeActivity.new
|
||||||
|
|
||||||
# Lets total up each activity before billing.
|
# Lets total up each activity before billing.
|
||||||
@@ -96,6 +98,7 @@ module IssuePatch
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Create a shareable link for a customer
|
# Create a shareable link for a customer
|
||||||
def share_token
|
def share_token
|
||||||
|
|||||||
Reference in New Issue
Block a user