Update qbo_invoice.rb

This commit is contained in:
2016-09-13 23:14:18 -04:00
committed by GitHub
parent 4b7cf407e8
commit c189bc5dca

View File

@@ -71,7 +71,8 @@ class QboInvoice < ActiveRecord::Base
# update the invoive custom fields with infomation from the work ticket if available
invoice.custom_fields.each { |cf|
# VIN
# VIN from the attached vehicle
begin
if cf.name.eql? "VIN"
vin = Vehicle.find(i.vehicles_id).vin
@@ -89,11 +90,32 @@ class QboInvoice < ActiveRecord::Base
# Custom Values
begin
value = i.custom_values.find_by(custom_field_id: CustomField.find_by_name(cf.name).id)
# Check to see if the value is blank...
if not value.value.to_s.blank?
# Check to see if the value is diffrent
if not cf.string_value.to_s.eql? value.value.to_s
# Use the lowest Milage
if cf.name.eql? "Mileage In"
if cf.string_value.to_i > value.value.to_i
cf.string_value = value.value.to_s
is_changed = true
end
# Use the max milage
else if cf.name.eql? "Mileage Out"
if cf.string_value.to_i < value.value.to_i
cf.string_value = value.value.to_s
is_changed = true
end
# Everything else
else
cf.string_value = value.value.to_s
is_changed = true
end
end
end
rescue
# Nothing to do here, there is no match