mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-21 10:50:37 -05:00
Leave other plugins' features to hooks
Refund emails and PDFs take the shop name and mail settings from :qbo_mail_settings instead of reading redmine_qbo_reminders' settings; the customer page's ticked boxes use generic data-ticked-field/data-ticked-params instead of knowing redmine_qbo_calendar's Add appointment link; and Create issues carries the params plugins name in :qbo_billing_issue_carry_params instead of appointment_id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0552e2f1a3
commit
ae0ffc7c1c
10 files changed
+69
-39
No files matched your search
@@ -30,6 +30,18 @@ module RedmineQboBilling
|
||||
# Suggestions for the editor's custom field boxes for a customer, from plugins answering
|
||||
# :qbo_billing_field_options, { customer: } => { field_id => [{ value:, label: }, ...] }
|
||||
# (e.g. redmine_qbo_vehicles: the customer's vehicles for its VIN field). Returns { "2" => [...] }.
|
||||
# The shop's name and how customer emails (refund summaries) are sent, from other plugins (e.g.
|
||||
# redmine_qbo_reminders: its shop name and SMTP server) through :qbo_mail_settings. Each returns any of
|
||||
# shop_name:, from:, reply_to:, delivery: (options for ActionMailer's mail(), e.g. an SMTP server); blank
|
||||
# ones fall back to Redmine's own settings.
|
||||
def self.mail_settings
|
||||
Redmine::Hook.call_hook(:qbo_mail_settings, {}).select { |result| result.is_a?(Hash) }
|
||||
.reduce({}) { |merged, result| merged.merge(result.symbolize_keys.compact_blank) }
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn "[RedmineQboBilling] Could not read mail settings from plugins: #{e.message}"
|
||||
{}
|
||||
end
|
||||
|
||||
def self.field_options(customer)
|
||||
return {} unless customer
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@ module RedmineQboBilling
|
||||
end
|
||||
|
||||
def shop_name
|
||||
reminders = defined?(RedmineQboReminders::Settings) ? RedmineQboReminders::Settings.current : nil
|
||||
reminders&.[]('shop_name').to_s.presence || Setting.app_title
|
||||
RedmineQboBilling.mail_settings[:shop_name].presence || Setting.app_title
|
||||
rescue StandardError
|
||||
Setting.app_title
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user