Updated patches and hooks

This commit is contained in:
2026-03-21 12:23:23 -04:00
parent ea73878c71
commit 097276e558
4 changed files with 32 additions and 24 deletions

View File

@@ -0,0 +1,23 @@
#The MIT License (MIT)
#
#Copyright (c) 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 RedmineQboVehicles
def self.setup
Issue.prepend Vehicles::Patches::IssuePatch
Customer.prepend Vehicles::Patches::CustomerPatch
Vehicles::Hooks::CustomerShowHookListener
Vehicles::Hooks::InvoiceHookListener
Vehicles::Hooks::IssuesFormHookListener
Vehicles::Hooks::IssuesShowHookListener
Vehicles::Hooks::PdfHookListener
Vehicles::Hooks::ViewHookListener
end
end

View File

@@ -14,16 +14,12 @@ module Vehicles
# Patches Redmine QBO Customer dynamically.
# Adds a relationship for vehicle ownership by customers
module CustomerPatch
extend ActiveSupport::Concern
ActiveSupport.on_load(:active_record) do
Customer.class_eval do
has_many :vehicles
end
prepended do
has_many :vehicles
end
end
end
end

View File

@@ -8,23 +8,18 @@
#
#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.
require_dependency 'issue'
module Vehicles
module Patches
# Patches Redmine's Issues dynamically.
# Adds a relationship for attahcing a vehilce to an issue
module IssuePatch
extend ActiveSupport::Concern
ActiveSupport.on_load(:active_record) do
Issue.class_eval do
belongs_to :vehicle
end
prepended do
belongs_to :vehicle
end
end
end
end