8 Commits

6 changed files with 29 additions and 16 deletions

View File

@@ -60,10 +60,15 @@ class VehiclesController < ApplicationController
# display a specific vehicle # display a specific vehicle
def show def show
begin begin
@vehicle = Vehicle.find_by_id(params[:id]) @vehicle = Vehicle.includes(issues: [:estimate, :invoices]).find(params[:id])
@vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin @vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin
@issues = @vehicle.issues.order(id: :desc) @issues = @vehicle.issues
@closed_issues = (@issues - @issues.open) .joins(:status)
.includes(:estimate, :invoices, :status, :project, :tracker, :priority)
.order(id: :desc)
@open_issues = @issues.select { |i| !i.status.is_closed }
@closed_issues = @issues.select { |i| i.status.is_closed }
flash[:error] = t :alert_no_customer if @vehicle.customer.nil? flash[:error] = t :alert_no_customer if @vehicle.customer.nil?
rescue rescue
flash[:error] = t :alert_vehicle_not_found flash[:error] = t :alert_vehicle_not_found

View File

@@ -92,14 +92,11 @@ class Vehicle < ActiveRecord::Base
scope = self.all scope = self.all
tokens.each do |token| tokens.each do |token|
q = "%#{sanitize_sql_like(token)}%" scope = scope.search(token)
scope = where("vin LIKE ? OR make LIKE ? OR model LIKE ? OR year LIKE ?", "%#{q}%", "%#{q}%", "%#{q}%", "%#{q}%")
end end
ids = scope.distinct.limit(options[:limit] || 100).pluck(:id) ids = scope.distinct.limit(options[:limit] || 100).pluck(:id)
ids.index_with { |id| id }
# rank by id
ids.each_with_object({}) { |id, h| h[id] = id }
end end
# returns a human readable string # returns a human readable string

View File

@@ -14,9 +14,9 @@
</div> </div>
</div> </div>
<h3><%=@issues.open.count%> <%=t(:label_open_issues)%></h3> <h3><%=@open_issues.count%> <%=t(:label_open_issues)%></h3>
<%= render partial: 'issues/list_simple', locals: {issues: @issues.open} %> <%= render partial: 'issues/list_simple', locals: {issues: @open_issues} %>
<h3><%=@closed_issues.count%> <%=t(:label_closed_issues)%></h3> <h3><%=@closed_issues.count%> <%=t(:label_closed_issues)%></h3>

View File

@@ -12,6 +12,11 @@ async function handleCopy(event) {
link = event.target; link = event.target;
} }
// If the text is already "Copied!", don't do anything
if (text == "Copied!") {
return;
}
try { try {
// Write to clipboard // Write to clipboard
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);

View File

@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
name 'Redmine QBO Vehicles plugin' name 'Redmine QBO Vehicles plugin'
author 'Rick Barrette' author 'Rick Barrette'
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking' description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
version '2026.2.6' version '2026.3.0'
url 'https://github.com/rickbarrette/redmine_qbo_vehicles' url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
author_url 'https://barrettefabrication.com' author_url 'https://barrettefabrication.com'
requires_redmine version_or_higher: '6.1.0' requires_redmine version_or_higher: '6.1.0'

View File

@@ -17,13 +17,13 @@ module Vehicles
# Called by Redmine QBO Invoice # Called by Redmine QBO Invoice
def process_invoice_custom_fields(context={}) def process_invoice_custom_fields(context={})
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields" log "Processing invoice custom fields for invoice ##{context[:invoice].id}"
issue = context[:issue] issue = context[:issue]
# update the invoive custom fields with infomation from the issue if available # update the invoive custom fields with infomation from the issue if available
context[:invoice].custom_fields.each do |cf| context[:invoice].custom_fields.each do |cf|
Rails.logger.info "Checking invoice.custom field: #{cf.name}" log "Checking invoice custom field: #{cf.name}"
# VIN from the attached vehicle # VIN from the attached vehicle
begin begin
@@ -32,13 +32,13 @@ module Vehicles
# TODO check cf_sync_confict flag once implemented # TODO check cf_sync_confict flag once implemented
if cf.string_value.to_s.blank? if cf.string_value.to_s.blank?
Rails.logger.info "VIN was blank, updating the invoice vin in quickbooks" log "VIN was blank, updating the invoice vin in quickbooks"
vin = context[:issue].vehicle.vin vin = context[:issue].vehicle.vin
break if vin.nil? break if vin.nil?
if not cf.string_value.to_s.eql? vin if not cf.string_value.to_s.eql? vin
cf.string_value = vin.to_s cf.string_value = vin.to_s
Rails.logger.info "VIN has changed" log "VIN has changed"
context[:is_changed] = true context[:is_changed] = true
end end
@@ -47,7 +47,7 @@ module Vehicles
end end
rescue rescue
#do nothing #do nothing
Rails.logger.info "redmine_qbo_vehicles.process_invoice_custom_fields failed, skipping" log "redmine_qbo_vehicles.process_invoice_custom_fields failed, skipping"
return nil return nil
end end
end end
@@ -56,6 +56,12 @@ module Vehicles
return nil return nil
end end
private
def log(msg)
Rails.logger.info "[InvoiceHookListener] #{msg}"
end
end end
end end