mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 08:54:23 -05:00
Compare commits
21 Commits
hooks
...
4f789080e7
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f789080e7 | |||
| 80fc858a35 | |||
| 6f8d280657 | |||
| 5782cbc166 | |||
| 0729d2ac41 | |||
| 6c6de0ba86 | |||
| 11dbcaf80c | |||
| 95592e542f | |||
| 472bdec4fa | |||
| c7a313e9ed | |||
| c14b590083 | |||
| 040c920481 | |||
| 8c63817950 | |||
| e2f43d398f | |||
| 7ba4829066 | |||
| 938999db91 | |||
| 0b60a8e41b | |||
| 817a43e849 | |||
| 047296329e | |||
| c8cb74f3d4 | |||
| aceb6cb6b5 |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 - 2023 Rick Barrette
|
Copyright (c) 2016 - 2024 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
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ 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
|
||||||
|
redirect_uri = "https://" + Setting.host_name + qbo_oauth_callback_path
|
||||||
|
logger.info "redirect_uri: " + redirect_uri
|
||||||
oauth2_client = Qbo.construct_oauth2_client
|
oauth2_client = Qbo.construct_oauth2_client
|
||||||
callback = Setting.host_name + "/qbo/oauth_callback/"
|
grant_url = oauth2_client.auth_code.authorize_url(redirect_uri: redirect_uri, 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
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ class QboController < ApplicationController
|
|||||||
if params[:state].present?
|
if params[:state].present?
|
||||||
oauth2_client = Qbo.construct_oauth2_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 = "https://" + Setting.host_name + qbo_oauth_callback_path
|
||||||
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)
|
||||||
|
|
||||||
# Remove the last authentication information
|
# Remove the last authentication information
|
||||||
@@ -123,7 +124,7 @@ class QboController < ApplicationController
|
|||||||
Qbo.update_time_stamp
|
Qbo.update_time_stamp
|
||||||
|
|
||||||
# The webhook doesn't require a response but let's make sure we don't send anything
|
# The webhook doesn't require a response but let's make sure we don't send anything
|
||||||
render :nothing => true
|
render :nothing => true, status: 200
|
||||||
else
|
else
|
||||||
render nothing: true, status: 400
|
render nothing: true, status: 400
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class VehiclesController < ApplicationController
|
|||||||
@customer = params[:customer]
|
@customer = params[:customer]
|
||||||
begin
|
begin
|
||||||
@vehicle = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
if @vehicle.update_attributes(allowed_params)
|
if @vehicle.update(allowed_params)
|
||||||
flash[:notice] = "Vehicle updated"
|
flash[:notice] = "Vehicle updated"
|
||||||
redirect_to @vehicle
|
redirect_to @vehicle
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -155,11 +155,13 @@ class Customer < ActiveRecord::Base
|
|||||||
logger.info "Processing customer #{c.id}"
|
logger.info "Processing customer #{c.id}"
|
||||||
customer = Customer.find_or_create_by(id: c.id)
|
customer = Customer.find_or_create_by(id: c.id)
|
||||||
if c.active?
|
if c.active?
|
||||||
if not customer.name.eql? c.display_name
|
#if not customer.name.eql? c.display_name
|
||||||
customer.name = c.display_name
|
customer.name = c.display_name
|
||||||
customer.id = c.id
|
customer.id = c.id
|
||||||
|
customer.phone_number = c.primary_phone.free_form_number.tr('^0-9', '') unless c.primary_phone.nil?
|
||||||
|
customer.mobile_phone_number = c.mobile_phone.free_form_number.tr('^0-9', '') unless c.mobile_phone.nil?
|
||||||
customer.save_without_push
|
customer.save_without_push
|
||||||
end
|
#end
|
||||||
else
|
else
|
||||||
if not c.new_record?
|
if not c.new_record?
|
||||||
customer.delete
|
customer.delete
|
||||||
@@ -178,20 +180,22 @@ class Customer < ActiveRecord::Base
|
|||||||
# This needs to be simplified
|
# This needs to be simplified
|
||||||
def self.sync_by_id(id)
|
def self.sync_by_id(id)
|
||||||
qbo = Qbo.first
|
qbo = Qbo.first
|
||||||
customer = qbo.perform_authenticated_request do |access_token|
|
c = qbo.perform_authenticated_request do |access_token|
|
||||||
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
service.fetch_by_id(id)
|
service.fetch_by_id(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless customer
|
return unless c
|
||||||
|
|
||||||
customer = Customer.find_or_create_by(id: customer.id)
|
customer = Customer.find_or_create_by(id: c.id)
|
||||||
if customer.active?
|
if c.active?
|
||||||
if not customer.name.eql? customer.display_name
|
#if not customer.name.eql? c.display_name
|
||||||
customer.name = customer.display_name
|
customer.name = c.display_name
|
||||||
customer.id = customer.id
|
customer.id = c.id
|
||||||
|
customer.phone_number = c.primary_phone.free_form_number.tr('^0-9', '') unless c.primary_phone.nil?
|
||||||
|
customer.mobile_phone_number = c.mobile_phone.free_form_number.tr('^0-9', '') unless c.mobile_phone.nil?
|
||||||
customer.save_without_push
|
customer.save_without_push
|
||||||
end
|
#end
|
||||||
else
|
else
|
||||||
if not customer.new_record?
|
if not customer.new_record?
|
||||||
customer.delete
|
customer.delete
|
||||||
@@ -205,7 +209,7 @@ class Customer < ActiveRecord::Base
|
|||||||
qbo = Qbo.first
|
qbo = Qbo.first
|
||||||
@details = qbo.perform_authenticated_request do |access_token|
|
@details = qbo.perform_authenticated_request do |access_token|
|
||||||
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
service = Quickbooks::Service::Customer.new(:company_id => qbo.realm_id, :access_token => access_token)
|
||||||
serivce.update(@details)
|
service.update(@details)
|
||||||
end
|
end
|
||||||
#raise "QBO Fault" if @details.fault?
|
#raise "QBO Fault" if @details.fault?
|
||||||
self.id = @details.id
|
self.id = @details.id
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th><%=t(:label_name)%></th>
|
||||||
|
<td><%= customer.name %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%=t(:label_email)%></th>
|
<th><%=t(:label_email)%></th>
|
||||||
<td><%= customer.email %></td>
|
<td><%= customer.email %></td>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h2><%=t(:field_customer)%> #<%= @customer.id %> - <%= @customer.name %> </h2>
|
<h2><%=t(:field_customer)%> #<%= @customer.id %> - <%= link_to @customer.to_s, "https://app.qbo.intuit.com/app/customerdetail?nameId=#{@customer.id}", target: :_blank %> </h2>
|
||||||
<div class="issue">
|
<div class="issue">
|
||||||
|
|
||||||
<div class="splitcontent">
|
<div class="splitcontent">
|
||||||
|
|||||||
@@ -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: '<%= qbo_authenticate_path %>'});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<table >
|
<table >
|
||||||
|
|||||||
@@ -88,4 +88,5 @@ en:
|
|||||||
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"
|
label_oauth2_refresh_token_expires_at: "Refresh Token Expires At"
|
||||||
|
label_name: "Name"
|
||||||
|
|
||||||
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.2'
|
version '2.1.0'
|
||||||
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'
|
||||||
|
|||||||
Reference in New Issue
Block a user