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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
Claude committed 2026-10-30 22:32:24 -04:00
1 parent 3a2d50ae8d
commit dec5b32165
1 file changed
+6 -4
+6 -4
View File
@@ -40,7 +40,8 @@ class BillLineItemsJob < ActiveJob::Base
private private
# Creates the QuickBooks estimate with redmine_qbo_billing, which writes every estimate: a first line # 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) def create_estimate(issue, unbilled_entries)
log "Creating estimate in QBO for #{issue.customer.name} from issue ##{issue.id}" log "Creating estimate in QBO for #{issue.customer.name} from issue ##{issue.id}"
memo = "Added from: #{issue.tracker} ##{issue.id}: #{issue.subject}" memo = "Added from: #{issue.tracker} ##{issue.id}: #{issue.subject}"
@@ -57,9 +58,10 @@ class BillLineItemsJob < ActiveJob::Base
} }
end end
vin = issue.respond_to?(:vehicle) ? issue.vehicle&.vin : nil values = RedmineQboBilling::IssueValues.values_for([issue])
estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines, estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines, private_note: memo,
private_note: memo, vin: vin) vin: values.dig(:vin, issue.id.to_s),
mileage: values.dig(:mileage, issue.id.to_s))
log "Created estimate ##{estimate.doc_number}" log "Created estimate ##{estimate.doc_number}"
end end