From 616ee137250a764f30e312ce3834b03eafe78d4f Mon Sep 17 00:00:00 2001
From: Claude
Date: Sat, 31 Oct 2026 08:11:27 -0400
Subject: [PATCH] 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
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
---
README.md | 6 ++
app/controllers/accounts_controller.rb | 2 +-
app/controllers/customers_controller.rb | 2 +-
app/controllers/employees_controller.rb | 2 +-
app/controllers/estimates_controller.rb | 2 +-
app/controllers/invoices_controller.rb | 2 +-
app/controllers/items_controller.rb | 2 +-
app/controllers/qbo_controller.rb | 2 +-
app/controllers/qbo_payments_controller.rb | 9 +-
app/views/qbo/_billing_settings.html.erb | 41 --------
app/views/qbo/_settings.html.erb | 108 ++++++++++++---------
config/locales/en.yml | 22 ++---
config/routes.rb | 1 +
13 files changed, 90 insertions(+), 111 deletions(-)
diff --git a/README.md b/README.md
index 2b95fe1..c5557c4 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 1945ed2..f0c7eb8 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -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
\ No newline at end of file
diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb
index 67ac373..9f85932 100644
--- a/app/controllers/customers_controller.rb
+++ b/app/controllers/customers_controller.rb
@@ -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
diff --git a/app/controllers/employees_controller.rb b/app/controllers/employees_controller.rb
index 373be34..e2e82e9 100644
--- a/app/controllers/employees_controller.rb
+++ b/app/controllers/employees_controller.rb
@@ -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
diff --git a/app/controllers/estimates_controller.rb b/app/controllers/estimates_controller.rb
index 3fa7dc7..3ae33aa 100644
--- a/app/controllers/estimates_controller.rb
+++ b/app/controllers/estimates_controller.rb
@@ -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
diff --git a/app/controllers/invoices_controller.rb b/app/controllers/invoices_controller.rb
index 5f47c54..afc7908 100644
--- a/app/controllers/invoices_controller.rb
+++ b/app/controllers/invoices_controller.rb
@@ -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
diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb
index 89de0a9..5248cd3 100644
--- a/app/controllers/items_controller.rb
+++ b/app/controllers/items_controller.rb
@@ -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
diff --git a/app/controllers/qbo_controller.rb b/app/controllers/qbo_controller.rb
index 99821c0..632569f 100644
--- a/app/controllers/qbo_controller.rb
+++ b/app/controllers/qbo_controller.rb
@@ -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.
diff --git a/app/controllers/qbo_payments_controller.rb b/app/controllers/qbo_payments_controller.rb
index c43f760..493eb49 100644
--- a/app/controllers/qbo_payments_controller.rb
+++ b/app/controllers/qbo_payments_controller.rb
@@ -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])
diff --git a/app/views/qbo/_billing_settings.html.erb b/app/views/qbo/_billing_settings.html.erb
index 27d79cd..9ca563a 100644
--- a/app/views/qbo/_billing_settings.html.erb
+++ b/app/views/qbo/_billing_settings.html.erb
@@ -40,44 +40,3 @@
<%= l(:text_default_tracker_info) %>
-
-<%# QuickBooks product/service list and income accounts (moved from redmine_qbo_lineitems) %>
-
-
-
- <%= Item.count %>
-
- (@ <%= Item.last_sync %>)
-
-
-
-
- <%= Account.count %>
-
- (@ <%= Account.last_sync %>)
-
-
-
-
- <%= Qbo.exists? ? Qbo.last_sync : l(:label_never_synced) %>
-
-
-
- <%= Account.get_default %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/qbo/_settings.html.erb b/app/views/qbo/_settings.html.erb
index 1a8d9b2..c68a4d2 100644
--- a/app/views/qbo/_settings.html.erb
+++ b/app/views/qbo/_settings.html.erb
@@ -3,81 +3,93 @@
intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_authenticate_path %>'});
+<%# QuickBooks connection: app keys, webhook token, sandbox, and the OAuth connection %>
+<%= l(:label_qbo_connection) %>
<%= text_field_tag 'settings[oauth_consumer_key]', settings[:oauth_consumer_key], size: 50 %>
-
<%= password_field_tag 'settings[oauth_consumer_secret]', settings[:oauth_consumer_secret], size: 50 %>
-
<%= text_field_tag 'settings[webhook_token]', settings[:webhook_token], size: 50 %>
-
<%= check_box_tag 'settings[sandbox]', 1, settings[:sandbox] %>
-
-
-
- <%= Qbo.oauth2_access_token_expires_at || 'N/A' %>
+ <%= Qbo.oauth2_access_token_expires_at ? format_time(Qbo.oauth2_access_token_expires_at) : 'N/A' %>
-
-
- <%= Customer.count %>
- (@ <%= Customer.last_sync %>)
-
-
-
-
- <%= Employee.count %>
- (@ <%= Employee.last_sync %>)
-
-
-
-
- <%= Invoice.count %>
- (@ <%= Invoice.last_sync %>)
-
-
-
-
- <%= Estimate.count %>
- (@ <%= Estimate.last_sync %>)
-
-
-
-
- <%= Qbo.exists? ? Qbo.last_sync : 'Never synced' %>
+
+
-