From dec5b3216530f4a85c0e4ad0a4d9e9dbe9d34030 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 30 Oct 2026 22:32:24 -0400 Subject: [PATCH] Billing job: VIN and mileage from the work order via redmine_qbo_billing The estimate made when an issue closes gets the issue's VIN and mileage from redmine_qbo_billing's issue values hook, instead of reading the vehicle here. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM --- app/jobs/bill_line_items_job.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/jobs/bill_line_items_job.rb b/app/jobs/bill_line_items_job.rb index 7aad48f..f1ec780 100644 --- a/app/jobs/bill_line_items_job.rb +++ b/app/jobs/bill_line_items_job.rb @@ -40,7 +40,8 @@ class BillLineItemsJob < ActiveJob::Base private # Creates the QuickBooks estimate with redmine_qbo_billing, which writes every estimate: a first line - # saying where the lines came from, then the unbilled line items. The VIN comes from the issue's vehicle. + # saying where the lines came from, then the unbilled line items. The VIN and mileage are the work order's, + # from redmine_qbo_billing's issue values hook (redmine_qbo_vehicles gives the VIN, the Mileage field the mileage). def create_estimate(issue, unbilled_entries) log "Creating estimate in QBO for #{issue.customer.name} from issue ##{issue.id}" memo = "Added from: #{issue.tracker} ##{issue.id}: #{issue.subject}" @@ -57,9 +58,10 @@ class BillLineItemsJob < ActiveJob::Base } end - vin = issue.respond_to?(:vehicle) ? issue.vehicle&.vin : nil - estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines, - private_note: memo, vin: vin) + values = RedmineQboBilling::IssueValues.values_for([issue]) + estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines, private_note: memo, + vin: values.dig(:vin, issue.id.to_s), + mileage: values.dig(:mileage, issue.id.to_s)) log "Created estimate ##{estimate.doc_number}" end