mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-11-17 19:20:36 -05:00
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:
1 file changed
+6
-4
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user