mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-04-02 16:21:58 -04:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df079b767c | |||
| 7d3908ec41 | |||
| f60e507029 | |||
| 3e6650ee65 | |||
| c2d0e5c702 |
26
app/controllers/employee_controller.rb
Normal file
26
app/controllers/employee_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 EmployeeController < 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
|
||||||
@@ -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}"
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ class QboSyncDispatcher
|
|||||||
# Allow other plugins to add addtional sync jobs via Hooks
|
# Allow other plugins to add addtional sync jobs via Hooks
|
||||||
Redmine::Hook.call_hook( :qbo_full_sync ).each do |context|
|
Redmine::Hook.call_hook( :qbo_full_sync ).each do |context|
|
||||||
next unless context
|
next unless context
|
||||||
jobs.push context
|
Array(context).each do |entity|
|
||||||
log "Added additionals QBO Sync Job for #{context.to_s}"
|
jobs.push(entity)
|
||||||
|
log "Added additional QBO Sync Job for #{entity.to_s}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
jobs.each { |job| QboSyncJob.perform_later(entity: job, full_sync: full_sync) }
|
jobs.each { |job| QboSyncJob.perform_later(entity: job, full_sync: full_sync) }
|
||||||
|
|||||||
@@ -47,8 +47,10 @@ class WebhookProcessJob < ActiveJob::Base
|
|||||||
# Allow other plugins to add addtional qbo entities via Hooks
|
# Allow other plugins to add addtional qbo entities via Hooks
|
||||||
Redmine::Hook.call_hook( :qbo_additional_entities ).each do |context|
|
Redmine::Hook.call_hook( :qbo_additional_entities ).each do |context|
|
||||||
next unless context
|
next unless context
|
||||||
entities.push context
|
Array(context).each do |entity|
|
||||||
log "Added additional QBO entities: #{context}"
|
jobs.push(entity)
|
||||||
|
log "Added additional QBO entity #{entity}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return unless entities.include?(name)
|
return unless entities.include?(name)
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 +14,8 @@ 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 'customers/sync', to: 'customers#sync'
|
||||||
|
get 'employees/sync', to: 'employee#sync'
|
||||||
get 'invoices/sync', to: 'invoice#sync'
|
get 'invoices/sync', to: 'invoice#sync'
|
||||||
get 'estimates/sync', to: 'estimate#sync'
|
get 'estimates/sync', to: 'estimate#sync'
|
||||||
|
|
||||||
@@ -21,7 +23,7 @@ get 'estimates/sync', to: 'estimate#sync'
|
|||||||
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/sync', to: 'estimate#sync'
|
||||||
get 'estimates/doc/', to: 'estimate#doc', as: :estimate_doc
|
get 'estimates/doc/', to: 'estimate#doc', as: :estimate_doc
|
||||||
get 'invoices/:id', to: 'invoice#show', as: :invoice
|
get 'invoices/:id', to: 'invoice#show', as: :invoice
|
||||||
|
|
||||||
|
|||||||
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