Browse Source

in cash outs, show the initial cash in cash total

jose miguel 7 years ago
parent
commit
fe06d31e38
2 changed files with 12 additions and 5 deletions
  1. 6 0
      app/controllers/cash_outs_controller.rb
  2. 6 5
      app/views/cash_outs/_form.html.erb

+ 6 - 0
app/controllers/cash_outs_controller.rb

@@ -184,6 +184,12 @@ class CashOutsController < ApplicationController
       payment["incoming"] = "0" if payment["incoming"].nil?
       payment["outgoing"] = "0" if payment["outgoing"].nil?
       payment["total"] = payment["incoming"].to_f - payment["outgoing"].to_f
+
+      # si es el efectivo sumarle el fondo
+      if payment["payment_method_id"].to_i == @cash_payment_method_id
+        payment["total"] += @initial_cash
+      end
+
       @cash_out.cash_out_details.build
     end
   end

+ 6 - 5
app/views/cash_outs/_form.html.erb

@@ -79,12 +79,12 @@
         <div class="table-scrollable">
             <table class="table table-hover table-striped table-bordered" id="payment_methods_table">
                 <thead>
-                    <tr class="uppercase">
+                    <tr>
                         <th> # </th>
                         <th> Método de pago </th>
-                        <th> Total de ingresos </th>
-                        <th> Total de egresos </th>
-                        <th>Total</th>
+                        <th> Total de ingresos (ventas) </th>
+                        <th> Total de egresos (gastos) </th>
+                        <th>Total (ventas y efectivo inicial)</th>
                     </tr>
                 </thead>
                 <tbody>
@@ -266,8 +266,9 @@
   function addCashOut() {
     if ( !$('#submit_cash_out').hasClass('disabled') ) {
       if ($('#cash_out_received_by_id').val()) {
-        $('#submit_cash_out').prop('disabled', true);
         $('#cash_out_form').submit();
+        $('#submit_cash_out').prop('disabled', true);
+        $('#submit_cash_out').addClass('disabled');
       } else {
         toastr["error"]("Seleccione quien va a recibir el corte de caja.");
       }