From c3eaddff976538f24d2f4caffb64c45793f0122a Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sat, 3 Mar 2018 12:22:44 -0500 Subject: [PATCH 1/6] Start work to switch from edmunds_vin to nhtsa_vin --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ff6b23a..a28724a 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gem 'quickbooks-ruby-base' gem 'oauth-plugin' gem 'oauth' gem 'roxml' -gem 'edmunds_vin' +gem 'nhtsa_vin' gem 'will_paginate' gem 'rails-jquery-autocomplete' gem 'jquery-rails', '~> 3.1.4' From 8838d3679383d8624119cc3a8f0e5ac725244cb4 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sat, 3 Mar 2018 13:54:19 -0500 Subject: [PATCH 2/6] Fixed vin decoding --- app/models/vehicle.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/vehicle.rb b/app/models/vehicle.rb index 0e5d771..716bf85 100644 --- a/app/models/vehicle.rb +++ b/app/models/vehicle.rb @@ -83,15 +83,15 @@ class Vehicle < ActiveRecord::Base where("vin LIKE ?", "%#{search}%") end - private +private # init method to pull JSON details from Edmunds def get_details if self.vin? begin query = NhtsaVin.get(self.vin) - raise error if not @details.valid? - @details = query.response = NhtsaVin.get(self.vin) + raise RuntimeError, query.error unless query.valid? + @details = query.response rescue Exception => e errors.add(:vin, e.message) end @@ -103,9 +103,9 @@ class Vehicle < ActiveRecord::Base get_details if @details begin - self.year = @details.year - self.make = @details.make - self.model = @details.model + self.year = @details.year unless @details.year.nil? + self.make = @details.make unless @details.make.nil? + self.model = @details.model unless @details.model.nil? rescue Exception => e errors.add(:vin, e.message) end From 39fcd6d4dd1a413180a85a3994916d144dae9e36 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sat, 3 Mar 2018 13:55:22 -0500 Subject: [PATCH 3/6] Removed Drive & Doors --- app/views/vehicles/_details.html.erb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/views/vehicles/_details.html.erb b/app/views/vehicles/_details.html.erb index 058eb0b..50ae99a 100644 --- a/app/views/vehicles/_details.html.erb +++ b/app/views/vehicles/_details.html.erb @@ -21,16 +21,6 @@ <%= vehicle.style %> - - Drive - <%= vehicle.drive %> - - - - Doors - <%= vehicle.doors %> - - Notes <%= vehicle.notes %> From b78cd44cc93ce3e6703b1f487579eec1674cc866 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Mon, 5 Mar 2018 08:58:33 -0500 Subject: [PATCH 4/6] don't bill time if not assigned to anyone EE --- lib/issue_patch.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/issue_patch.rb b/lib/issue_patch.rb index 7512c4d..756d0da 100644 --- a/lib/issue_patch.rb +++ b/lib/issue_patch.rb @@ -41,7 +41,9 @@ module IssuePatch # Create billable time entries def bill_time - + + return if assigned_to.nil? + # Get unbilled time entries spent_time = time_entries.where(qbo_billed: [false, nil]) spent_hours ||= spent_time.sum(:hours) || 0 From 49858c45c9f0930d9feda6d38705f0c70ae434c3 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Tue, 27 Mar 2018 09:38:44 -0400 Subject: [PATCH 5/6] do a full search by setting the full parameter to true. --- app/controllers/customers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index 36f6f41..ae595c5 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -33,7 +33,7 @@ class CustomersController < ApplicationController default_search_scope :names - autocomplete :customer, :name, :full => false, :extra_data => [:id] + autocomplete :customer, :name, :full => true, :extra_data => [:id] def filter_vehicles_by_customer @filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer]) From 3509ae9725b3349494deb8be4b69593003629bcc Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Tue, 27 Mar 2018 09:40:01 -0400 Subject: [PATCH 6/6] Removed squish_vin and added last 8 of vin to vehicle name --- app/models/vehicle.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/app/models/vehicle.rb b/app/models/vehicle.rb index 716bf85..17d2e15 100644 --- a/app/models/vehicle.rb +++ b/app/models/vehicle.rb @@ -29,7 +29,8 @@ class Vehicle < ActiveRecord::Base if year.nil? or make.nil? or model.nil? return "#{vin}" else - return "#{year} #{make} #{model}" + split_vin = vin.scan(/.{1,9}/) + return "#{year} #{make} #{model} - #{split_vin[1]}" end end @@ -113,15 +114,4 @@ private self.name = to_s end - # makes a squishvin - # https://api.edmunds.com/api/vehicle/v2/squishvins/#{vin}/?fmt=json&api_key=#{ENV['edmunds_key']} - def vin_squish - if not self.vin? or self.vin.size < 11 - # this is to go ahead and query the API, letting them handle the error. :P - return '1000000000A' - end - v = self.vin[0,11] - return v.slice(0,8) + v.slice(9,11) - end - end