From 92460392b9cdc1e66fa986a642f5bb9cc1c6dc31 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Sat, 31 Jan 2026 12:45:47 -0500 Subject: [PATCH] Refactor estimates and invoices rendering to use local variables for the abilty for other plugins to display filtered lists --- app/views/customers/show.html.erb | 4 ++-- app/views/estimates/_list.html.erb | 4 ++-- app/views/invoices/_list.html.erb | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/views/customers/show.html.erb b/app/views/customers/show.html.erb index 54045b5..cb7ca1e 100644 --- a/app/views/customers/show.html.erb +++ b/app/views/customers/show.html.erb @@ -27,12 +27,12 @@

<%=t(:estimates)%>:

- <%= render partial: 'estimates/list', locals: {customer: @customer} %> + <%= render partial: 'estimates/list', locals: {estimates: @customer.estimates} %>

<%=t(:label_invoices)%>:

- <%= render partial: 'invoices/list', locals: {customer: @customer} %> + <%= render partial: 'invoices/list', locals: {invoices: @customer.invoices} %>
diff --git a/app/views/estimates/_list.html.erb b/app/views/estimates/_list.html.erb index d078a69..2429fc8 100644 --- a/app/views/estimates/_list.html.erb +++ b/app/views/estimates/_list.html.erb @@ -1,6 +1,6 @@ -<% if @customer.present? %> +<% if estimates.empty? %> - <% @customer.estimates.order(id: :desc).each do |estimate| %> + <% estimates.sort.reverse.each do |estimate| %>
<%= link_to "##{estimate.doc_number}", estimate_path(estimate), target: :_blank %> <%= estimate.txn_date %>
diff --git a/app/views/invoices/_list.html.erb b/app/views/invoices/_list.html.erb index 775514c..0a2c801 100644 --- a/app/views/invoices/_list.html.erb +++ b/app/views/invoices/_list.html.erb @@ -1,24 +1,23 @@ -<% if @customer.present? %> +<% if invoices.empty? %> <%= form_with(url: invoice_path, method: :get) do |form| %> - <% if @customer.invoices.count > 1 %> + <% if invoices.count > 1 %>
<%= check_box_tag "select-all-invoices", "1", false, id: "select-all-invoices" %> <%= label_tag "select-all-invoices", t(:label_select_all) %>
-
<% end %> - <% @customer.invoices.order(id: :desc).each do |invoice| %> + <% invoices.sort.reverse.each do |invoice| %>
<%= check_box_tag "invoice_ids[]", invoice.id, false, class: "invoice-checkbox" %> <%= link_to "##{invoice.doc_number}", invoice_path(invoice), target: :_blank %> <%= invoice.txn_date %>
<% end %> - <% if @customer.invoices.count > 1 %> + <% if invoices.count > 1 %> <%= form.submit t(:button_bulk_pdf) %> <% end %> <% end %>