<%# Title with the customer breadcrumb, errors, and warnings shared by the estimate and invoice pages %> <% customer = Customer.find_by(id: form.customer_id) if form.customer_id.present? invoice = form.invoice? %>

<%= link_to l(:label_customers), customers_path %> » <% if customer %> <%= link_to customer.name, customer_path(customer) %> » <% end %> <% if form.persisted? %> <%= l(invoice ? :label_invoice : :label_estimate) %> #<%= form.doc_number %> <% if form.sent? %> <%= l(:label_estimate_sent) %> <% end %> <% if invoice && form.locked == :paid %> <% fully_paid = form.balance.to_d.zero? %> <%= l(fully_paid ? :label_invoice_paid : :label_invoice_partially_paid) %> <% elsif !invoice && form.txn_status.present? && form.txn_status != 'Pending' %> <%= form.txn_status %> <% end %> <% else %> <%= l(invoice ? :label_new_invoice : :label_new_estimate) %> <% end %>

<%= error_messages_for form %> <% if @conflict %>

<%= l(:text_estimate_reload) %> <%= link_to l(:button_reload_estimate), invoice ? edit_qbo_invoice_path(form.id) : edit_qbo_estimate_path(form.id) %>

<% end %> <% if !invoice && Array(form.invoiced_on).any? %>
<%= l(:text_estimate_billed_on) %>
<% end %> <% if form.duplicated_from.present? %>
<%= l(:text_estimate_duplicated_from, number: form.duplicated_from) %>
<% end %> <% if form.converted_from.present? %>
<%= l(:text_invoice_from_estimate, number: form.converted_from) %>
<% end %> <% if form.locked == :linked %>
<%= l(:error_estimate_linked_to_issues) %>
<% elsif form.locked == :paid %>

<%= l(:error_invoice_paid) %>

<% elsif form.locked == :bundles %>

<%= l(invoice ? :error_invoice_has_bundles : :error_estimate_has_bundles) %>

<% elsif !invoice && %w[Converted Closed].include?(form.txn_status.to_s) && Array(form.invoiced_on).empty? %>

<%= l(:text_estimate_closed) %>

<% end %> <% if RedmineQboBilling::Company.settings.empty? %>

<%= l(:text_quickbooks_settings_unavailable) %> <% if User.current.admin? %> <%= link_to l(:button_refresh_quickbooks_fields), refresh_company_qbo_estimates_path, method: :post %> <% end %>

<% end %>