Blank VIN on new documents; VIN from attached estimates; read estimate VINs with newer custom fields

- New estimates and invoices start with a blank VIN; picking a customer only fills the VIN box's
  suggestions.
- Importing an estimate whose work orders give no VIN fills the invoice's VIN box with the estimate's
  own VIN (open estimates now carry it).
- EstimateWriter.vin_for reads an estimate's VIN with QuickBooks' newer custom fields (cached a minute).
  The local Estimate's details leave those out, so plugins matching the estimate's VIN to a vehicle
  never found one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-31 10:52:39 -04:00
1 parent abeb0fe0f5
commit cb705d9525
5 files changed
+40 -20

No files matched your search

+3 -3
View File
@@ -47,7 +47,6 @@ module RedmineQboBilling
customer_name: customer&.name,
email: writer.customer_email(customer),
billing_address: writer.customer_address(customer),
vin: RedmineQboBilling.default_vin(customer),
txn_date: user.today.iso8601,
sales_person: user.name,
customer_memo: Company.invoice_message,
@@ -73,8 +72,7 @@ module RedmineQboBilling
form.billing_address = source.billing_address.presence || form.billing_address
# The estimate's VIN, or else a plugin's for the estimate's work orders (e.g. their vehicle)
form.vin = source.vin.presence ||
RedmineQboBilling.default_vin(customer, issues: Issue.where(estimate_id: source.id.to_s).to_a) ||
form.vin
RedmineQboBilling.default_vin(customer, issues: Issue.where(estimate_id: source.id.to_s).to_a)
form.mileage = source.mileage
# The estimate's writer sells the job; with no one on the estimate, whoever writes the invoice
form.sales_person = source.sales_person.presence || user.name
@@ -363,6 +361,8 @@ module RedmineQboBilling
issue: linked_issue&.then { |i| "#{i.tracker} ##{i.id}: #{i.subject}" },
# Lines from this estimate go next to the invoice's time for the same issue
issue_id: issue_reference(lines.detect { |l| l.description.present? }&.description) || linked_issue&.id&.to_s,
# The estimate's own VIN, used when its work orders give none
vin: writer.custom_value(e, Company.vin_field, Company::VIN_NAME).to_s.strip,
lines: lines.map { |l| line_hash(l) }
}
end