mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-19 10:40:36 -05:00
Completed work that's billed and paid in full can be refunded from its invoice (Refund on the invoice, or Paid invoice on the customer's Refund page). It makes a QuickBooks Refund Receipt: the invoice lines refunded (all or part, by quantity or amount) with their products/services and tax codes, the invoice discount's share, and the restocking fee as a negative line when it's ticked: the fee rate of the parts refunded, so labor-only work has none. Paid out of the refund check or card account, with the check number. Each refund records the lines it refunded, so a line can't be refunded for more than it was billed across refunds. Optionally notes the refund on the invoice's work orders and emails the customer. The refund page, PDF and email show the lines, tax and fee. Migration 056 adds the columns to qbo_refunds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
115 lines
5.4 KiB
ERB
115 lines
5.4 KiB
ERB
<% html_title @customer.to_s %>
|
|
|
|
<h2><%= link_to l(:label_customers), customers_path %> » <%= @customer.to_s %></h2>
|
|
|
|
<%# Under the title rather than beside it, so a long name and the many actions don't crowd each other %>
|
|
<div class="contextual qbo-under-title">
|
|
<%# New issue for this customer; picks up what's ticked on this page (an estimate, other plugins' items) %>
|
|
<%= link_to sprite_icon('add', l(:label_new_issue)), new_issue_path(issue: { customer_id: @customer.id }),
|
|
id: 'dynamic-new-issue-link', class: 'icon icon-add', target: :_blank %>
|
|
<%# Plugins add their customer actions here (e.g. redmine_qbo_calendar's Add appointment) %>
|
|
<%= call_hook :view_customers_show_contextual, { customer: @customer } %>
|
|
<%# Estimates, invoices and payments are handled here, each shown to users with its permission; Open in
|
|
QuickBooks goes to their QuickBooks account page for anything else. %>
|
|
<% if RedmineQboBilling.writer? %>
|
|
<%= render partial: 'qbo_estimates/customer_link', locals: { customer: @customer } %>
|
|
<% end %>
|
|
<% if RedmineQboBilling.invoice_writer? %>
|
|
<%= render partial: 'qbo_invoices/customer_link', locals: { customer: @customer } %>
|
|
<% end %>
|
|
<% if RedmineQboBilling.payment_viewer? %>
|
|
<%= link_to sprite_icon('list', l(:label_payments)), qbo_payments_path(customer_id: @customer.id), class: 'icon icon-list' %>
|
|
<% end %>
|
|
<% if 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 %>
|
|
<% if RedmineQboBilling.refunder? %>
|
|
<%= link_to sprite_icon('arrow-narrow-left', l(:label_refund)), new_qbo_refund_path(customer_id: @customer.id), class: 'icon icon-arrow-narrow-left' %>
|
|
<% end %>
|
|
<% if User.current.allowed_to?(:edit_customers, nil, global: true) %>
|
|
<%= link_to sprite_icon('edit', l(:button_edit)), edit_customer_path(@customer),
|
|
class: 'icon icon-edit', accesskey: accesskey(:edit) %>
|
|
<% end %>
|
|
<%= link_to sprite_icon('link', l(:button_open_in_quickbooks)),
|
|
"https://#{RedmineQbo.sandbox_mode? ? 'sandbox' : 'app'}.qbo.intuit.com/app/customerdetail?nameId=#{@customer.id}",
|
|
class: 'icon icon-link', target: :_blank, rel: 'noopener' %>
|
|
</div>
|
|
<div class="issue">
|
|
|
|
<div class="splitcontent">
|
|
|
|
<div class="splitcontentleft">
|
|
|
|
<h4><%=t(:label_details)%>:</h4>
|
|
|
|
<!-- Customer Info -->
|
|
|
|
<%= render partial: 'customers/details', locals: {customer: @customer} %>
|
|
|
|
|
|
<!-- QBO Info -->
|
|
|
|
<div class="splitcontent">
|
|
<div class="splitcontentleft">
|
|
<h4><%=t(:estimates)%>:</h4>
|
|
<%= render partial: 'estimates/list', locals: {estimates: @customer.estimates, new_issue_checkboxes: true} %>
|
|
</div>
|
|
|
|
<div class="splitcontentleft">
|
|
<h4><%=t(:label_invoices)%>:</h4>
|
|
<%= render partial: 'invoices/list', locals: {invoices: @customer.invoices} %>
|
|
</div>
|
|
</div>
|
|
|
|
<%# Estimate and invoice drafts, kept in Redmine until they're saved to QuickBooks %>
|
|
<% customer_drafts = QboDraft.visible.where(customer_id: @customer.id).includes(:user).newest_first.to_a %>
|
|
<% if customer_drafts.any? %>
|
|
<h4><%= l(:label_qbo_drafts) %>:</h4>
|
|
<%= render partial: 'qbo_drafts/list', locals: { drafts: customer_drafts, show_customer: false } %>
|
|
<% end %>
|
|
|
|
<%# Refunds made from Redmine (SOP-OPS-014) %>
|
|
<% if RedmineQboBilling.refunder? %>
|
|
<% customer_refunds = QboRefund.where(customer_id: @customer.id).recent.limit(10).to_a %>
|
|
<% if customer_refunds.any? %>
|
|
<h4><%= l(:label_refunds) %>:</h4>
|
|
<table class="list">
|
|
<tbody>
|
|
<% customer_refunds.each do |refund| %>
|
|
<tr>
|
|
<td><%= link_to format_date(refund.txn_date), qbo_refund_path(refund) %></td>
|
|
<td>
|
|
<% if refund.invoice? %>
|
|
<%= link_to refund.document_label, RedmineQboBilling.invoice_writer? ? edit_qbo_invoice_path(refund.invoice_id) : invoice_path(refund.invoice_id) %>
|
|
<% elsif refund.estimate_id.present? %>
|
|
<%= link_to("E#{refund.estimate_number}", RedmineQboBilling.writer? ? edit_qbo_estimate_path(refund.estimate_id) : estimate_path(refund.estimate_id)) %>
|
|
<% end %>
|
|
</td>
|
|
<td><%= refund.method_name %></td>
|
|
<td style="text-align: right"><%= RedmineQboBilling::RefundWriter.money(refund.refund_amount) %></td>
|
|
<td><%= refund.done? ? '' : l(:label_refund_incomplete) %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<div class="splitcontentleft">
|
|
<%= call_hook :show_customer_view_right, {customer: @customer} %>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br/>
|
|
<h3><%=@open_issues.count%> <%=t(:label_open_issues)%> - <%=@hours.round(1)%> <%=t(:label_hours)%></h3>
|
|
<%= render partial: 'issues/list_simple', locals: {issues: @open_issues.open} %>
|
|
|
|
<h3><%=@closed_issues.count%> <%=t(:label_closed_issues)%> - <%= @closed_hours.round(1)%> <%=t(:label_hours)%></h3>
|
|
<%= render partial: 'issues/list_simple', locals: {issues: @closed_issues} %>
|
|
|
|
<%= render partial: 'customers/new_issue_link_script' %>
|