Let admins hide QuickBooks custom fields from estimates and invoices

QuickBooks doesn't tell apps which custom fields are inactive, and a field stays on
its old estimates after it's turned off, so an inactive "Sales Rep old" kept showing
and was filled in with the sales person. The billing settings now list the fields
found, with a box to hide each; hidden fields are left out of the editor, the sales
person and other plugins' field lookups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-04 10:07:54 -05:00
1 parent fa1b4eed06
commit 895733f534
3 files changed
+49 -1

No files matched your search

+16 -1
View File
@@ -34,11 +34,26 @@ module RedmineQboBilling
module_function
# All enabled sales form custom fields, in QuickBooks' order
# The sales form custom fields the plugin uses, in QuickBooks' order: all those found, except the ones
# hidden in the plugin settings. Everything else (the editor, the sales person, other plugins' VIN and
# mileage) goes through here, so a hidden field is never shown or filled in.
def custom_fields
hidden = hidden_field_ids
all_custom_fields.reject { |f| hidden.include?(f.id.to_i) }
end
# Every custom field found, hidden ones included (listed on the plugin settings page)
def all_custom_fields
Array(settings[:custom_fields]).map { |f| Field.new(f[:id], f[:name]) }
end
# Fields hidden in the plugin settings. QuickBooks doesn't tell apps which custom fields are inactive,
# and a field stays on its old estimates after it's turned off (e.g. a renamed "Sales Rep old"), so the
# plugin can't leave those out by itself.
def hidden_field_ids
Array((Setting.plugin_redmine_qbo || {})['hidden_custom_field_ids']).map(&:to_i).reject(&:zero?)
end
# The first enabled custom field whose name matches, e.g. a plugin's VIN field (/\bvin\b/i), or nil
def custom_field_matching(pattern)
custom_fields.detect { |f| f.name.to_s =~ pattern }