mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Merge branch 'master' into line_items
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -5,7 +5,7 @@ gem 'quickbooks-ruby-base'
|
|||||||
gem 'oauth-plugin'
|
gem 'oauth-plugin'
|
||||||
gem 'oauth'
|
gem 'oauth'
|
||||||
gem 'roxml'
|
gem 'roxml'
|
||||||
gem 'edmunds_vin'
|
gem 'nhtsa_vin'
|
||||||
gem 'will_paginate'
|
gem 'will_paginate'
|
||||||
gem 'rails-jquery-autocomplete'
|
gem 'rails-jquery-autocomplete'
|
||||||
gem 'jquery-rails', '~> 3.1.4'
|
gem 'jquery-rails', '~> 3.1.4'
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CustomersController < ApplicationController
|
|||||||
|
|
||||||
default_search_scope :names
|
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
|
def filter_vehicles_by_customer
|
||||||
@filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer])
|
@filtered_vehicles = Vehicle.all.where(customer_id: params[:selected_customer])
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class Vehicle < ActiveRecord::Base
|
|||||||
if year.nil? or make.nil? or model.nil?
|
if year.nil? or make.nil? or model.nil?
|
||||||
return "#{vin}"
|
return "#{vin}"
|
||||||
else
|
else
|
||||||
return "#{year} #{make} #{model}"
|
split_vin = vin.scan(/.{1,9}/)
|
||||||
|
return "#{year} #{make} #{model} - #{split_vin[1]}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -90,8 +91,8 @@ class Vehicle < ActiveRecord::Base
|
|||||||
if self.vin?
|
if self.vin?
|
||||||
begin
|
begin
|
||||||
query = NhtsaVin.get(self.vin)
|
query = NhtsaVin.get(self.vin)
|
||||||
raise error if not @details.valid?
|
raise RuntimeError, query.error unless query.valid?
|
||||||
@details = query.response = NhtsaVin.get(self.vin)
|
@details = query.response
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
errors.add(:vin, e.message)
|
errors.add(:vin, e.message)
|
||||||
end
|
end
|
||||||
@@ -103,9 +104,9 @@ class Vehicle < ActiveRecord::Base
|
|||||||
get_details
|
get_details
|
||||||
if @details
|
if @details
|
||||||
begin
|
begin
|
||||||
self.year = @details.year
|
self.year = @details.year unless @details.year.nil?
|
||||||
self.make = @details.make
|
self.make = @details.make unless @details.make.nil?
|
||||||
self.model = @details.model
|
self.model = @details.model unless @details.model.nil?
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
errors.add(:vin, e.message)
|
errors.add(:vin, e.message)
|
||||||
end
|
end
|
||||||
@@ -113,15 +114,4 @@ class Vehicle < ActiveRecord::Base
|
|||||||
self.name = to_s
|
self.name = to_s
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -21,16 +21,6 @@
|
|||||||
<td><%= vehicle.style %></td>
|
<td><%= vehicle.style %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>Drive</th>
|
|
||||||
<td><%= vehicle.drive %></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th>Doors</th>
|
|
||||||
<td><%= vehicle.doors %></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Notes</th>
|
<th>Notes</th>
|
||||||
<td><%= vehicle.notes %></td>
|
<td><%= vehicle.notes %></td>
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ module IssuePatch
|
|||||||
# Create billable time entries
|
# Create billable time entries
|
||||||
def bill_time
|
def bill_time
|
||||||
|
|
||||||
|
return if assigned_to.nil?
|
||||||
|
|
||||||
# Get unbilled time entries
|
# Get unbilled time entries
|
||||||
spent_time = time_entries.where(qbo_billed: [false, nil])
|
spent_time = time_entries.where(qbo_billed: [false, nil])
|
||||||
spent_hours ||= spent_time.sum(:hours) || 0
|
spent_hours ||= spent_time.sum(:hours) || 0
|
||||||
|
|||||||
Reference in New Issue
Block a user