mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-18 02:20:37 -05:00
Move vehicle code out to redmine_qbo_vehicles
- IssueMileageListener removed: redmine_qbo_vehicles answers qbo_billing_issue_values with mileage. - New hook qbo_billing_build_issue sets plugins' fields on issues created from an estimate; the vehicle lookup by VIN moved to redmine_qbo_vehicles. - New hook qbo_billing_vin_options gives the VIN box's suggestions (RedmineQboBilling.vin_options) instead of reading customer.vehicles. - The customer page's New issue link script is generic: any checkbox with data-new-issue-param="issue[field]" fills that field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
11 files changed
+78
-115
No files matched your search
@@ -4,7 +4,8 @@
|
||||
vin_field = company.vin_field
|
||||
mileage_field = company.mileage_field
|
||||
customer = Customer.find_by(id: form.customer_id) if form.customer_id.present?
|
||||
vehicles = customer.respond_to?(:vehicles) ? customer.vehicles.select { |v| v.vin.present? } : []
|
||||
# VINs other plugins suggest for the VIN box (e.g. redmine_qbo_vehicles: the customer's vehicles)
|
||||
vin_options = RedmineQboBilling.vin_options(customer)
|
||||
# When QuickBooks' settings couldn't be read at all, the page header says so instead of each field
|
||||
settings_read = company.settings.present?
|
||||
# The same editor writes estimates and invoices
|
||||
@@ -121,8 +122,8 @@
|
||||
<%= text_field_tag 'estimate[vin]', form.vin, id: 'qbo_estimate_vin', list: 'qbo-estimate-vins', maxlength: 31,
|
||||
autocomplete: 'off', spellcheck: false, disabled: vin_field.nil? %>
|
||||
<datalist id="qbo-estimate-vins">
|
||||
<% vehicles.each do |vehicle| %>
|
||||
<option value="<%= vehicle.vin %>"><%= vehicle.to_s %></option>
|
||||
<% vin_options.each do |option| %>
|
||||
<option value="<%= option[:vin] %>"><%= option[:name] %></option>
|
||||
<% end %>
|
||||
</datalist>
|
||||
<% if settings_read && !vin_field %>
|
||||
|
||||
@@ -283,12 +283,14 @@ $(function () {
|
||||
loadedEmail = info.email || '';
|
||||
$('#qbo-estimate-address').text(info.billing_address || '');
|
||||
|
||||
// VINs plugins suggest for this customer (e.g. their vehicles); one fills an empty VIN box
|
||||
var options = info.vin_options || [];
|
||||
var $list = $('#qbo-estimate-vins').empty();
|
||||
(info.vehicles || []).forEach(function (vehicle) {
|
||||
$('<option>').attr('value', vehicle.vin).text(vehicle.name).appendTo($list);
|
||||
options.forEach(function (option) {
|
||||
$('<option>').attr('value', option.vin).text(option.name).appendTo($list);
|
||||
});
|
||||
if ($vin.length && !$vin.prop('disabled') && !$vin.val().trim() && (info.vehicles || []).length === 1) {
|
||||
$vin.val(info.vehicles[0].vin);
|
||||
if ($vin.length && !$vin.prop('disabled') && !$vin.val().trim() && options.length === 1) {
|
||||
$vin.val(options[0].vin);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -381,7 +383,7 @@ $(function () {
|
||||
return ids;
|
||||
};
|
||||
|
||||
// VIN and mileage from the work orders (via plugins such as redmine_qbo_vehicles and redmine_mileage_cp):
|
||||
// VIN and mileage from the work orders (via plugins such as redmine_qbo_vehicles):
|
||||
// one vehicle fills the VIN box; the highest mileage fills the mileage box
|
||||
var updateVehicleFields = function (issueIds) {
|
||||
var values = (importData && importData.issue_values) || {};
|
||||
|
||||
Reference in new issue
Block a user