Forráskód Böngészése

uncommented things that were changed in another pos implementations

jose miguel 7 éve
szülő
commit
82882d7004

+ 17 - 32
app/datatables/stock_by_pointsale_datatable.rb

@@ -1,8 +1,5 @@
 class StockByPointsaleDatatable
-
-  delegate :params, :image_tag, :is_a, :number_to_currency,
-    :available_products_path, :stock_by_pointsale_path,
-    to: :@view
+  delegate :params, :image_tag, :is_a, :number_to_currency, :available_products_path, :stock_by_pointsale_path, to: :@view
 
   def initialize(view, user, selected)
     @view = view
@@ -10,7 +7,7 @@ class StockByPointsaleDatatable
     @selected = selected
   end
 
-  def as_json(options = {})
+  def as_json(_options = {})
     total = WarehouseStock.activos.where('stock > 0').count + AvailableProduct.activos.where('stock > 0').count
     {
       sEcho: params[:sEcho].to_i,
@@ -20,31 +17,27 @@ class StockByPointsaleDatatable
     }
   end
 
-private
+  private
 
   def data
     stock.map do |available|
-      if available.product.img_product?
-        img = available.product.img_product.url(:small)
-      else
-        img = "/images/small/missing.png"
-      end
+      img = available.product.img_product? ? available.product.img_product.url(:small) : "/images/small/missing.png"
       category = available.categories[0]
 
       if @current_user.usertype == 'C'
         [
           (image_tag img),
           get_display_name(available.product),
-          (category.parent_id == 0 ? category.category : category.parent.category),
+          (category.parent_id.zero? ? category.category : category.parent.category),
           (category.parent_id != 0 ? category.category : ' '),
-          # available.stock.round,
+          available.stock.round,
           "<h3> $#{get_price_sale(available.product)} </h3>"
         ].compact
       else
         [
           (image_tag img),
           get_display_name(available.product),
-          (category.parent_id == 0 ? category.category : category.parent.category),
+          (category.parent_id.zero? ? category.category : category.parent.category),
           (category.parent_id != 0 ? category.category : ' '),
           available.stock_min.round,
           available.stock_max.round,
@@ -68,17 +61,12 @@ private
       name += "<br> <i class='fa fa-barcode'></i>: #{product.barcode}"
     end
 
-    return name
-
+    name
   end
 
   def get_price_sale(product)
-    if @current_user.usertype != 'S'
-      location_id = params[:location][2, params[:location].length] if !params[:location].blank?
-      return product.get_price_sale(location_id)
-    else
-      return ''
-    end
+    location_id = params[:location][2, params[:location].length] unless params[:location].blank?
+    @current_user.usertype == 'S' ? '' : product.get_price_sale(location_id)
   end
 
   def stock
@@ -86,23 +74,22 @@ private
   end
 
   def fetch_stock
-
     location = params[:location]
     category = params[:category]
     sub_category = params[:sub_category]
 
-    location_id = params[:location][2, params[:location].length] if !location.blank?
+    location_id = params[:location][2, params[:location].length] unless location.blank?
 
-    if ( @current_user.usertype == 'S' && location.blank? ) || ( !location.blank? && location.first == 'W' )
-      stock = WarehouseStock.activos.includes(:categories, :warehouse).where(:warehouse_id => (location_id.blank? ? @current_user.warehouse_id : location_id) ).where('stock > 0')
-    elsif ( @current_user.usertype != 'S' && location.blank? ) || ( !location.blank? && location.first == 'P' )
-      stock = AvailableProduct.activos.includes(:categories, :pointsale).where(:pointsale_id => (location_id.blank? ? @current_user.pointsale_id : location_id) ).where('stock > 0')
+    if (@current_user.usertype == 'S' && location.blank?) || (!location.blank? && location.first == 'W')
+      stock = WarehouseStock.activos.includes(:categories, :warehouse).where(warehouse_id: (location_id.blank? ? @current_user.warehouse_id : location_id)).where('stock > 0')
+    elsif (@current_user.usertype != 'S' && location.blank?) || (!location.blank? && location.first == 'P')
+      stock = AvailableProduct.activos.includes(:categories, :pointsale).where(pointsale_id: (location_id.blank? ? @current_user.pointsale_id : location_id)).where('stock > 0')
     end
 
     if sub_category.present?
       stock = stock.joins(:categories).where('categories.id = ?', sub_category)
     elsif category.present?
-      subs_ids = Category.activos.where(:parent_id => category).pluck(:id)
+      subs_ids = Category.activos.where(parent_id: category).pluck(:id)
       stock = stock.joins(:categories).where('categories.id IN (?)', subs_ids)
     end
 
@@ -110,7 +97,6 @@ private
       stock = stock.page(page).per_page(per_page)
     end
 
-
     unless params[:busqueda].blank?
       stock = stock.where("products.sku ilike :search or products.name ilike :search", search: "%#{params[:busqueda]}%")
     end
@@ -119,7 +105,7 @@ private
   end
 
   def page
-    params[:start].to_i/per_page + 1
+    params[:start].to_i / per_page + 1
   end
 
   def per_page
@@ -134,5 +120,4 @@ private
   def sort_direction
     params[:sSortDir_0] == "desc" ? "desc" : "asc"
   end
-
 end

+ 1 - 3
app/views/available_products/_form_stock_printable.html.erb

@@ -12,9 +12,7 @@
               <th>Stock mínimo</th>
               <th>Stock máximo</th>
             <% end %>
-            <% if current_user.usertype != 'C' %>
-              <th>Existencia</th>
-            <% end %>
+            <th>Existencia</th>
             <th>Precio</th>
           </tr>
         </thead>

+ 3 - 3
app/views/cash_outs/_form.html.erb

@@ -28,7 +28,7 @@
         <li class="list-group-item list-group-item"> Abonos a crédito
           <span class="pull-right label label-info"><%= number_to_currency(@credit_sales, precision: 2) %></span>
         </li>
-        <li class="list-group-item list-group-item"> Total de gastos
+        <li class="list-group-item list-group-item"> Total de egresos
           <span class="pull-right label label-info"><%= number_to_currency(@expenses_total, precision: 2) %></span>
         </li>
       </ul>
@@ -83,7 +83,7 @@
                         <th> # </th>
                         <th> Método de pago </th>
                         <th> Total de ingresos </th>
-                        <th> Total de gastos </th>
+                        <th> Total de egresos </th>
                         <th>Total</th>
                     </tr>
                 </thead>
@@ -172,7 +172,7 @@
       </tbody>
     </table>
 
-    <h4 class="form-section"> Gastos del día</h4>
+    <h4 class="form-section"> Egresos del día</h4>
     <table class="table table-striped table-bordered table-hover tableadvanced">
       <thead>
         <tr>

+ 3 - 3
app/views/cash_outs/receipt.pdf.erb

@@ -104,7 +104,7 @@
 				<thead>
 					<tr>
 						<th style="text-align:left">Ingresos</th>
-						<th style="text-align:center">Gastos</th>
+						<th style="text-align:center">Egresos</th>
 						<th style="text-align:right">Total</th>
 					</tr>
 				</thead>
@@ -182,10 +182,10 @@
 			</tbody>
 		</table>
 	</div>
-	<!-- gastos -->
+	<!-- egresos -->
 	<% if expenses.present? %>
 		<div class="products" style="border-bottom:1px solid black">
-			<h4 style="margin-top:5px;margin-bottom:5px">GASTOS</h4>
+			<h4 style="margin-top:5px;margin-bottom:5px">EGRESOS</h4>
 			<table cellspacing="0" style="border-collapse:collapse">
 				<thead>
 					<tr>

+ 3 - 3
app/views/cash_outs/show.html.erb

@@ -131,7 +131,7 @@
 												<div class="col-md-4">
 												    <div class="hidden-print" style="padding-left: 0px">
 												      <ul class="list-group">
-												        <li class="list-group-item list-group-item-default"> Total de gastos
+												        <li class="list-group-item list-group-item-default"> Total de egresos
 												        <span class="pull-right label label-warning"><%= number_to_currency(@expenses_total, precision: 2) %></span>
 												        </li>
 												      </ul>
@@ -177,7 +177,7 @@
 	                                                <strong><%= number_to_currency(@sales_total, precision: 2) %> </strong>
 	                                            </li>
 	                                            <li>
-	                                                <i class="fa fa-money"></i>&nbsp Total de gastos:
+	                                                <i class="fa fa-money"></i>&nbsp Total de egresos:
 	                                                <strong><%= number_to_currency(@expenses_total, precision: 2) %> </strong>
 	                                            </li>
 	                                            <li>
@@ -200,7 +200,7 @@
 									                    <th> # </th>
 									                    <th> Método de pago </th>
 									                    <th> total de ingresos </th>
-									                    <th> total de gastos </th>
+									                    <th> total de egresos </th>
 									                    <th> Total </th>
 									                </tr>
 									            </thead>