From d80007bc845497acce01a6e62f658a72d1b94ecb Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 Feb 2026 18:52:11 -0500 Subject: [PATCH 01/11] Titleize the subject before save , but keep words containing numbers mixed with letters capitalized --- lib/redmine_qbo/patches/issue_patch.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/redmine_qbo/patches/issue_patch.rb b/lib/redmine_qbo/patches/issue_patch.rb index a5f743e..6ec9bc4 100644 --- a/lib/redmine_qbo/patches/issue_patch.rb +++ b/lib/redmine_qbo/patches/issue_patch.rb @@ -110,11 +110,20 @@ module RedmineQbo CustomerToken.get_token self end - # Titleize the subject before save + # Titleize the subject before save , but keep words containing numbers mixed with letters capitalized def titlize_subject - self.subject = self.subject.titleize + self.subject = self.subject.split(/\s+/).map do |word| + # If word is NOT purely alphanumeric (contains special chars), + # or is all upper/lower, we can handle it. + # excluding alphanumeric strings with mixed case and numbers (e.g., "ID555ABC") from being altered. + if word =~ /[A-Z]/ && word =~ /[0-9]/ + word + else + word.downcase + word.capitalize + end + end.join(' ') end - end # Add module to Issue From 2c3548d1ac2768fb5e46c6f3d5a0927f3dd3d669 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 Feb 2026 18:55:49 -0500 Subject: [PATCH 02/11] Added logging --- lib/redmine_qbo/patches/issue_patch.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/redmine_qbo/patches/issue_patch.rb b/lib/redmine_qbo/patches/issue_patch.rb index 6ec9bc4..f81bea8 100644 --- a/lib/redmine_qbo/patches/issue_patch.rb +++ b/lib/redmine_qbo/patches/issue_patch.rb @@ -112,6 +112,7 @@ module RedmineQbo # Titleize the subject before save , but keep words containing numbers mixed with letters capitalized def titlize_subject + logger.debug "QBO: Titlizing subject for issue ##{self.id}" self.subject = self.subject.split(/\s+/).map do |word| # If word is NOT purely alphanumeric (contains special chars), # or is all upper/lower, we can handle it. From d59e52b11114ad8cd6f517a14633def1f20f78f1 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 Feb 2026 18:58:16 -0500 Subject: [PATCH 03/11] removed subject from logs --- lib/redmine_qbo/patches/issue_patch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine_qbo/patches/issue_patch.rb b/lib/redmine_qbo/patches/issue_patch.rb index f81bea8..26e5949 100644 --- a/lib/redmine_qbo/patches/issue_patch.rb +++ b/lib/redmine_qbo/patches/issue_patch.rb @@ -43,7 +43,7 @@ module RedmineQbo # Create billable time entries def bill_time - logger.debug "QBO: Billing time for issue ##{id} - #{subject}" + logger.debug "QBO: Billing time for issue ##{id}" return unless status.is_closed? return if assigned_to.nil? return unless Qbo.first From c8f115ae0257d3d127da15827ce91cad62914cd5 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 Feb 2026 19:28:42 -0500 Subject: [PATCH 04/11] removed unused js --- assets/javascripts/application.js | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 assets/javascripts/application.js diff --git a/assets/javascripts/application.js b/assets/javascripts/application.js deleted file mode 100644 index f240bcc..0000000 --- a/assets/javascripts/application.js +++ /dev/null @@ -1,11 +0,0 @@ -$(function() { - $("input#issue_customer_id").on("change", function() { - - $.ajax({ - url: "/filter_estimates_by_customer", - type: "GET", - data: { selected_customer: $("input#issue_customer_id").val() } - }); - }); - -}); From e35a2148eb7dbb6457e0b5748747221427f71bac Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 Feb 2026 19:37:32 -0500 Subject: [PATCH 05/11] 2026.2.0 --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.rb b/init.rb index ecc776b..2ed8846 100644 --- a/init.rb +++ b/init.rb @@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do name 'Redmine QBO plugin' 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' - version '2026.1.9' + version '2026.2.0' url 'https://github.com/rickbarrette/redmine_qbo' author_url 'https://barrettefabrication.com' settings default: {empty: true}, partial: 'qbo/settings' From d063494bd2a6293a3cb4e7ee6f0adde23cb593ac Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 6 Feb 2026 23:00:26 -0500 Subject: [PATCH 06/11] removed empty link string --- lib/redmine_qbo/patches/issues_controller_patch.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/redmine_qbo/patches/issues_controller_patch.rb b/lib/redmine_qbo/patches/issues_controller_patch.rb index 1a6496b..69a9358 100644 --- a/lib/redmine_qbo/patches/issues_controller_patch.rb +++ b/lib/redmine_qbo/patches/issues_controller_patch.rb @@ -15,8 +15,7 @@ module RedmineQbo module Helper def watcher_link(issue, user) - link = +'' - link << link_to(I18n.t(:label_bill_time), bill_path( issue.id ), method: :get, class: 'icon icon-email-add') if user.admin? + link = link_to(I18n.t(:label_bill_time), bill_path( issue.id ), method: :get, class: 'icon icon-email-add') if user.admin? link << link_to(I18n.t(:label_share), share_path( issue.id ), method: :get, target: :_blank, class: 'icon icon-shared') if user.logged? link.html_safe + super end From 0e3318efdd25a18c09b29b3c94398f9d4b30f054 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 8 Feb 2026 09:58:34 -0500 Subject: [PATCH 07/11] Added prefilters to help locate 422 on issue creation. This is an effort to figure out why I get 422 Unprocessable Entity errors sometimes when creating new issues. --- config/locales/en.yml | 4 ++- .../patches/issues_controller_patch.rb | 27 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 64308da..bec98ae 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -99,4 +99,6 @@ en: notice_invoice_not_found: "Invoice not found" notice_forbidden: "You do not have permission to access this resource" notice_issue_not_found: "Issue not found" - customer_details: "Customer Details" \ No newline at end of file + customer_details: "Customer Details" + notice_error_project_nil: "The issue's project is nil." + notice_error_project_nil: "The issue's tracker is nil." \ No newline at end of file diff --git a/lib/redmine_qbo/patches/issues_controller_patch.rb b/lib/redmine_qbo/patches/issues_controller_patch.rb index 69a9358..566e98c 100644 --- a/lib/redmine_qbo/patches/issues_controller_patch.rb +++ b/lib/redmine_qbo/patches/issues_controller_patch.rb @@ -22,11 +22,36 @@ module RedmineQbo end def self.included(base) - base.class_eval do helper Helper + before_action :error_check, only: [:create] + before_action :reload_new_issue, only: [:new] + end + end + + # Check for errors when creating an issue. + # If the project or tracker is not set, reload the new issue form with an error message. + def error_check + logger.info "Creating issue for: #{@issue.project}" + update_issue_from_params + if @issue.project.nil? + flash[:error] = t :notice_error_project_nil + render :new, status: :unprocessable_entity end + if @issue.project.nil? + flash[:error] = t :notice_error_tracker_nil + render :new, status: :unprocessable_entity + end + end + + # Reload the new issue form with a default tracker and project if not set. + # This is needed to prevent errors when creating an issue without selecting a project or tracker. + def reload_new_issue + logger.info "Reloading new #{@issue.tracker} issue for: #{@project}" + @issue.tracker ||= Tracker.first + @project ||= Project.first + logger.info "Reloaded new #{@issue.tracker} issue for: #{@project}" end end From b38bd951f7b780062edfeb5af12892c74140757c Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 8 Feb 2026 10:02:42 -0500 Subject: [PATCH 08/11] fiex typo tracker not project --- lib/redmine_qbo/patches/issues_controller_patch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/redmine_qbo/patches/issues_controller_patch.rb b/lib/redmine_qbo/patches/issues_controller_patch.rb index 566e98c..a5ff0de 100644 --- a/lib/redmine_qbo/patches/issues_controller_patch.rb +++ b/lib/redmine_qbo/patches/issues_controller_patch.rb @@ -39,7 +39,7 @@ module RedmineQbo render :new, status: :unprocessable_entity end - if @issue.project.nil? + if @issue.tracker.nil? flash[:error] = t :notice_error_tracker_nil render :new, status: :unprocessable_entity end From 7a73b7e8a95cf823c16d2bc73a20f4cc45c92b6c Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 8 Feb 2026 10:58:39 -0500 Subject: [PATCH 09/11] refactor error handling in issue creation; remove unused reload_new_issue method --- lib/redmine_qbo/patches/issues_controller_patch.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/redmine_qbo/patches/issues_controller_patch.rb b/lib/redmine_qbo/patches/issues_controller_patch.rb index a5ff0de..3aebd5b 100644 --- a/lib/redmine_qbo/patches/issues_controller_patch.rb +++ b/lib/redmine_qbo/patches/issues_controller_patch.rb @@ -25,7 +25,6 @@ module RedmineQbo base.class_eval do helper Helper before_action :error_check, only: [:create] - before_action :reload_new_issue, only: [:new] end end @@ -33,27 +32,20 @@ module RedmineQbo # If the project or tracker is not set, reload the new issue form with an error message. def error_check logger.info "Creating issue for: #{@issue.project}" - update_issue_from_params + if @issue.project.nil? + @issue.project = Project.first flash[:error] = t :notice_error_project_nil render :new, status: :unprocessable_entity end if @issue.tracker.nil? + @issue.tracker = Tracker.first flash[:error] = t :notice_error_tracker_nil render :new, status: :unprocessable_entity end end - # Reload the new issue form with a default tracker and project if not set. - # This is needed to prevent errors when creating an issue without selecting a project or tracker. - def reload_new_issue - logger.info "Reloading new #{@issue.tracker} issue for: #{@project}" - @issue.tracker ||= Tracker.first - @project ||= Project.first - logger.info "Reloaded new #{@issue.tracker} issue for: #{@project}" - end - end # Add module to IssuessController From 548dc4fba839d775396e594e6f33e803917301fe Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 8 Feb 2026 13:07:28 -0500 Subject: [PATCH 10/11] Implement issue creation error handling; add project validation and refactored issue hooks --- config/locales/en.yml | 3 +- ...ok_listener.rb => issues_hook_listener.rb} | 43 +++++++++++++++++-- .../hooks/issues_show_hook_listener.rb | 43 ------------------- .../patches/issues_controller_patch.rb | 24 +---------- 4 files changed, 42 insertions(+), 71 deletions(-) rename lib/redmine_qbo/hooks/{issues_form_hook_listener.rb => issues_hook_listener.rb} (63%) delete mode 100644 lib/redmine_qbo/hooks/issues_show_hook_listener.rb diff --git a/config/locales/en.yml b/config/locales/en.yml index bec98ae..c6cebfd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -100,5 +100,4 @@ en: notice_forbidden: "You do not have permission to access this resource" notice_issue_not_found: "Issue not found" customer_details: "Customer Details" - notice_error_project_nil: "The issue's project is nil." - notice_error_project_nil: "The issue's tracker is nil." \ No newline at end of file + notice_error_project_nil: "The issue's project is nil, set project to: " \ No newline at end of file diff --git a/lib/redmine_qbo/hooks/issues_form_hook_listener.rb b/lib/redmine_qbo/hooks/issues_hook_listener.rb similarity index 63% rename from lib/redmine_qbo/hooks/issues_form_hook_listener.rb rename to lib/redmine_qbo/hooks/issues_hook_listener.rb index 926be14..91568ce 100644 --- a/lib/redmine_qbo/hooks/issues_form_hook_listener.rb +++ b/lib/redmine_qbo/hooks/issues_hook_listener.rb @@ -10,10 +10,21 @@ module RedmineQbo module Hooks + class IssuesHookListener < Redmine::Hook::ViewListener - class IssuesFormHookListener < Redmine::Hook::ViewListener + include IssuesHelper - include IssuesHelper + # Check the new issue form for a valid project. + # This is added to help prevent 422 unprocessable entity errors when creating an issue + # See https://github.com/redmine/redmine/blob/84483d63828d0cb2efbf5bd786a2f0d22e34c93d/app/controllers/issues_controller.rb#L179 + def controller_issues_new_before_save(context={}) + if context[:issue].project.nil? + context[:issue].project = projects_for_select(context[:issue]).first + context[:controller].flash[:error] = I18n.t(:notice_error_project_nil) + context[:issue].project.to_s + end + + return context + end # Edit Issue Form # Here we build the required form components before passing them to a partial view formatting. @@ -54,7 +65,31 @@ module RedmineQbo } ) end - end - end + # View Issue + # Displays the quickbooks customer, estimate, & invoices attached to the issue + def view_issues_show_details_bottom(context={}) + issue = context[:issue] + + # Build a list of invoice links + invoice_link = "" + if issue.invoices + issue.invoices.each do |i| + invoice_link += "#{link_to i, i, target: :_blank}
" + end + end + + context[:controller].send(:render_to_string, { + partial: 'issues/show_details', + locals: { + customer: issue.customer ? link_to(issue.customer) : nil, + estimate_link: issue.estimate ? link_to(issue.estimate, issue.estimate, target: :_blank) : nil, + invoice_link: invoice_link.html_safe, + issue: issue + } + }) + end + + end + end end \ No newline at end of file diff --git a/lib/redmine_qbo/hooks/issues_show_hook_listener.rb b/lib/redmine_qbo/hooks/issues_show_hook_listener.rb deleted file mode 100644 index ee59966..0000000 --- a/lib/redmine_qbo/hooks/issues_show_hook_listener.rb +++ /dev/null @@ -1,43 +0,0 @@ -#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. - -module RedmineQbo - module Hooks - - class IssuesShowHookListener < Redmine::Hook::ViewListener - - # View Issue - # Displays the quickbooks customer, estimate, & invoices attached to the issue - def view_issues_show_details_bottom(context={}) - issue = context[:issue] - - # Build a list of invoice links - invoice_link = "" - if issue.invoices - issue.invoices.each do |i| - invoice_link += "#{link_to i, i, target: :_blank}
" - end - end - - context[:controller].send(:render_to_string, { - partial: 'issues/show_details', - locals: { - customer: issue.customer ? link_to(issue.customer) : nil, - estimate_link: issue.estimate ? link_to(issue.estimate, issue.estimate, target: :_blank) : nil, - invoice_link: invoice_link.html_safe, - issue: issue - } - }) - end - - end - - end -end \ No newline at end of file diff --git a/lib/redmine_qbo/patches/issues_controller_patch.rb b/lib/redmine_qbo/patches/issues_controller_patch.rb index 3aebd5b..a7b4da2 100644 --- a/lib/redmine_qbo/patches/issues_controller_patch.rb +++ b/lib/redmine_qbo/patches/issues_controller_patch.rb @@ -24,29 +24,9 @@ module RedmineQbo def self.included(base) base.class_eval do helper Helper - before_action :error_check, only: [:create] end - end - - # Check for errors when creating an issue. - # If the project or tracker is not set, reload the new issue form with an error message. - def error_check - logger.info "Creating issue for: #{@issue.project}" - - if @issue.project.nil? - @issue.project = Project.first - flash[:error] = t :notice_error_project_nil - render :new, status: :unprocessable_entity - end - - if @issue.tracker.nil? - @issue.tracker = Tracker.first - flash[:error] = t :notice_error_tracker_nil - render :new, status: :unprocessable_entity - end - end - - end + end + end # Add module to IssuessController IssuesController.send(:include, IssuesControllerPatch) From ac05d387637b4ed7d26f0a39d7076719ae9ead07 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sun, 8 Feb 2026 13:15:20 -0500 Subject: [PATCH 11/11] 2026.2.1 --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.rb b/init.rb index 2ed8846..8248fa5 100644 --- a/init.rb +++ b/init.rb @@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo do name 'Redmine QBO plugin' 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' - version '2026.2.0' + version '2026.2.1' url 'https://github.com/rickbarrette/redmine_qbo' author_url 'https://barrettefabrication.com' settings default: {empty: true}, partial: 'qbo/settings'