Clientes deudores

<% if success %>

<%= success %>

<% elsif warning %>

<%= warning %>

<% end %>
Lista de clientes con ventas a crédito
<% @customers.each_with_index do |customer, key| %> <% # customer.verify_credit %> <% payment = CreditPayment.where(:customer_id => customer.id, :status => 0).order("date_payment DESC").first %> <% credito = Credit.activos.where(:customer_id => customer.id).sum(:rest) %> <% sales = Sale.where("customer_id = #{customer.id} and status != 1 and status != 2 and saletype = 0").order("date_sale DESC") %> <% if sales.first.present? && sales.first.status != "2" && credito > 0 %> <% if customer.status != "debtor" %> <% else %> <% end %> <% end %> <% end %>
Cliente Límite de crédito Monto a pagar Fecha de última venta Fecha de último abono Status Acciones
<%= customer.nick_name %> Crédito
$ <%= customer.credit_limit %>
Crédito expirado <%= number_to_currency(credito, precision: 2) %> <%= l(sales.first.date_sale, :format => '%d/%m/%Y') %> <% if payment.present? %> <%= l(payment.date_payment, :format => '%d/%m/%Y') %> <% end %> <% if customer.status == "inactive" %> <% else %> <% end %> <%= link_to customer_sales_path(:customer_id => customer.id), {:class=>"btn btn-icon-only default filtros2", :title=>"Ver detalles de ventas"} do %> <% end %> <%= link_to new_cash_registers_move_path(:sale => sales.last.id, :customer => customer.id, format: 'js'), remote: true, data: { toggle: "modal", target: "#new" }, :class=>"btn btn-icon-only green-dark", :title=>"Abonar" do %> <% end %>