<% html_title l(:label_payment) %> <% method_name = RedmineQboBilling::PaymentWriter.payment_method_name(@payment) %>
<%= link_to sprite_icon('application-pdf', l(:button_print_payment)), pdf_qbo_payment_path(@payment.id), class: 'icon icon-pdf', target: :_blank %> <% if @customer && RedmineQboBilling.payment_receiver? %> <%= link_to sprite_icon('add', l(:button_receive_payment)), new_qbo_payment_path(customer_id: @customer.id), class: 'icon icon-add' %> <% end %> <%= link_to sprite_icon('link', l(:button_open_in_quickbooks)), "https://#{RedmineQbo.sandbox_mode? ? 'sandbox' : 'app'}.qbo.intuit.com/app/recvpayment?txnId=#{@payment.id}", class: 'icon icon-link', target: :_blank, rel: 'noopener' %>

<%= link_to l(:label_customers), customers_path %> » <% if @customer %><%= link_to @customer.name, customer_path(@customer) %> » <%= link_to l(:label_payments), qbo_payments_path(customer_id: @customer.id) %> »<% end %> <%= l(:label_payment) %> <%= number_to_currency(@payment.total) %>

<%= l(:label_payment_date) %>:
<%= format_date(@payment.txn_date) %>
<%= l(:label_payment_method) %>:
<%= method_name %>
<%= l(:label_payment_reference) %>:
<%= @payment.payment_ref_number %>
<%= l(:label_amount) %>:
<%= number_to_currency(@payment.total) %>
<%= l(:label_payment_unapplied) %>:
<%= number_to_currency(@payment.unapplied_amount || 0) %>
<% if @payment.private_note.present? %>

<%= l(:label_memo) %>

<%= @payment.private_note %>

<% end %>

<%= l(:label_payment_applies_to) %>

<% applied = RedmineQboBilling::PaymentWriter.applied_invoices(@payment) %> <% if applied.empty? %>

<%= l(:text_payment_unapplied_deposit) %>

<% else %> <% applied.each do |invoice_id, number, amount| %> <% end %>
<%= l(:label_invoice) %><%= l(:label_payment_applied) %>
<%= link_to "##{number}", RedmineQboBilling.invoice_writer? ? edit_qbo_invoice_path(invoice_id) : invoice_path(invoice_id) %> <%= number_to_currency(amount) %>
<% end %>