mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-18 02:20:37 -05:00
Move vehicle code out to redmine_qbo_vehicles
- IssueMileageListener removed: redmine_qbo_vehicles answers qbo_billing_issue_values with mileage. - New hook qbo_billing_build_issue sets plugins' fields on issues created from an estimate; the vehicle lookup by VIN moved to redmine_qbo_vehicles. - New hook qbo_billing_vin_options gives the VIN box's suggestions (RedmineQboBilling.vin_options) instead of reading customer.vehicles. - The customer page's New issue link script is generic: any checkbox with data-new-issue-param="issue[field]" fills that field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
11 files changed
+78
-115
No files matched your search
@@ -19,7 +19,6 @@ module RedmineQboBilling
|
||||
|
||||
# Hooks
|
||||
RedmineQboBilling::Hooks::QboHookListener
|
||||
RedmineQboBilling::Hooks::IssueMileageListener
|
||||
|
||||
# Administration menu: the QuickBooks product/service list (accounts are reached from it)
|
||||
Redmine::MenuManager.map :admin_menu do |menu|
|
||||
@@ -28,6 +27,22 @@ module RedmineQboBilling
|
||||
end
|
||||
end
|
||||
|
||||
# VINs to suggest in the estimate/invoice VIN box for a customer, from plugins answering
|
||||
# :qbo_billing_vin_options, { customer: } => [{ vin:, name: }, ...] (e.g. redmine_qbo_vehicles: the
|
||||
# customer's vehicles)
|
||||
def self.vin_options(customer)
|
||||
return [] unless customer
|
||||
|
||||
Redmine::Hook.call_hook(:qbo_billing_vin_options, { customer: customer }).flatten.compact.filter_map do |option|
|
||||
option = option.to_h.symbolize_keys
|
||||
vin = option[:vin].to_s.strip
|
||||
{ vin: vin, name: option[:name].to_s.presence || vin } unless vin.empty?
|
||||
end.uniq { |o| o[:vin].upcase }
|
||||
rescue StandardError => e
|
||||
Rails.logger.warn "[RedmineQboBilling] VIN suggestions failed: #{e.message}"
|
||||
[]
|
||||
end
|
||||
|
||||
# True when the user may write estimates
|
||||
def self.writer?(user = User.current)
|
||||
user.allowed_to?(:write_estimates, nil, global: true)
|
||||
|
||||
Reference in new issue
Block a user