Compare commits

...

10 Commits

Author SHA1 Message Date
ricky 6da0972476 2026.4.1 2026-04-09 09:43:04 -04:00
ricky 35542ba1b9 Fix vehicle name fallback not applied in select by replacing pluck with model instances 2026-04-09 09:42:45 -04:00
ricky cc94401a1f 2026.4.0 2026-04-09 09:32:00 -04:00
ricky 6012434de2 Display year/make/model if name is blank 2026-04-09 09:31:31 -04:00
ricky 83a5811a37 Removed InvoiceHookListener registation 2026-03-29 21:55:41 -04:00
ricky 35bd41d289 2026.3.4 2026-03-28 00:28:11 -04:00
ricky a9354026bc removed InvoiceHookListener as support has been removed from redmine_qbo 2026-03-28 00:27:59 -04:00
ricky f9102c1a5d update vehicles in batches 2026-03-26 22:10:32 -04:00
ricky 0aef1d0c2b Build vehicle name 2026-03-26 12:45:17 -04:00
ricky ba313dfd02 2026.3.3 2026-03-26 08:11:43 -04:00
7 changed files with 31 additions and 79 deletions
+10 -1
View File
@@ -32,7 +32,7 @@ class VehicleVinDecodeJob < ApplicationJob
model: details.model.presence || vehicle.model,
doors: details.doors.presence || vehicle.doors,
trim: details.trim.presence || vehicle.trim,
name: vehicle.to_s,
name: build_name(vehicle, details),
vin_decoded: true,
error: nil
)
@@ -40,6 +40,15 @@ class VehicleVinDecodeJob < ApplicationJob
private
def build_name(vehicle, details)
if details.year && details.make && details.model
suffix = vehicle.vin.to_s[9..]
"#{details.year} #{details.make} #{details.model} - #{suffix}"
else
vehicle.vin
end
end
def log(msg)
Rails.logger.info "[VehicleVinDecodeJob] #{msg}"
end
+7
View File
@@ -41,6 +41,11 @@ class Vehicle < ApplicationRecord
super(val.to_s.strip)
end
def name
val = self[:name]
val.present? ? val : to_s
end
# Redmine compatibility shim
def project
nil
@@ -63,7 +68,9 @@ class Vehicle < ApplicationRecord
end
def to_s
return self[:name] if self[:name].present?
return vin if year.blank? || make.blank? || model.blank?
suffix = vin.to_s[9..] || vin
"#{year} #{make} #{model} - #{suffix}"
end
+4 -2
View File
@@ -19,8 +19,10 @@ class AddPollingAndIndexes < ActiveRecord::Migration[7.0]
add_index :vehicles, :model
add_index :vehicles, :year
Vehicle.all.each do |v|
VehicleVinDecodeJob.perform_later(v.id)
Vehicle.find_each.with_index do |vehicle, index|
VehicleVinDecodeJob
.set(wait: (index / 50).minutes)
.perform_later(vehicle.id)
end
end
+1 -1
View File
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
name 'Redmine QBO Vehicles plugin'
author 'Rick Barrette'
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
version '2026.3.2'
version '2026.4.1'
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
author_url 'https://barrettefabrication.com'
requires_redmine version_or_higher: '6.1.0'
-1
View File
@@ -14,7 +14,6 @@ module RedmineQboVehicles
Customer.prepend Vehicles::Patches::CustomerPatch
Vehicles::Hooks::CustomerShowHookListener
Vehicles::Hooks::InvoiceHookListener
Vehicles::Hooks::IssuesFormHookListener
Vehicles::Hooks::IssuesShowHookListener
Vehicles::Hooks::PdfHookListener
@@ -1,69 +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 Vehicles
module Hooks
class InvoiceHookListener < Redmine::Hook::ViewListener
include IssuesHelper
# Called by Redmine QBO Invoice
def process_invoice_custom_fields(context={})
log "Processing invoice custom fields for invoice ##{context[:invoice].id}"
issue = context[:issue]
# update the invoive custom fields with infomation from the issue if available
context[:invoice].custom_fields.each do |cf|
log "Checking invoice custom field: #{cf.name}"
# VIN from the attached vehicle
begin
if cf.name.eql? "VIN"
# Only update if blank to prevent infite loops
# TODO check cf_sync_confict flag once implemented
if cf.string_value.to_s.blank?
log "VIN was blank, updating the invoice vin in quickbooks"
vin = context[:issue].vehicle.vin
break if vin.nil?
if not cf.string_value.to_s.eql? vin
cf.string_value = vin.to_s
log "VIN has changed"
context[:is_changed] = true
end
end
end
rescue
#do nothing
log "redmine_qbo_vehicles.process_invoice_custom_fields failed, skipping"
return nil
end
end
return context if context[:is_changed]
return nil
end
private
def log(msg)
Rails.logger.info "[InvoiceHookListener] #{msg}"
end
end
end
end
@@ -18,13 +18,17 @@ module Vehicles
def view_issues_form_details_bottom(context={})
# Load the customer's vehicles for selection in the issue form.
vehicles = context[:issue].customer&.vehicles || []
context[:controller].send(:render_to_string, {
partial: 'issues/form_hook_vehicles',
locals: {
vehicle: context[:form].select( :vehicle_id,
context[:issue].customer ? context[:issue].customer.vehicles.pluck(:name, :id) : [],
selected: context[:issue].vehicle ? context[:issue].vehicle.id : nil,
include_blank: true )
vehicle: context[:form].select(
:vehicle_id,
vehicles.map { |v| [v.name, v.id] },
selected: context[:issue].vehicle&.id,
include_blank: true
)
}
})