mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-17 18:20:36 -05:00
Tidy the plugin settings page
- Three sections: QuickBooks connection, Synchronization and Billing. - Synchronization is one table of every synced type (customers, employees, estimates, invoices, payments, items, accounts) with its count, last sync and a Sync link, plus Sync changes and Full sync. The separate billing stats and management boxes are folded into it. - New payments sync (admin only). - Sync links return to the page they were clicked on instead of the home page. - Remove locale strings nothing uses any more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
13 files changed
+90
-111
No files matched your search
@@ -308,6 +308,12 @@ Administration → Plugins → Configure
|
||||
|
||||
Once authentication succeeds, the plugin performs an **initial synchronization**.
|
||||
|
||||
The settings page has three sections:
|
||||
|
||||
* **QuickBooks connection**: client ID and secret, webhook token, sandbox, when the access token expires, and Connect to QuickBooks.
|
||||
* **Synchronization**: customers, employees, estimates, invoices, payments, products/services (items) and accounts, with how many of each are stored, when each last synced and a **Sync** link for each (it re-reads every record of that type). **Sync changes** reads only what changed since the last sync; **Full sync** re-reads everything. The default income account for new products/services is shown here too.
|
||||
* **Billing**: estimate expiration, "Replaced by imported time" and the issues-from-estimates settings.
|
||||
|
||||
---
|
||||
|
||||
# User Mapping
|
||||
|
||||
@@ -32,6 +32,6 @@ class AccountsController < ApplicationController
|
||||
|
||||
def sync
|
||||
Account.sync
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
end
|
||||
@@ -213,7 +213,7 @@ class CustomersController < ApplicationController
|
||||
|
||||
def sync
|
||||
Customer.sync
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -15,7 +15,7 @@ class EmployeesController < ApplicationController
|
||||
|
||||
def sync
|
||||
Employee.sync
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -31,7 +31,7 @@ class EstimatesController < ApplicationController
|
||||
|
||||
def sync
|
||||
Estimate.sync
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -34,7 +34,7 @@ class InvoicesController < ApplicationController
|
||||
|
||||
def sync
|
||||
Invoice.sync
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -76,7 +76,7 @@ class ItemsController < ApplicationController
|
||||
|
||||
def sync
|
||||
Item.sync
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -70,7 +70,7 @@ class QboController < ApplicationController
|
||||
full_sync = ActiveModel::Type::Boolean.new.cast(params[:full_sync])
|
||||
QboSyncDispatcher.sync!(full_sync: full_sync)
|
||||
|
||||
redirect_to :home, flash: { notice: I18n.t(:label_syncing) }
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
# Endpoint to receive QuickBooks webhook notifications. Validates the request and processes the payload to sync relevant data to Redmine. Responds with appropriate HTTP status codes based on success or failure of processing.
|
||||
|
||||
@@ -13,10 +13,17 @@
|
||||
# listed on their payments page.
|
||||
class QboPaymentsController < ApplicationController
|
||||
|
||||
before_action :authorize_global
|
||||
before_action :authorize_global, except: :sync
|
||||
before_action :require_admin, only: :sync
|
||||
|
||||
QBO_ERRORS = QboEstimatesController::QBO_ERRORS
|
||||
|
||||
# Re-reads every payment from QuickBooks into the local cache (admin, from the plugin settings)
|
||||
def sync
|
||||
Payment.sync
|
||||
redirect_back fallback_location: home_path, flash: { notice: I18n.t(:label_syncing) }
|
||||
end
|
||||
|
||||
# The customer's payments, newest first, read from QuickBooks
|
||||
def index
|
||||
@customer = Customer.find_by(id: params[:customer_id])
|
||||
|
||||
@@ -40,44 +40,3 @@
|
||||
<em class="info"><%= l(:text_default_tracker_info) %></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
<%# QuickBooks product/service list and income accounts (moved from redmine_qbo_lineitems) %>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<label><strong><%= t(:label_item_count) %></strong></label>
|
||||
<%= Item.count %>
|
||||
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">
|
||||
(@ <%= Item.last_sync %>)
|
||||
</em>
|
||||
</p>
|
||||
<p>
|
||||
<label><strong><%= t(:label_account_count) %></strong></label>
|
||||
<%= Account.count %>
|
||||
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">
|
||||
(@ <%= Account.last_sync %>)
|
||||
</em>
|
||||
</p>
|
||||
<p>
|
||||
<label><strong><%= t(:label_last_sync) %> (QBO)</strong></label>
|
||||
<%= Qbo.exists? ? Qbo.last_sync : l(:label_never_synced) %>
|
||||
</p>
|
||||
<p>
|
||||
<label><strong><%= t(:label_default_account) %></strong></label>
|
||||
<%= Account.get_default %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<fieldset class="box">
|
||||
<legend><%= l(:label_management_and_sync) %></legend>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<%= link_to t(:label_sync_now_items), sync_items_path, class: 'button icon icon-reload' %>
|
||||
<%= link_to t(:label_sync_now_accounts), sync_accounts_path, class: 'button icon icon-reload' %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= link_to t(:label_items), items_path, class: 'icon icon-list' %>
|
||||
<span style="margin: 0 10px; color: #ccc;">|</span>
|
||||
<%= link_to t(:label_accounts), accounts_path, class: 'icon icon-list' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -3,81 +3,93 @@
|
||||
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_authenticate_path %>'});
|
||||
</script>
|
||||
|
||||
<%# QuickBooks connection: app keys, webhook token, sandbox, and the OAuth connection %>
|
||||
<h3><%= l(:label_qbo_connection) %></h3>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<label><%= t(:label_client_id) %></label>
|
||||
<%= text_field_tag 'settings[oauth_consumer_key]', settings[:oauth_consumer_key], size: 50 %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_client_secret) %></label>
|
||||
<%= password_field_tag 'settings[oauth_consumer_secret]', settings[:oauth_consumer_secret], size: 50 %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_webhook_token) %></label>
|
||||
<%= text_field_tag 'settings[webhook_token]', settings[:webhook_token], size: 50 %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_sandbox) %></label>
|
||||
<%= check_box_tag 'settings[sandbox]', 1, settings[:sandbox] %>
|
||||
</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_oauth_expires) %></label>
|
||||
<span class="icon <%= Qbo.oauth2_access_token_expires_at&.future? ? 'icon-ok' : 'icon-warning' %>">
|
||||
<%= Qbo.oauth2_access_token_expires_at || 'N/A' %>
|
||||
<%= Qbo.oauth2_access_token_expires_at ? format_time(Qbo.oauth2_access_token_expires_at) : 'N/A' %>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_customer_count) %></label>
|
||||
<%= Customer.count %>
|
||||
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Customer.last_sync %>)</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_employee_count) %></label>
|
||||
<%= Employee.count %>
|
||||
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Employee.last_sync %>)</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_invoice_count) %></label>
|
||||
<%= Invoice.count %>
|
||||
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Invoice.last_sync %>)</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_estimate_count) %></label>
|
||||
<%= Estimate.count %>
|
||||
<em style="color: #777; font-size: 0.9em; margin-left: 8px;">(@ <%= Estimate.last_sync %>)</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label><%= t(:label_last_sync) %> (QBO)</label>
|
||||
<%= Qbo.exists? ? Qbo.last_sync : 'Never synced' %>
|
||||
<label></label>
|
||||
<ipp:connectToIntuit></ipp:connectToIntuit>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<fieldset class="box">
|
||||
<legend>Management & Synchronization</legend>
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<ipp:connectToIntuit></ipp:connectToIntuit>
|
||||
</div>
|
||||
<%# Everything kept in step with QuickBooks: how many records there are, when each last changed, and a sync
|
||||
button for each. A type's sync re-reads all of its records from QuickBooks. %>
|
||||
<% sync_rows = [
|
||||
[l(:label_customers), Customer, sync_customers_path, customers_path],
|
||||
[l(:label_employee_plural), Employee, employees_sync_path, nil],
|
||||
[l(:label_estimates), Estimate, estimates_sync_path, nil],
|
||||
[l(:label_invoices), Invoice, invoices_sync_path, nil],
|
||||
[l(:label_payments), Payment, sync_qbo_payments_path, nil],
|
||||
[l(:label_items), Item, sync_items_path, items_path],
|
||||
[l(:label_accounts), Account, sync_accounts_path, accounts_path]
|
||||
] %>
|
||||
<h3><%= l(:label_management_and_sync) %></h3>
|
||||
<div class="box">
|
||||
<table class="list qbo-sync-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="name"></th>
|
||||
<th class="count"><%= l(:label_qbo_records) %></th>
|
||||
<th class="updated"><%= l(:label_last_sync) %></th>
|
||||
<th class="buttons"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% sync_rows.each do |label, model, sync_path, list_path| %>
|
||||
<tr>
|
||||
<td class="name"><%= list_path ? link_to(label, list_path) : label %></td>
|
||||
<td class="count"><%= model.count %></td>
|
||||
<td class="updated"><%= model.last_sync %></td>
|
||||
<td class="buttons"><%= link_to sprite_icon('reload', l(:label_sync)), sync_path, class: 'icon icon-reload' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<%= link_to t(:label_sync_now_customers), sync_customers_path, 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, class: 'button icon icon-reload' %>
|
||||
<%= link_to t(:label_sync_now_estimate), estimates_sync_path, class: 'button icon icon-reload' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<p class="qbo-sync-default-account">
|
||||
<strong><%= t(:label_default_account) %>:</strong> <%= Account.get_default || '–' %>
|
||||
<em class="info"><%= l(:text_default_account_info) %></em>
|
||||
</p>
|
||||
|
||||
<%# Billing: estimates, issues from estimates, invoices, the product/service list and accounts %>
|
||||
<p class="qbo-sync-all">
|
||||
<strong><%= t(:label_last_sync) %> (QBO):</strong> <%= Qbo.exists? ? Qbo.last_sync : l(:label_never_synced) %>
|
||||
<%= link_to sprite_icon('reload', l(:label_sync_changes)), qbo_sync_path, class: 'button icon icon-reload' %>
|
||||
<%= link_to sprite_icon('reload', l(:label_full_sync)), qbo_sync_path(full_sync: true), class: 'button icon icon-reload' %>
|
||||
</p>
|
||||
<em class="info"><%= l(:text_qbo_sync_info) %></em>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
table.qbo-sync-table { margin-bottom: 10px; }
|
||||
table.qbo-sync-table td.name, table.qbo-sync-table th.name { text-align: left; }
|
||||
table.qbo-sync-table td.count { text-align: right; width: 8em; }
|
||||
table.qbo-sync-table td.updated { width: 14em; }
|
||||
table.qbo-sync-table td.buttons { width: 6em; }
|
||||
.qbo-sync-all .button { margin-left: 8px; }
|
||||
</style>
|
||||
|
||||
<%# Billing: estimates, issues from estimates and invoices %>
|
||||
<h3><%= l(:label_billing_settings) %></h3>
|
||||
<%= render partial: 'qbo/billing_settings', locals: { settings: settings } %>
|
||||
+8
-14
@@ -37,7 +37,6 @@ en:
|
||||
label_closed_issues: "Closed Issues"
|
||||
label_connected: "Successfully connected to QuickBooks"
|
||||
label_create_estimate: "Create Estimate"
|
||||
label_customer_count: "Customer Count"
|
||||
label_customer_link_expires: "This customer link expires in"
|
||||
label_customer: "Customer"
|
||||
label_customers: "Customers"
|
||||
@@ -49,15 +48,12 @@ en:
|
||||
label_edit: "Edit"
|
||||
label_edit_customer: "Edit Customer"
|
||||
label_email: "Email"
|
||||
label_employee_count: "Employee Count"
|
||||
label_error: "Error"
|
||||
label_estimate_404: "Estimate not found"
|
||||
label_estimate_count: "Estimate Count"
|
||||
label_estimate: "Estimate"
|
||||
label_estimates: "Estimates"
|
||||
label_hours: "Hours"
|
||||
label_invoice_404: "Invoice not found"
|
||||
label_invoice_count: "Invoice Count"
|
||||
label_invoices: "Invoices"
|
||||
label_last_sync: "Last Sync"
|
||||
label_load_customer: "Load Customer"
|
||||
@@ -87,11 +83,6 @@ en:
|
||||
label_share: "Share"
|
||||
label_shipping_address: "Shipping Address"
|
||||
label_sync: "Sync"
|
||||
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_trim: "Trim"
|
||||
label_webhook_token: "Intuit QBO Webhook Token"
|
||||
@@ -206,20 +197,23 @@ en:
|
||||
label_active: "Active"
|
||||
label_account: "Account"
|
||||
label_accounts: "Accounts"
|
||||
label_account_count: "Number of Accounts:"
|
||||
label_back: "Back"
|
||||
label_default_account: "Default Item Income Account"
|
||||
label_description: "Description"
|
||||
label_edit_item: "Edit Item"
|
||||
label_item: "Item"
|
||||
label_item_count: "Item Count:"
|
||||
label_item_new: "New Item"
|
||||
label_items: "Items"
|
||||
label_management_and_sync: "Management & Synchronization"
|
||||
label_management_and_sync: "Synchronization"
|
||||
label_qbo_connection: "QuickBooks connection"
|
||||
label_qbo_records: "Records"
|
||||
label_employee_plural: "Employees"
|
||||
label_sync_changes: "Sync changes"
|
||||
label_full_sync: "Full sync"
|
||||
text_qbo_sync_info: "Sync changes reads what changed in QuickBooks since the last sync; Full sync and each type's Sync re-read every record (e.g. after changing \"Replaced by imported time\", sync estimates and invoices). Webhooks keep things current in between."
|
||||
text_default_account_info: "New products/services go in this income account; set it on the Accounts page."
|
||||
label_never_synced: "Never synced"
|
||||
label_no: "No"
|
||||
label_sync_now_accounts: "Sync Accounts"
|
||||
label_sync_now_items: "Sync Items"
|
||||
label_type: "Type"
|
||||
label_yes: "Yes"
|
||||
error_default_account_not_selected: "Select an account to make it the default."
|
||||
|
||||
@@ -74,6 +74,7 @@ resources :qbo_payments, only: [:index, :new, :create, :show] do
|
||||
get :pdf
|
||||
end
|
||||
collection do
|
||||
get :sync
|
||||
get :open_invoices
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user