mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-11-17 19:20:36 -05:00
Pass work-order custom fields generically to new estimates
create_estimate(custom_fields:) gets whatever other plugins give for the issue through redmine_qbo's issue values hook (e.g. redmine_qbo_vehicles: VIN and mileage), instead of naming a VIN and mileage. 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
+8
-5
@@ -40,8 +40,9 @@ class BillLineItemsJob < ActiveJob::Base
|
|||||||
private
|
private
|
||||||
|
|
||||||
# Creates the QuickBooks estimate with redmine_qbo's estimate writer, which writes every estimate: a first line
|
# Creates the QuickBooks estimate with redmine_qbo's estimate writer, which writes every estimate: a first line
|
||||||
# saying where the lines came from, then the unbilled line items. The VIN and mileage are the work order's,
|
# saying where the lines came from, then the unbilled line items. Its QuickBooks custom fields get what other
|
||||||
# from redmine_qbo's issue values hook (redmine_qbo_vehicles gives the VIN, the Mileage field the mileage).
|
# plugins give for the work order through redmine_qbo's issue values hook (e.g. redmine_qbo_vehicles: VIN
|
||||||
|
# and 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}"
|
||||||
@@ -58,10 +59,12 @@ class BillLineItemsJob < ActiveJob::Base
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
values = RedmineQboBilling::IssueValues.values_for([issue])
|
# { field_id => { issue_id => value } } -> { field_id => value } for this issue
|
||||||
|
custom_fields = RedmineQboBilling::IssueValues.values_for([issue])
|
||||||
|
.transform_values { |by_issue| by_issue[issue.id.to_s] }
|
||||||
|
.reject { |_, value| value.blank? }
|
||||||
estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines, private_note: memo,
|
estimate = RedmineQboBilling::EstimateWriter.create_estimate(customer: issue.customer, lines: lines, private_note: memo,
|
||||||
vin: values.dig(:vin, issue.id.to_s),
|
custom_fields: custom_fields)
|
||||||
mileage: values.dig(:mileage, issue.id.to_s))
|
|
||||||
log "Created estimate ##{estimate.doc_number}"
|
log "Created estimate ##{estimate.doc_number}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user