Files
redmine_qbo/app/views/qbo_estimates/edit.html.erb
T
Claude 388ac915d7 Handle QuickBooks custom fields generically; no vehicle code left
redmine_qbo now works the same for any business; vehicle behaviour lives in redmine_qbo_vehicles.

- Every enabled QuickBooks text custom field gets a box on the estimate/invoice editor (the sales person
  is still filled in automatically). Forms keep custom_fields { field_id => value } instead of vin and
  mileage; Duplicate and Create invoice copy them all.
- Company: custom_field_matching(pattern) and editable_custom_fields; the VIN and Mileage name patterns
  are gone.
- Hooks are keyed by custom field id: qbo_billing_field_options (box suggestions) and
  qbo_billing_field_defaults (values for a document's work orders) replace the VIN hooks;
  qbo_billing_issue_values returns { field_id => { issue_id => value } }.
- Editor script API for plugins: window.qboEditor, the qbo:customer-changed and qbo:imported events, and
  the view_qbo_estimate_form_bottom hook to add a script. The VIN/mileage filling and the several-vehicle
  warning moved to redmine_qbo_vehicles.
- EstimateWriter.create_estimate(custom_fields:), custom_field_value and custom_field_values replace
  the vin/mileage arguments and vin_for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 11:34:10 -04:00

27 lines
2.0 KiB
ERB

<% html_title "#{l(:label_estimate)} ##{@form.doc_number}" %>
<div class="contextual">
<%# Plugins add estimate actions here (e.g. redmine_qbo_calendar's Add appointment) %>
<%= call_hook :view_qbo_estimate_contextual, { estimate_id: @form.id, customer_id: @form.customer_id, custom_fields: @form.custom_fields, doc_number: @form.doc_number } %>
<%# An estimate is billed once: no Create invoice once it's on an invoice, closed or rejected %>
<% if RedmineQboBilling.invoice_writer? && @form.locked != :billed && @form.txn_status.to_s != 'Rejected' %>
<%= link_to sprite_icon('document', l(:button_create_invoice)), new_qbo_invoice_path(estimate_id: @form.id), class: 'icon icon-document' %>
<% end %>
<% if User.current.allowed_to?(:create_estimate_issues, nil, global: true) %>
<%= link_to sprite_icon('issue', l(:button_create_estimate_issues)), issues_preview_qbo_estimate_path(@form.id), class: 'icon icon-issue' %>
<% end %>
<%= link_to sprite_icon('copy', l(:button_duplicate)), new_qbo_estimate_path(duplicate: @form.id), class: 'icon icon-copy' %>
<%= link_to sprite_icon('application-pdf', l(:label_estimate_pdf)), estimate_path(@form.id), class: 'icon icon-pdf', target: :_blank %>
<% if RedmineQboBilling.sender? && @form.email.present? %>
<%= link_to sprite_icon('email', l(:button_email_estimate)), send_email_qbo_estimate_path(@form.id, email: @form.email),
method: :post, class: 'icon icon-email',
data: { confirm: l(:text_email_estimate_confirmation, number: @form.doc_number, email: @form.email) } %>
<% end %>
<%= link_to sprite_icon('link', l(:button_open_in_quickbooks)),
"https://#{RedmineQbo.sandbox_mode? ? 'sandbox' : 'app'}.qbo.intuit.com/app/estimate?txnId=#{@form.id}",
class: 'icon icon-link', target: :_blank, rel: 'noopener' %>
</div>
<%= render partial: 'qbo_estimates/header', locals: { form: @form } %>
<%= render partial: 'qbo_estimates/form', locals: { form: @form } %>