Fill the VIN on new estimates and invoices through a hook

New hook qbo_billing_default_vin, { customer:, issues: }: a blank estimate or invoice starts with the VIN
a plugin gives for the customer, and an invoice made from an estimate without a VIN gets the one for the
estimate's work orders. The editor only filled the VIN when the customer was changed or work orders were
imported, so pages opened with the customer already set started blank.

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:17:25 -04:00
1 parent 28538d4c7f
commit b84f39afce
4 files changed
+21 -1

No files matched your search

+5 -1
View File
@@ -47,6 +47,7 @@ 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,
@@ -70,7 +71,10 @@ module RedmineQboBilling
form.customer_id = source.customer_id
form.email = source.email.presence || form.email
form.billing_address = source.billing_address.presence || form.billing_address
form.vin = source.vin
# 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
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