mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 08:21:57 -04:00
Compare commits
4 Commits
3e6650ee65
...
020ea01d36
| Author | SHA1 | Date | |
|---|---|---|---|
| 020ea01d36 | |||
| df079b767c | |||
| 7d3908ec41 | |||
| f60e507029 |
26
app/controllers/employees_controller.rb
Normal file
26
app/controllers/employees_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2016 - 2026 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 EmployeesController < ApplicationController
|
||||||
|
include AuthHelper
|
||||||
|
|
||||||
|
before_action :require_user, unless: -> { session[:token].nil? }
|
||||||
|
|
||||||
|
def sync
|
||||||
|
Employee.sync
|
||||||
|
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Logs messages with a consistent prefix for easier debugging.
|
||||||
|
def log(msg)
|
||||||
|
Rails.logger.info "[EmployeeController] #{msg}"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
#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.
|
#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 EstimateController < ApplicationController
|
class EstimatesController < ApplicationController
|
||||||
include AuthHelper
|
include AuthHelper
|
||||||
|
|
||||||
before_action :require_user, unless: -> { session[:token].nil? }
|
before_action :require_user, unless: -> { session[:token].nil? }
|
||||||
@@ -24,6 +24,11 @@ class EstimateController < ApplicationController
|
|||||||
render_pdf(@estimate)
|
render_pdf(@estimate)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sync
|
||||||
|
Estimate.sync
|
||||||
|
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Loads the estimate based on ID or doc number, with a fallback to sync if not found locally.
|
# Loads the estimate based on ID or doc number, with a fallback to sync if not found locally.
|
||||||
@@ -72,13 +77,6 @@ class EstimateController < ApplicationController
|
|||||||
redirect_back fallback_location: root_path, flash: { error: I18n.t(:notice_estimate_not_found) }
|
redirect_back fallback_location: root_path, flash: { error: I18n.t(:notice_estimate_not_found) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync
|
|
||||||
Estimate.sync
|
|
||||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# Logs messages with a consistent prefix for easier debugging.
|
# Logs messages with a consistent prefix for easier debugging.
|
||||||
def log(msg)
|
def log(msg)
|
||||||
Rails.logger.info "[EstimateController] #{msg}"
|
Rails.logger.info "[EstimateController] #{msg}"
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
#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.
|
#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 InvoiceController < ApplicationController
|
class InvoicesController < ApplicationController
|
||||||
include AuthHelper
|
include AuthHelper
|
||||||
|
|
||||||
before_action :require_user, unless: -> { session[:token].nil? }
|
before_action :require_user, unless: -> { session[:token].nil? }
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<% estimates.sort.reverse.each do |estimate| %>
|
<% estimates.sort.reverse.each do |estimate| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<%= check_box_tag "estimate_ids[]", estimate.id, false, onchange: "updateLink()", data: { url: estimate_path(estimate), text: "Estimate ##{estimate.to_s}" }, class: "estimate-checkbox appointment" %>
|
<%= check_box_tag "estimate_ids[]", estimate.id, false, onchange: "updateLink()", data: { url: estimates_path(estimate), text: "Estimate ##{estimate.to_s}" }, class: "estimate-checkbox appointment" %>
|
||||||
<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>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,111 +1,79 @@
|
|||||||
<!--
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 - 2026 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- somewhere in your document include the Javascript -->
|
|
||||||
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
|
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
|
||||||
|
|
||||||
<!-- 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: '<%= qbo_authenticate_path %>'});
|
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_authenticate_path %>'});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<table >
|
<div class="box tabular">
|
||||||
<tbody>
|
<p>
|
||||||
|
<label><%= t(:label_client_id) %></label>
|
||||||
|
<%= text_field_tag 'settings[settingsOAuthConsumerKey]', settings['settingsOAuthConsumerKey'], size: 50 %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label><%= t(:label_client_secret) %></label>
|
||||||
|
<%= password_field_tag 'settings[settingsOAuthConsumerSecret]', settings['settingsOAuthConsumerSecret'], size: 50 %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<th><%=t(:label_client_id)%></th>
|
<label><%= t(:label_webhook_token) %></label>
|
||||||
<td>
|
<%= text_field_tag 'settings[settingsWebhookToken]', settings['settingsWebhookToken'], size: 50 %>
|
||||||
<input
|
</p>
|
||||||
type="text"
|
|
||||||
style="width:350px"
|
|
||||||
id="settingsOAuthConsumerKey"
|
|
||||||
value="<%= settings['settingsOAuthConsumerKey'] %>"
|
|
||||||
name="settings[settingsOAuthConsumerKey]" >
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<th><%=t(:label_client_secret)%></th>
|
<label><%= t(:label_sandbox) %></label>
|
||||||
<td>
|
<%= check_box_tag 'settings[sandbox]', 1, settings[:sandbox] %>
|
||||||
<input
|
</p>
|
||||||
type="text"
|
|
||||||
style="width:350px"
|
|
||||||
id="settingsOAuthConsumerSecret"
|
|
||||||
value="<%= settings['settingsOAuthConsumerSecret'] %>"
|
|
||||||
name="settings[settingsOAuthConsumerSecret]" >
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th><%=t(:label_webhook_token)%></th>
|
|
||||||
<td>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
style="width:350px"
|
|
||||||
id="settingsWebhookToken"
|
|
||||||
value="<%= settings['settingsWebhookToken'] %>"
|
|
||||||
name="settings[settingsWebhookToken]" >
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<hr />
|
||||||
<th><%=t(:label_sandbox)%></th>
|
|
||||||
<td>
|
|
||||||
<%= check_box_tag 'settings[sandbox]', @settings[:sandbox], @settings[:sandbox] %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<p>
|
||||||
<th><%=t(:label_oauth_expires)%></th>
|
<label><%= t(:label_oauth_expires) %></label>
|
||||||
<td><%= Qbo.oauth2_access_token_expires_at %>
|
<span class="icon <%= Qbo.oauth2_access_token_expires_at&.future? ? 'icon-ok' : 'icon-warning' %>">
|
||||||
</tr>
|
<%= Qbo.oauth2_access_token_expires_at || 'N/A' %>
|
||||||
|
</span>
|
||||||
<tr>
|
</p>
|
||||||
<th><%=t(:label_oauth2_refresh_token_expires_at)%></th>
|
|
||||||
<td><%= Qbo.oauth2_refresh_token_expires_at %>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
<p>
|
||||||
</table>
|
<label><%= t(:label_customer_count) %></label>
|
||||||
|
<%= Customer.count %>
|
||||||
|
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Customer.last_sync %>)</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
<br/>
|
<p>
|
||||||
<%=t(:label_oauth_note)%>
|
<label><%= t(:label_employee_count) %></label>
|
||||||
<br/>
|
<%= Employee.count %>
|
||||||
<br/>
|
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Employee.last_sync %>)</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
<!-- this will display a button that the user clicks to start the flow -->
|
<p>
|
||||||
<ipp:connectToIntuit></ipp:connectToIntuit>
|
<label><%= t(:label_invoice_count) %></label>
|
||||||
|
<%= Invoice.count %>
|
||||||
|
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Item.last_sync %>)</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
<br/>
|
<p>
|
||||||
<br/>
|
<label><%= t(:label_estimate_count) %></label>
|
||||||
|
<%= Estimate.count %>
|
||||||
|
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Account.last_sync %>)</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
<div>
|
<p>
|
||||||
<b><%=t(:label_customer_count)%>:</b> <%= Customer.count%> @ <%= Customer.last_sync %>
|
<label><%= t(:label_last_sync) %> (QBO)</label>
|
||||||
</div>
|
<%= Qbo.exists? ? Qbo.last_sync : 'Never synced' %>
|
||||||
|
</p>
|
||||||
<div>
|
|
||||||
<b><%=t(:label_employee_count)%>:</b> <%= Employee.count %> @ <%= Employee.last_sync %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<b><%=t(:label_invoice_count)%>:</b> <%= Invoice.count %> @ <%= Invoice.last_sync%>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<b><%=t(:label_estimate_count)%>:</b> <%= Estimate.count %> @ <%= Estimate.last_sync %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<b><%=t(:label_last_sync)%> </b> <%= Qbo.last_sync if Qbo.exists? %> <%= link_to t(:label_sync_now), qbo_sync_path(full_sync: true) %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<fieldset class="box">
|
||||||
|
<legend>Management & Synchronization</legend>
|
||||||
|
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<ipp:connectToIntuit></ipp:connectToIntuit>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="margin-bottom: 15px;">
|
||||||
|
<%= link_to t(:label_sync_now_customers), customers_sync_path(full_sync: true), class: 'button icon icon-reload' %>
|
||||||
|
<%= link_to t(:label_sync_now_employees), employees_sync_path, class: 'button icon icon-reload' %>
|
||||||
|
<%= link_to t(:label_sync_now_invoices), invoices_sync_path(full_sync: true), class: 'button icon icon-reload' %>
|
||||||
|
<%= link_to t(:label_sync_now_estimate), estimates_sync_path, class: 'button icon icon-reload' %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
@@ -82,6 +82,10 @@ en:
|
|||||||
label_shipping_address: "Shipping Address"
|
label_shipping_address: "Shipping Address"
|
||||||
label_sync: "Sync"
|
label_sync: "Sync"
|
||||||
label_sync_now: "Sync Now"
|
label_sync_now: "Sync Now"
|
||||||
|
label_sync_now_customers: "Sync Customers"
|
||||||
|
label_sync_now_employees: "Sync Employees"
|
||||||
|
label_sync_now_invoices: "Sync Invoices"
|
||||||
|
label_sync_now_estimate: "Sync Estimates"
|
||||||
label_syncing: "Syncing QuickBooks"
|
label_syncing: "Syncing QuickBooks"
|
||||||
label_trim: "Trim"
|
label_trim: "Trim"
|
||||||
label_webhook_token: "Intuit QBO Webhook Token"
|
label_webhook_token: "Intuit QBO Webhook Token"
|
||||||
|
|||||||
@@ -14,16 +14,13 @@ get 'qbo/oauth_callback', to: 'qbo#oauth_callback'
|
|||||||
|
|
||||||
#manual sync
|
#manual sync
|
||||||
get 'qbo/sync', to: 'qbo#sync'
|
get 'qbo/sync', to: 'qbo#sync'
|
||||||
get 'invoices/sync', to: 'invoice#sync'
|
|
||||||
get 'estimates/sync', to: 'estimate#sync'
|
|
||||||
|
|
||||||
#webhook
|
#webhook
|
||||||
post 'qbo/webhook', to: 'qbo#webhook'
|
post 'qbo/webhook', to: 'qbo#webhook'
|
||||||
|
|
||||||
# Estimate & Invoice PDF
|
# Estimate & Invoice PDF
|
||||||
get 'estimates/:id', to: 'estimate#show', as: :estimate
|
get 'estimates/doc/', to: 'estimates#doc', as: :estimate_doc
|
||||||
get 'estimates/doc/', to: 'estimate#doc', as: :estimate_doc
|
get 'invoices/:id', to: 'invoices#show', as: :invoice
|
||||||
get 'invoices/:id', to: 'invoice#show', as: :invoice
|
|
||||||
|
|
||||||
#manual billing
|
#manual billing
|
||||||
get 'bill/:id', to: 'qbo#bill', as: :bill
|
get 'bill/:id', to: 'qbo#bill', as: :bill
|
||||||
@@ -40,3 +37,16 @@ resources :customers do
|
|||||||
get :autocomplete_customer_name, on: :collection
|
get :autocomplete_customer_name, on: :collection
|
||||||
get :sync
|
get :sync
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :estimates do
|
||||||
|
get :sync
|
||||||
|
get :doc, as: :estimate_doc
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :employees do
|
||||||
|
get :sync
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :invoices do
|
||||||
|
get :sync
|
||||||
|
end
|
||||||
|
|||||||
2
init.rb
2
init.rb
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do
|
|||||||
name 'Redmine QBO plugin'
|
name 'Redmine QBO plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed'
|
description 'A pluging for Redmine to connect with QuickBooks Online to create Time Activity Entries for billable hours logged when an Issue is closed'
|
||||||
version '2026.3.10'
|
version '2026.3.11'
|
||||||
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