<%# A refund as it was made (SOP-OPS-014) %> <% html_title l(:label_refund) %> <% money = ->(amount) { RedmineQboBilling::RefundWriter.money(amount) } %>

<%= link_to l(:label_customers), customers_path %> » <% if @customer %><%= link_to @customer.name, customer_path(@customer) %> »<% end %> <%= l(:label_refund) %> <%= format_date(@refund.txn_date) %>

<%= link_to sprite_icon('application-pdf', 'PDF'), pdf_qbo_refund_path(@refund), class: 'icon icon-pdf', target: :_blank %> <% if @refund.fee_invoice_id.present? %> <%= link_to sprite_icon('application-pdf', l(:label_refund_fee_invoice_pdf)), invoice_path(@refund.fee_invoice_id), class: 'icon icon-pdf', target: :_blank %> <% end %>
<% if @refund.done? %>

<%= @refund.balance_after.nil? ? l(:text_refund_balance_unknown) : l(:text_refund_balance, balance: money.(@refund.balance_after)) %>

<% else %>

<%= l(:text_refund_incomplete) %>

<% end %> <% if @refund.message.present? %>
<%= simple_format(h(@refund.message)) %>
<% end %>

<%= @refund.estimate_id.present? ? link_to("E#{@refund.estimate_number}", RedmineQboBilling.writer? ? edit_qbo_estimate_path(@refund.estimate_id) : estimate_path(@refund.estimate_id)) : l(:label_refund_no_estimate) %>

<%= @refund.reason %>

<%= money.(@refund.credit_amount) %>

<%= money.(@refund.parts_amount) %>

<%= money.(@refund.fee_amount) %> <% if @refund.fee_invoice_id.present? %> · <%= link_to l(:label_refund_fee_invoice, number: @refund.fee_invoice_number), RedmineQboBilling.invoice_writer? ? edit_qbo_invoice_path(@refund.fee_invoice_id) : invoice_path(@refund.fee_invoice_id) %> <% end %>

<%= money.(@refund.refund_amount) %> · <%= @refund.method_name %><%= " ##{@refund.check_number}" if @refund.check? %> <% if @refund.purchase_url %> · <%= link_to l(@refund.check? ? :label_refund_open_check : :label_refund_open_expense), @refund.purchase_url, target: '_blank', rel: 'noopener' %> <% end %>

<% if @refund.estimate_number.present? %>

<%= checked_image @refund.estimate_closed? %>

<% end %> <% if @refund.canceled_issue_ids.any? %>

<%= safe_join(Issue.where(id: @refund.canceled_issue_ids).map { |issue| link_to_issue(issue, project: false) }, ', ') %>

<% end %>

<%= @refund.emailed_to.presence || '—' %> <% if @refund.done? %> · <%= link_to sprite_icon('email', l(@refund.emailed_to.present? ? :button_refund_email_again : :button_refund_email)), email_qbo_refund_path(@refund), method: :post, class: 'icon icon-email', data: { confirm: l(:text_refund_email_confirm) } %> <% end %>

<%= @refund.user ? link_to_user(@refund.user) : '' %> <%= format_time(@refund.created_at) %>