Bläddra i källkod

Fixes and changes in views, models and controllers

Jacqueline Maldonado 7 år sedan
förälder
incheckning
ef4c41762a

+ 1 - 1
app/controllers/special_prices_controller.rb

@@ -5,7 +5,7 @@ class SpecialPricesController < ApplicationController
   ##--- Breadcrum_rails
   add_breadcrumb "Nuevo precio(s) especial", :new_special_price_path, only: :new
 
-  before_action :set_special_price, only: [:show, :edit, :update, :destroy]
+  before_action :set_special_price, only: [:update, :destroy]
 
   # GET /special_prices/new
   def new

+ 16 - 24
app/datatables/available_products_datatable.rb

@@ -31,7 +31,6 @@ class AvailableProductsDatatable
           '5' => available.stock
         }.compact.reject { |_k, v| v.nil? }
       end
-
     else
       products.map do |product|
         category = product.categories[0]
@@ -49,18 +48,9 @@ class AvailableProductsDatatable
 
   def get_display_name(product)
     name = "<label style='margin-bottom:0px'><strong>#{product.name}</strong></label> <br>"
-
-    if product.display_attributes.present?
-      name += "#{product.display_attributes} <br>"
-    end
-
-    if product.barcode.present?
-      name += "<i class='fa fa-barcode'></i>: #{product.barcode} <br>"
-    end
-
-    if product.description.present?
-      name += "Descripción: #{product.description}"
-    end
+    name += "#{product.display_attributes} <br>" if product.display_attributes.present?
+    name += "<i class='fa fa-barcode'></i>: #{product.barcode} <br>" if product.barcode.present?
+    name += "Descripción: #{product.description}" if product.barcode.present?
     name
   end
 
@@ -69,20 +59,22 @@ class AvailableProductsDatatable
   end
 
   def fetch_products
-    if params[:table] == 'in_pointsale'
-      products = AvailableProduct.activos.where(pointsale_id: params[:id]).activos
-    else
-      products_in_pointsale = @pointsale.products.activos_children.pluck(:id)
-      products = Product.activos_children.where.not(id: products_in_pointsale).order('products.name')
-    end
+    products =
+      if params[:table] == 'in_pointsale'
+        AvailableProduct.joins(:product, :categories).activos.where(pointsale_id: params[:id]).activos
+      else
+        products_in_pointsale = @pointsale.products.activos_children.pluck(:id)
+        Product.joins(:categories).activos_children.where.not(id: products_in_pointsale).order('products.name')
+      end
 
     products = products.page(page).per_page(per_page)
     search = params[:busqueda]
-    name_searched = if search.include? ':'
-                      search[0, search.index(':') - 1]
-                    else
-                      search
-                    end
+    name_searched =
+      if search.include? ':'
+        search[0, search.index(':') - 1]
+      else
+        search
+      end
     unless search.blank?
       products = products.where("products.sku ilike :search or products.name ilike :search", search: "%#{name_searched}%").order('products.name')
       if search.include? ':'

+ 58 - 37
app/datatables/products_datatable.rb

@@ -21,40 +21,61 @@ private
 
   def data
     products.map.with_index do |product, index|
-      if product.img_product?
-        img = product.img_product.url(:medium)
-      else
-        img = "/images/small/missing.png"
-      end
-      is_product_available = product.available_in_pointsale?(@current_user.pointsale_id)
-      product_available = product.get_available_in_pointsale(@current_user.pointsale_id) if is_product_available
-      [
-        (index +1),
-        (image_tag img),
-        "<label>#{product.name} </label> <br>  SKU: <b> #{product.sku} </b>
-          #{ '<i class="fa fa-cubes font-yellow-gold"></i>' if product.is_parent }
-          <br>" + (product.parent_id.nil? ? "" : "<small>#{product.display_attributes}</small><br>") + "<i class='fa fa-barcode'></i>: <b> #{product.barcode} </b>  <br>
-          <p> #{product.description} </p>",
-        (@current_user.usertype == 'A' ? (product.is_in_dollars? ? "#{number_to_currency(product.price_base_dollars, precision: 2)} USD" : "#{number_to_currency(product.price_base, precision: 2)} MXN") : nil),
-        "<h3> #{number_to_currency(product.get_price_sale(@current_user.pointsale_id), precision: 2)}</h3>
-          #{ is_product_available && (product_available && !product_available.price_sale.nil?) && @current_user.usertype == 'G' ? ('Precio de venta base <br>' + number_to_currency(product.price_sale, precision: 2) ) : ''}",
-        product.categories[0].category,
-        product.active? ? "<i class='fa fa-check fa-2 font-green'></i>" : "<i class='fa fa-times fa-2 font-red'></i>",
-        get_actions(@current_user.usertype, product, is_product_available, product_available)
-      ].compact
+      img = product.img_product? ? product.img_product.url(:medium) : img = "/images/small/missing.png"
+      product_available = @current_user.usertype == "A" || @current_user.usertype == "SS" ? nil : product.get_available_in_pointsale(@current_user.pointsale_id)
+      arr = [
+              (index + 1),
+              (image_tag img),
+              display_name(product)
+            ]
+      arr << dollar_price(product) if @current_user.usertype == "A" || @current_user.usertype == "SS"
+      arr << [
+                product_price(product, product_available),
+                product.categories[0].category,
+                product.active? ? "<i class='fa fa-check fa-2 font-green'></i>" : "<i class='fa fa-times fa-2 font-red'></i>",
+                get_actions(product, product_available)
+              ]
+      arr.flatten
+    end
+  end
+
+  def display_name(product)
+    display_product = "<label>#{product.name} </label> <br>  SKU: <b> #{product.sku} </b>"
+    display_product += "<i class='fa fa-cubes font-yellow-gold'></i>" if product.is_parent
+    display_product += "<br>" + (product.parent_id.nil? ? "" : "<small>#{product.display_attributes}</small><br>") + "<i class='fa fa-barcode'></i>: <b> #{product.barcode} </b> <br>"
+    display_product += "<p> #{product.description} </p>"
+    display_product
+  end
+
+  def dollar_price(product)
+    if @current_user.usertype == "A" || @current_user.usertype == "SS"
+      product.is_in_dollars? ? "#{number_to_currency(product.price_base_dollars, precision: 2)} USD" : "#{number_to_currency(product.price_base, precision: 2)} MXN"
+    else
+      '.'
     end
   end
 
+  def product_price(product, product_available)
+    if @current_user.usertype == "G"
+      price_sale = product_available.present? && product_available.price_sale.present? ? product_available.price_sale : product.price_sale
+      price = "<h3> #{number_to_currency(price_sale, precision: 2)}</h3>"
+      price += 'Precio de venta base <br>' + number_to_currency(product.price_sale, precision: 2)
+    else
+      ''
+    end
+  end
 
   def products
     @products ||= fetch_products
   end
 
   def fetch_products
-    products = Product.vigentes_parents.includes(:categories)
-    if @current_user.usertype == 'G'
-      products = Product.activos_children
-    end
+    products =
+      if @current_user.usertype == 'G'
+        Product.activos_children
+      else
+        Product.vigentes_parents.includes(:categories)
+      end
     products = products.page(page).per_page(per_page)
     unless params[:busqueda].blank?
       products = products.where("sku ilike :search or name ilike :search", search: "%#{params[:busqueda]}%")
@@ -63,7 +84,7 @@ private
   end
 
   def page
-    params[:start].to_i/per_page + 1
+    params[:start].to_i / per_page + 1
   end
 
   def per_page
@@ -79,19 +100,19 @@ private
     params[:sSortDir_0] == "desc" ? "desc" : "asc"
   end
 
-  def get_actions(usertype, product, is_product_available, product_available)
+  def get_actions(product, product_available)
     links = '<div class="clearfix">'
-    links += link_to(fa_icon('search'), product, {class: 'btn btn-icon-only default filtros', :title=>"Ver producto"})
+    links += link_to(fa_icon('search'), product, { class: 'btn btn-icon-only default filtros', title: "Ver producto" })
 
-    if usertype == 'G'
-      links += (link_to(fa_icon('dollar'), available_product_edit_price_path(product_available), { :remote => true, class: 'btn btn-icon-only green-dark', :title=>"Cambiar precio"})) if is_product_available
-    elsif usertype == 'A'
-      links += link_to(fa_icon('edit'), edit_product_path(product), {class: 'btn btn-icon-only btn-primary filtros', :title=>"Modificar producto"})
-      links += link_to(fa_icon('copy'), product_edit_variants_path(product.id), {:class => 'btn btn-icon-only btn-info filtros', :title=>"Modificar variantes del producto"}) if product.presentation
-      links += link_to(fa_icon('list-alt'), product_prices_path(product),  {:remote => true, :class => 'btn btn-icon-only green-dark', :title=>"Precios en punto de venta"})
-      links += (link_to(fa_icon('toggle-off'), product_update_status_path(product),  :class => 'btn btn-icon-only default', :title=>"Desactivar producto", data: { confirm: '¿Esta seguro de desactivar el producto?', method: 'post'})) if product.active?
-      links += (link_to(fa_icon('toggle-on'), product_update_status_path(product),  :class => 'btn btn-icon-only green-jungle', :title=>"Activar producto", data: { confirm: '¿Esta seguro de activar el producto?', method: 'post'})) if product.inactive?
-      links += (link_to(fa_icon('trash-o'), product, :class => 'btn btn-icon-only btn-danger', :title=>"Eliminar producto", data: { confirm: '¿Esta seguro de eliminar el producto?', method: :delete})) if product.can_be_deleted?
+    if @current_user.usertype == 'G'
+      links += (link_to(fa_icon('dollar'), available_product_edit_price_path(product_available), { remote: true, class: 'btn btn-icon-only green-dark', title: "Cambiar precio" })) if product_available
+    elsif @current_user.usertype == "A" || @current_user.usertype == "SS"
+      links += link_to(fa_icon('edit'), edit_product_path(product), { class: 'btn btn-icon-only btn-primary filtros', title: "Modificar producto" })
+      links += link_to(fa_icon('copy'), product_edit_variants_path(product.id), { class: 'btn btn-icon-only btn-info filtros', title: "Modificar variantes del producto" }) if product.presentation
+      links += link_to(fa_icon('list-alt'), product_prices_path(product), { remote: true, class: 'btn btn-icon-only green-dark', title: "Precios en punto de venta" })
+      links += (link_to(fa_icon('toggle-off'), product_update_status_path(product), class: 'btn btn-icon-only default', title: "Desactivar producto", data: { confirm: '¿Está seguro de desactivar el producto?', method: 'post' })) if product.active?
+      links += (link_to(fa_icon('toggle-on'), product_update_status_path(product), class: 'btn btn-icon-only green-jungle', title: "Activar producto", data: { confirm: '¿Está seguro de activar el producto?', method: 'post' })) if product.inactive?
+      links += (link_to(fa_icon('trash-o'), product, class: 'btn btn-icon-only btn-danger', title: "Eliminar producto", data: { confirm: '¿Esta seguro de eliminar el producto?', method: :delete })) if product.can_be_deleted?
     end
     links += '</div>'
     return links

+ 17 - 0
app/helpers/pointsales_helper.rb

@@ -3,4 +3,21 @@ module PointsalesHelper
 		(pointsale.users.blank? ? pointsale.users.new : pointsale.users)
 		pointsale
 	end
+
+  def pointsale_status(pointsale)
+    case pointsale.status
+    when "active" then
+      content_tag(:i, "", class: "fa fa-check font-green")
+    when "inactive" then
+      content_tag(:i, "", class: "fa fa-times font-red")
+    end
+  end
+
+  def product_count(count)
+    if count > 0
+      content_tag(:i, "", class: "fa fa-check font-green")
+    else
+      content_tag(:i, "", class: "fa fa-times font-red")
+    end
+  end
 end

+ 0 - 2
app/models/available_product.rb

@@ -1,8 +1,6 @@
 class AvailableProduct < ActiveRecord::Base
-
   belongs_to :product
   belongs_to :pointsale
-
   has_many :categories, :through => :product
 
   audited

+ 16 - 24
app/models/cash_out.rb

@@ -1,26 +1,18 @@
 class CashOut < ActiveRecord::Base
-	belongs_to :user, :class_name => 'User'
-	belongs_to :received_by, :class_name => 'User'
-	belongs_to :open_cash_register
-	has_many :cash_out_details
-
-	has_one :cash_register, :through => :open_cash_register
-	has_one :pointsale, :through => :cash_register
-
-	##--- Llevar registro de Actividad del usuario
-	audited
-
-  	accepts_nested_attributes_for :cash_out_details
-  	# accepts_nested_attributes_for :cash_out_details,
-  	# 	:reject_if => proc { |att| att['received_by_id'].blank? }
-
-
-	validates :received_cash, presence: { message: "Debe indicar el efectivo a retirar." }, :on => [:create]
-	validates :cash_fund, presence: { message: "Debe indicar el fondo de caja." }, :on => [:create]
-	validates :received_by_id, presence: { message: "Debe seleccionar quien recibe el dinero del corte." }, :on => [:create]
-
-
-	validates_associated :cash_out_details
-
-
+  belongs_to :user, class_name: 'User'
+  belongs_to :received_by, class_name: 'User'
+  belongs_to :open_cash_register
+  has_many :cash_out_details
+
+  has_one :cash_register, through: :open_cash_register
+  has_one :pointsale, through: :cash_register
+
+  ##--- Llevar registro de Actividad del usuario
+  audited
+
+  accepts_nested_attributes_for :cash_out_details
+  validates :received_cash, presence: { message: "Debe indicar el efectivo a retirar." }, on: [:create]
+  validates :cash_fund, presence: { message: "Debe indicar el fondo de caja." }, on: [:create]
+  validates :received_by_id, presence: { message: "Debe seleccionar quién recibe el dinero del corte." }, on: [:create]
+  validates_associated :cash_out_details
 end

+ 5 - 7
app/models/pointsale.rb

@@ -39,19 +39,17 @@ class Pointsale < ActiveRecord::Base
 
   ##--- Validaciones previas de guardar
   validates :name, presence: { message: "Debe capturar el nombre del punto de venta." }, unless: :skip_name_validation
-  validates :prefix, presence: { message: "Debe indicar el prefijo del punto de venta." }, length: { maximum: 3, too_long: "El maximo de caracteres debe ser %{count}.", minimum: 3, too_short: "El minimo de caracteres debe ser %{count}." }, uniqueness: { message: "El prefijo ya fue utilizado, favor de especificar otro." }
+  validates :prefix, presence: { message: "Debe indicar el prefijo del punto de venta." }, length: { maximum: 3, too_long: "El máximo de caracteres debe ser %{count}.", minimum: 3, too_short: "El mínimo de caracteres debe ser %{count}." }, uniqueness: { message: "El prefijo ya fue utilizado, favor de especificar otro." }
   # validates_attachment_content_type :img_pointsale, :content_type => /\Aimage\/.*\Z/
 
   ##--- Tipo de vistas / consultas
-  scope :vigentes, -> { where("status != 0").order("status ASC, name ASC") }
-  scope :activos, -> { where("status = 1").order("name ASC") }
+  scope :vigentes, -> { where.not(status: 0).order("status ASC, name ASC") }
+  scope :activos, -> { where(status: 1).order("name ASC") }
   scope :ignore_current, ->(pointsale_id) { where.not(id: pointsale_id) }
   # def has_stock
 
-  def total_products(pointsale_id)
-    unless pointsale_id.nil?
-      Pointsale.find(pointsale_id).products.where("stock > 0").sum(:stock).to_i
-    end
+  def total_products
+    products.where("stock > 0").sum(:stock).to_i
   end
 
   def self.get_pointsale(id, option)

+ 10 - 9
app/models/product.rb

@@ -50,14 +50,14 @@ class Product < ActiveRecord::Base
   end
 
   ##--- Tipo de vistas / consultas
-  scope :vigentes, -> { where("status != 0").order(" status ASC, name ASC") }
-  scope :activos, -> { where("status = 1").order(" name ASC") }
-  scope :activos_children, -> { where("status = 1 and is_parent = false ").order("products.name ASC") }
-  scope :vigentes_parents, -> { where("status != 0 and parent_id IS NULL ").order(" status ASC, name ASC") }
-  scope :name_sku_barcode_like, ->(name) { where("status = 1 and is_parent = false and (name ilike ? or sku ilike ? or barcode ilike ?)", "%#{name}%", "%#{name}%", "%#{name}%").order("name") }
-  scope :name_sku_barcode_attribute_like, ->(name, attributes_string) { where("status = 1 and is_parent = false and (name ilike ? or sku ilike ? or barcode ilike ?) #{attributes_string}", "%#{name}%", "%#{name}%", "%#{name}%").order("name") }
+  scope :vigentes, -> { where.not(status: 0).order(" products.status ASC, products.name ASC") }
+  scope :activos, -> { where(status: 1).order("products.name ASC") }
+  scope :activos_children, -> { activos.where(is_parent: false).order("products.name ASC") }
+  scope :vigentes_parents, -> { vigentes.where("parent_id IS NULL") }
+  scope :name_sku_barcode_like, ->(name) { activos.where("is_parent = ? and (name ilike ? or sku ilike ? or barcode ilike ?)", false, "%#{name}%", "%#{name}%", "%#{name}%") }
+  scope :name_sku_barcode_attribute_like, ->(name, attributes_string) { activos.where("is_parent = ? and (name ilike ? or sku ilike ? or barcode ilike ?) #{attributes_string}", false, "%#{name}%", "%#{name}%", "%#{name}%") }
   # para special_prices
-  scope :name_sku_barcode_like_sp, ->(name) { where("status = 1 and is_parent = true and (name ilike ? or sku ilike ? or barcode ilike ?)", "%#{name}%", "%#{name}%", "%#{name}%").order("name") }
+  scope :name_sku_barcode_like_sp, ->(name) { activos.where("is_parent = ? and (name ilike ? or sku ilike ? or barcode ilike ?)", true, "%#{name}%", "%#{name}%", "%#{name}%") }
 
   def name_with_sku
     sku.to_s + " - " + name.to_s
@@ -118,8 +118,9 @@ class Product < ActiveRecord::Base
   end
 
   def get_price_sale(pointsale_id)
-    if pointsale_id != 0 && available_in_pointsale?(pointsale_id) && !get_available_in_pointsale(pointsale_id).price_sale.nil?
-      get_available_in_pointsale(pointsale_id).price_sale
+    available = get_available_in_pointsale(pointsale_id)
+    if available.present? && available.price_sale.present?
+      available.price_sale
     else
       price_sale
     end

+ 12 - 12
app/models/product_waste.rb

@@ -1,18 +1,18 @@
 class ProductWaste < ActiveRecord::Base
-	belongs_to :product
-	belongs_to :user
-	belongs_to :pointsale
-	belongs_to :warehouse
-	belongs_to :products_return_in
+  belongs_to :product
+  belongs_to :user
+  belongs_to :pointsale
+  belongs_to :warehouse
+  belongs_to :products_return_in
 
-  	##--- Llevar registro de Actividad del usuario
-	audited
+  ##--- Llevar registro de Actividad del usuario
+  audited
 
-	validates :product_id , :presence => { message: "Debe seleccionar producto." }, :on => [:create]
-	validates :quantity , :presence => { message: "Debe indicar cantidad." }, :on => [:create]
-	validates :reason , :presence => { message: "Debe indicar el motivo." }, :on => [:create]
+  validates :product_id, presence: { message: "Debe seleccionar producto." }, on: [:create]
+  validates :quantity, presence: { message: "Debe indicar cantidad." }, on: [:create]
+  validates :reason, presence: { message: "Debe indicar el motivo." }, on: [:create]
 
-	enum status: [:active, :inactive ]
+  enum status: [:active, :inactive]
 
-	scope :activos, -> { where( "status = 0").order(" id DESC") }
+  scope :activos, -> { where(status: 0).order("id DESC") }
 end

+ 10 - 8
app/views/cash_outs/opened_cash_registers.html.erb

@@ -16,6 +16,8 @@
     <!-- BEGIN PAGE CONTENT BODY -->
     <div class="page-content">
       <div class="container-fluid">
+        <%= link_to cash_outs_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
+        <% end %>
         <!-- BEGIN PAGE BREADCRUMBS -->
         <ul class="page-breadcrumb breadcrumb">
           <%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
@@ -41,14 +43,14 @@
                   <div class="caption">
                     <i class="fa fa-list "></i>
                     <span class="caption-subject bold uppercase">Lista de cajas abiertas</span>
-                  </div> 
+                  </div>
                 </div>
                 <div class="portlet-body">
                   <table class="table table-striped table-bordered table-hover tableadvanced" id="cash_outs_table">
                     <thead>
                       <tr>
                         <th>#</th>
-                        <th>Punto de venta</th> 
+                        <th>Punto de venta</th>
                         <th>Caja registradora</th>
                         <th>Ingresos</th>
                         <th>Egresos</th>
@@ -62,23 +64,23 @@
                         <tr>
                           <td><%= key + 1 %></td>
                           <td>
-                            <%= OpenCashRegister.get_pointsale(open_cash.id, "open_cash_register").name %> 
-                          </td> 
+                            <%= OpenCashRegister.get_pointsale(open_cash.id, "open_cash_register").name %>
+                          </td>
                           <td><%= open_cash.cash_register.name %> </td>
                           <td>
-                            <% amount_in =  CashRegistersMove.where(:open_cash_register => open_cash.id, :move_type =>  1).sum(:quantity) %> 
+                            <% amount_in =  CashRegistersMove.where(:open_cash_register => open_cash.id, :move_type =>  1).sum(:quantity) %>
                            <%= number_to_currency(amount_in, precision: 2) %>
                           </td>
                           <td>
                             <% amount_out = CashRegistersMove.where(:open_cash_register => open_cash.id, :move_type =>  0).sum(:quantity) %>
-                           <%= number_to_currency(amount_out, precision: 2) %>   
+                           <%= number_to_currency(amount_out, precision: 2) %>
                            </td>
                            <td>
-                             <%= number_to_currency((amount_in - amount_out), precision: 2) %>   
+                             <%= number_to_currency((amount_in - amount_out), precision: 2) %>
                            </td>
                           <td><%= open_cash.user.first_name %></td>
                           <td><%= l(open_cash.created_at, :format => '%I:%M %p') %></td>
-                        </tr>                      
+                        </tr>
                       <% end %>
                     </tbody>
                   </table>

+ 54 - 54
app/views/expenses/_expenses_for_admin.html.erb

@@ -2,10 +2,10 @@
   <div class="col-md-2 col-sm-3 col-xs-3">
     <ul class="nav nav-tabs tabs-left">
       <li class="active">
-          <a href="#puntosdeventa" data-toggle="tab"> Puntos de venta </a>
+        <a href="#puntosdeventa" data-toggle="tab"> Puntos de venta </a>
       </li>
       <li>
-          <a href="#generales" data-toggle="tab"> Generales </a>
+        <a href="#generales" data-toggle="tab"> Generales </a>
       </li>
     </ul>
   </div>
@@ -18,10 +18,10 @@
               <thead>
                 <tr>
                   <th>#</th>
-                  <th>Código de egreso</th>
-                  <th>Concepto de egreso</th>
-                  <th>Punto de venta</th>
-                  <th>Caja registradora</th>
+                  <th>Código<br>de egreso</th>
+                  <th>Concepto<br>de egreso</th>
+                  <th>Punto<br>de venta</th>
+                  <th>Caja<br>registradora</th>
                   <th>Fecha</th>
                   <th>Cantidad</th>
                   <th>Observaciones</th>
@@ -31,31 +31,31 @@
               </thead>
               <tbody>
                 <% @from_pointsale.each_with_index do |expense, key| %>
-                <tr>
-                  <td><%= expense.id %></td>
-                  <td><%= expense.expense_code %></td>
-                  <td><%= expense.expensesconcept.name %></td>
-                  <td><%= expense.open_cash_register.cash_register.pointsale.name %></td>
-                  <td><%= expense.open_cash_register.cash_register.name %></td>
-                  <td><%= l(expense.created_at, :format => '%d/%B/%Y') %> </td>
-                  <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
-                  <td><%= expense.observations %> </td>
-                  <td>
-                    <% case expense.status %>
-                    <% when "active"%>
-                      <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Caja abierta </span>
-                    <% when "canceled"%>
-                       <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
-                    <% when "registered"%>
-                       <span class="label label-sm label-success"><i class="fa fa-check"></i>  Caja cerrada </span>
-                    <% end %>
-                  </td>
-                  <td class="text-center">
-                    <% if expense.status == "active" %>
-                      <%= link_to expense, method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
-                    <% end %>
-                  </td>
-                </tr>
+                  <tr>
+                    <td><%= expense.id %></td>
+                    <td><%= expense.expense_code %></td>
+                    <td><%= expense.expensesconcept.name %></td>
+                    <td><%= expense.open_cash_register.cash_register.pointsale.name %></td>
+                    <td><%= expense.open_cash_register.cash_register.name %></td>
+                    <td><%= l(expense.created_at, format: '%d/%B/%Y') %> </td>
+                    <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
+                    <td><%= expense.observations %> </td>
+                    <td>
+                      <% case expense.status %>
+                      <% when "active"%>
+                        <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Caja abierta </span>
+                      <% when "canceled"%>
+                         <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
+                      <% when "registered"%>
+                         <span class="label label-sm label-success"><i class="fa fa-check"></i>  Caja cerrada </span>
+                      <% end %>
+                    </td>
+                    <td class="text-center">
+                      <% if expense.active? %>
+                        <%= link_to expense, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
+                      <% end %>
+                    </td>
+                  </tr>
                 <% end %>
               </tbody>
             </table>
@@ -69,8 +69,8 @@
               <thead>
                 <tr>
                   <th>#</th>
-                  <th>Código de egreso</th>
-                  <th>Concepto de gasto</th>
+                  <th>Código<br>de egreso</th>
+                  <th>Concepto<br>de gasto</th>
                   <th>Fecha</th>
                   <th>Cantidad</th>
                   <th>Observaciones</th>
@@ -80,27 +80,27 @@
               </thead>
               <tbody>
                 <% @general_expenses.each_with_index do |expense, key| %>
-                <tr>
-                  <td><%= expense.id %></td>
-                  <td><%= expense.expense_code %></td>
-                  <td><%= expense.expensesconcept.name %></td>
-                  <td><%= l(expense.expense_date, :format => '%d/%B/%Y') %> </td>
-                  <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
-                  <td><%= expense.observations %> </td>
-                  <td>
-                    <% case expense.status %>
-                    <% when "active"%>
-                      <span class="label label-sm label-success"> <i class="fa fa-check"></i> Activo </span>
-                    <% when "canceled"%>
-                       <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelado </span>
-                    <% end %>
-                  </td>
-                  <td class="text-center">
-                    <% if expense.active? %>
-                      <%= link_to expense, method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
-                    <% end %>
-                  </td>
-                </tr>
+                  <tr>
+                    <td><%= expense.id %></td>
+                    <td><%= expense.expense_code %></td>
+                    <td><%= expense.expensesconcept.name %></td>
+                    <td><%= l(expense.expense_date, format: '%d/%B/%Y') %> </td>
+                    <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
+                    <td><%= expense.observations %> </td>
+                    <td>
+                      <% case expense.status %>
+                      <% when "active"%>
+                        <span class="label label-sm label-success"> <i class="fa fa-check"></i> Activo </span>
+                      <% when "canceled"%>
+                         <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelado </span>
+                      <% end %>
+                    </td>
+                    <td class="text-center">
+                      <% if expense.active? %>
+                        <%= link_to expense, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i> <% end %>
+                      <% end %>
+                    </td>
+                  </tr>
                 <% end %>
               </tbody>
             </table>

+ 2 - 2
app/views/expenses/_expenses_for_manager.html.erb

@@ -33,8 +33,8 @@
         <% end %>
       </td>
       <td class="text-center">
-        <% if expense.status == "active" %>
-          <%= link_to expense , method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar egreso", data: { confirm: '¿Esta seguro que desea cancelar el egreso?'}   do %> <i class="fa fa-ban"></i><% end %>
+        <%= expense.active? %>
+          <%= link_to expense, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
         <% end %>
       </td>
     </tr>

+ 66 - 67
app/views/expensesconcepts/_form.html.erb

@@ -1,78 +1,78 @@
-<%= form_for(@expensesconcept, :html => {:class=>"form-horizontal"}) do |f| %>
-
-<div class="portlet-body form">
-	<% if @expensesconcept.errors.any? %>
-	<div class="alert alert-danger">
-		<strong>Tiene <%= pluralize(@expensesconcept.errors.count, "error") %> no se puede guardar el concepto de egreso</strong><br>
-	</div>
-	<% end %>
-	<div class="form-body">
-		<div class="form-group">
-			<%= f.label :name, "Nombre del Concepto", {:class=>"col-md-3 control-label"} do %> Nombre del concepto
-				<span class="required">*</span>
-			<% end %>
-			<div class="col-md-9">
-				<%= f.text_field :name, {:class=>"form-control"} %>
-			</div>
+<%= form_for(@expensesconcept, html: { class: "form-horizontal" }) do |f| %>
+	<div class="portlet-body form">
+		<% if @expensesconcept.errors.any? %>
+		<div class="alert alert-danger">
+			<strong>Tiene <%= pluralize(@expensesconcept.errors.count, "error") %> no se puede guardar el concepto de egreso</strong><br>
 		</div>
-		<div class="form-group">
-			<%= f.label :decription, "Descripción", {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.text_field :description, {:class=>"form-control"} %>
+		<% end %>
+		<div class="form-body">
+			<div class="form-group">
+				<%= f.label :name, "Nombre del Concepto", { class: "col-md-3 col-sm-3 control-label" } do %> Nombre del concepto
+					<span class="required">*</span>
+				<% end %>
+				<div class="col-md-5 col-sm-5">
+					<%= f.text_field :name, { class: "form-control" } %>
+				</div>
 			</div>
-		</div>
-		<% if @expensesconcept.persisted? %>
-		<div class="form-group">
-			<%= f.label :status, {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.check_box(:status,
-					{
-						class: "make-switch",
-						data: {
-							on_color: "success",
-							off_color: "danger",
-							on_text: "Activo",
-							off_text: "Inactivo"
-						}
-					},
-					"active", "inactive"
-				) %>
+			<div class="form-group">
+				<%= f.label :decription, "Descripción", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-5 col-sm-5">
+					<%= f.text_area :description, { class: "form-control", rows: 5 } %>
+				</div>
 			</div>
-		</div>
-		<% end %>
-		<div class="form-group ">
-			<%= f.label :allpoints, "Aplica a todo los puntos de venta?", {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.check_box(:allpoints,
-					{
-						class: "make-switch",
-						data: {
-							on_color: "success",
-							off_color: "danger",
-							on_text: "Si",
-							off_text: "No"
-						}
-					},"true", "false"
-				) %>
+			<% if @expensesconcept.persisted? %>
+			<div class="form-group">
+				<%= f.label :status, { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-2 col-sm-2">
+					<%= f.check_box(:status,
+						{
+							class: "make-switch",
+							data: {
+								on_color: "success",
+								off_color: "danger",
+								on_text: "Activo",
+								off_text: "Inactivo"
+							}
+						},
+						"active", "inactive"
+					) %>
+				</div>
 			</div>
-		</div>
-		<div class="form-group" id="boxpointsales" <% if @expensesconcept.allpoints? %> style="display:none;"  <% end %> >
-			<%= f.label :pointsale_ids, "Puntos de Venta", {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.collection_select :pointsale_ids, Pointsale.activos, :id, :name, {:selected => @expensesconcept.pointsale_ids, :include_blank => false}, {:multiple => true, :class => "multi-select "}   %>
+			<% end %>
+			<div class="form-group ">
+				<%= f.label :allpoints, "Aplica a todo los puntos de venta?", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-2 col-sm-2">
+					<%= f.check_box(:allpoints,
+						{
+							class: "make-switch",
+							data: {
+								on_color: "success",
+								off_color: "danger",
+								on_text: "Si",
+								off_text: "No"
+							}
+						},"true", "false"
+					) %>
+				</div>
+			</div>
+			<div class="form-group" id="boxpointsales" <% if @expensesconcept.allpoints? %> style="display:none;" <% end %> >
+				<%= f.label :pointsale_ids, "Puntos de Venta", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-5 col-sm-5">
+					<%= f.collection_select :pointsale_ids, Pointsale.activos, :id, :name, { selected: @expensesconcept.pointsale_ids, include_blank: false }, { multiple: true, class: "multi-select" } %>
+				</div>
 			</div>
 		</div>
-	</div>
-	<div class="form-actions">
-		<div class="row">
-			<div class="col-md-offset-3 col-md-9">
-				<%= f.submit 'Guardar', {:class=>"btn green"} %>
-				<%= link_to 'Cancelar', expensesconcepts_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
+		<div class="form-actions">
+			<div class="row">
+				<div class="col-md-offset-3 col-md-9">
+					<%= f.submit 'Guardar', { class: "btn green" } %>
+					<%= link_to 'Cancelar', expensesconcepts_path(filter: @filter, current_page: @current_page), { class: "btn default" } %>
+				</div>
 			</div>
 		</div>
 	</div>
-</div>
 <% end %>
+
 <script type="text/javascript">
 	$(document).ready(function() {
 		handleMultiSelect();
@@ -81,8 +81,7 @@
 		$('input[name="expensesconcept[allpoints]"]').on('switchChange.bootstrapSwitch', function(event, state) {
 			if (state) {
 				$("#boxpointsales").hide();
-
-			}else{
+			} else {
 				$("#boxpointsales").show();
 			}
 		});

+ 42 - 42
app/views/pointsales/_form.html.erb

@@ -1,4 +1,4 @@
-<%= form_for(setup_pointsale(@pointsale), :html => {:class=>"form-horizontal"}) do |f| %>
+<%= form_for(setup_pointsale(@pointsale), html: { class: "form-horizontal" }) do |f| %>
 	<div class="portlet-body form">
 		<% if @pointsale.errors.any? %>
 		<div class="alert alert-danger">
@@ -9,49 +9,49 @@
 			<!-- <div class="profile-sidebar"></div>	-->
 			<h4 class="form-section">Información del punto de venta</h4>
 			<div class="form-group">
-				<%= f.label :name, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Nombre del punto de venta
+				<%= f.label :name, "Nombre del punto de venta", { class: "col-md-3 col-sm-3 control-label" } do %> Nombre del punto de venta
 					<span class="required">*</span>
 				<% end %>
-				<div class="col-md-9">
-					<%= f.text_field :name, {:class=>"form-control"} %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_field :name, { class: "form-control" } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :prefix, "Prefijo", {:class=>"col-md-3 control-label"} do %> Prefijo
+				<%= f.label :prefix, "Prefijo", { class: "col-md-3 col-sm-3 control-label" } do %> Prefijo
 					<span class="required">*</span>
 				<% end %>
-				<div class="col-md-9">
-					<%= f.text_field :prefix, {:class=>"form-control"} %>
+				<div class="col-md-3 col-sm-6">
+					<%= f.text_field :prefix, { class: "form-control input-xsmall", maxlength: 3 } %>
 					<span class="help-block">El prefijo es la abreviación que se utilizará para identificar al punto de venta, debe conformarse de 3 letras.</span>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :address, "Dirección", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
-					<%= f.text_field :address, {:class=>"form-control"} %>
+				<%= f.label :address, "Dirección", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_field :address, { class: "form-control" } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :haggle_percent, {:class=>"col-md-3 control-label"} do %> Porcentaje de regateo para ventas <% end %>
-				<div class="col-md-2">
-					<%= f.number_field :haggle_percent, {:class=>"form-control" }  %>
+				<%= f.label :haggle_percent, { class: "col-md-3 col-sm-3 control-label" } do %> Porcentaje de regateo para ventas <% end %>
+				<div class="col-md-2 col-sm-6">
+					<%= f.number_field :haggle_percent, { class: "form-control input-xsmall" } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :notes, "Encabezado para el ticket", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
-					<%= f.text_area :notes, {:class=>"form-control", :rows => 5} %>
+				<%= f.label :notes, "Encabezado para el ticket", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_area :notes, { class: "form-control", rows: 5 } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :ticket_footer, "Pie de pagina para ticket", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
-					<%= f.text_area :ticket_footer, {:class=>"form-control", :rows => 5} %>
+				<%= f.label :ticket_footer, "Pie de pagina para ticket", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_area :ticket_footer, { class: "form-control", rows: 5 } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :img_pointsale, "Imagen para el ticket", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
+				<%= f.label :img_pointsale, "Imagen para el ticket", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
 					<div class="fileinput fileinput-new" data-provides="fileinput">
 						<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
 							<% if @pointsale.img_pointsale? %>
@@ -65,7 +65,7 @@
 							<span class="btn default btn-file">
 								<span class="fileinput-new"> Seleccione imagen </span>
 								<span class="fileinput-exists"> Cambiar </span>
-								<%= f.file_field :img_pointsale, {:class=>"default"} %>
+								<%= f.file_field :img_pointsale, { class: "default" } %>
 								<%= f.hidden_field :img_pointsale_cache %>
 							</span>
 							<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Borrar </a>
@@ -77,51 +77,51 @@
 				<h4 class="form-section">Usuario responsable de punto de venta</h4>
 				<%= f.fields_for :users, @pointsale.users do |u| %>
 					<div class="form-group">
-						<%= u.label :first_name, "Nombre", {:class=>"col-md-3 control-label"} do %> Nombre
+						<%= u.label :first_name, "Nombre", { class: "col-md-3 col-sm-3 control-label" } do %> Nombre
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :first_name, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :first_name, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :last_name, "Apellidos", {:class=>"col-md-3 control-label"} do %> Apellidos
+						<%= u.label :last_name, "Apellidos", { class: "col-md-3 col-sm-3 control-label" } do %> Apellidos
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :last_name, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :last_name, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :email, "Correo", {:class=>"col-md-3 control-label"} do %> Correo electrónico
+						<%= u.label :email, "Correo", { class: "col-md-3 col-sm-3 control-label" } do %> Correo electrónico
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :email, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :email, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :userid, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Usuario
+						<%= u.label :userid, "Nombre del punto de venta", { class: "col-md-3 col-sm-3 control-label" } do %> Usuario
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :userid, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :userid, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :password, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Contraseña
+						<%= u.label :password, "Nombre del punto de venta", { class: "col-md-3 col-sm-3 control-label" } do %> Contraseña
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.password_field :password, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.password_field :password, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :password_confirmation, "Confirmar contraseña", {:class=>"col-md-3 control-label"} do %> Confirmar Contraseña
+						<%= u.label :password_confirmation, "Confirmar contraseña", { class: "col-md-3 col-sm-3 control-label" } do %> Confirmar Contraseña
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.password_field :password_confirmation, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.password_field :password_confirmation, { class: "form-control" } %>
 						</div>
 					</div>
 				<% end %>
@@ -130,8 +130,8 @@
 		<div class="form-actions">
 			<div class="row">
 				<div class="col-md-offset-3 col-md-9">
-					<%= f.submit 'Guardar', {:class=>"btn green"} %>
-					<%= link_to 'Cancelar', pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
+					<%= f.submit 'Guardar', { class: "btn green" } %>
+					<%= link_to 'Cancelar', pointsales_path(filter: @filter, current_page: @current_page), { class: "btn default" } %>
 				</div>
 			</div>
 		</div>

+ 19 - 34
app/views/pointsales/_index.html.erb

@@ -1,43 +1,28 @@
 <% @pointsales.each_with_index do |pointsale, key| %>
-<tr>
+  <tr>
     <td><%= key + 1 %></td>
     <td><%= pointsale.name %></td>
     <td><%= pointsale.prefix %></td>
     <td><%= pointsale.address %></td>
-    <td class="text-center"><% if pointsale.products.count > 0 %>
-            <i class="fa fa-check font-green"></i>
-            <% else %>
-            <i class="fa fa-times font-red"></i>
-        <% end %></td>
-    <td class="text-center">
-        <% if pointsale.total_products(pointsale.id) > 0 %>
-            <i class="fa fa-check font-green"></i>
-            <% else %>
-            <i class="fa fa-times font-red"></i>
-        <% end %></td>
-    <td class="text-center"><% if pointsale.status == "active" %>
-            <i class="fa fa-check font-green"></i>
-            <% else %>
-            <i class="fa fa-times font-red"></i>
-            <% end %></td>
-    <td >
-        <%= link_to edit_pointsale_path(pointsale, :todo => "products"), {:class=>"btn btn-icon-only default", :title=>"Actualizar productos disponibles"} do %>
-             <i class="fa fa-object-group"></i>
+    <td class="text-center"><%= product_count(pointsale.products.count) %></td>
+    <td class="text-center"><%= product_count(pointsale.total_products) %></td>
+    <td class="text-center"><%= pointsale_status(pointsale) %></td>
+    <td>
+      <%= link_to edit_pointsale_path(pointsale, todo: "products"), { class: "btn btn-icon-only default", title: "Actualizar productos disponibles" } do %>
+         <i class="fa fa-object-group"></i>
+      <% end %>
+      <%= link_to edit_pointsale_path(pointsale), { class: "btn btn-icon-only btn-primary", title: "Editar punto de venta" } do %>
+         <i class="fa fa-edit"></i>
+      <% end %>
+      <% if pointsale.active? && pointsale.open_cash_registers.where("open_cash_registers.status = ?", 0).count == 0 %>
+        <%= link_to pointsale_update_status_path(pointsale), class: "btn btn-icon-only default", title: "Desactivar punto de venta", data: { confirm: '¿Está seguro de desactivar el punto de venta?', method: 'post' } do %>
+          <i class="fa fa-toggle-off"></i>
         <% end %>
-        <%= link_to edit_pointsale_path(pointsale), {:class=>"btn btn-icon-only btn-primary", :title=>"Editar punto de venta"} do %>
-             <i class="fa fa-edit"></i>
+      <% elsif pointsale.inactive? %>
+        <%= link_to pointsale_update_status_path(pointsale), class: "btn btn-icon-only green-jungle", title: "Activar punto de venta", data: { confirm: '¿Está seguro de activar el punto de venta?', method: 'post' } do %>
+          <i class="fa fa-toggle-on"></i>
         <% end %>
-        <% if pointsale.active? && pointsale.open_cash_registers.where("open_cash_registers.status = 0").count == 0 %>
-            <%= link_to pointsale_update_status_path(pointsale), :class=>"btn btn-icon-only default", :title=>"Desactivar punto de venta", data: { confirm: '¿Esta seguro de desactivar el punto de venta?', method: 'post'}  do %>
-                <i class="fa fa-toggle-off"></i>
-            <% end %>
-        <% elsif pointsale.inactive? %>
-            <%= link_to pointsale_update_status_path(pointsale), :class=>"btn btn-icon-only green-jungle", :title=>"Activar punto de venta", data: { confirm: '¿Esta seguro de activar el punto de venta?', method: 'post'}  do %>
-                <i class="fa fa-toggle-on"></i>
-            <% end %>
-        <% end %>
-
-
+      <% end %>
     </td>
-</tr>
+  </tr>
 <% end %>

+ 49 - 50
app/views/pointsales/edit.html.erb

@@ -1,62 +1,61 @@
-	<!-- BEGIN CONTAINER -->
-	<div class="page-container">
-		<!-- BEGIN CONTENT -->
-		<div class="page-content-wrapper">
-			<!-- BEGIN CONTENT BODY -->
-			<!-- BEGIN PAGE HEAD-->
-			<div class="page-head">
-				<div class="container-fluid">
-					<!-- BEGIN PAGE TITLE -->
-					<div class="page-title">
-						<h1> Punto de Venta </h1>
-					</div>
-					<!-- END PAGE TITLE -->
+<!-- BEGIN CONTAINER -->
+<div class="page-container">
+	<!-- BEGIN CONTENT -->
+	<div class="page-content-wrapper">
+		<!-- BEGIN CONTENT BODY -->
+		<!-- BEGIN PAGE HEAD-->
+		<div class="page-head">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE TITLE -->
+				<div class="page-title">
+					<h1> Punto de Venta </h1>
 				</div>
+				<!-- END PAGE TITLE -->
 			</div>
-			<!-- END PAGE HEAD-->
-			<!-- BEGIN PAGE CONTENT BODY -->
-			<div class="page-content">
-				<div class="container-fluid">
-					<%= link_to  pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
-					<% end %>
-					<!-- BEGIN PAGE BREADCRUMBS -->
-					<ul class="page-breadcrumb breadcrumb">
-						<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-					</ul>
-					<!-- END PAGE BREADCRUMBS -->
-					<!-- BEGIN PAGE CONTENT INNER -->
-					<div class="page-content-inner">
-						<div class="row ">
-							<!-- editar punto de venta -->
-							<div class='col-md-12'>
-								<div class="portlet light">
-									<div class="portlet-title">
-										<div class="caption">
-											<i class="fa fa-edit font-blue-sharp"></i>
-											<span class="caption-subject font-blue-sharp bold uppercase">
-												<% if @todo == "products" %>
+		</div>
+		<!-- END PAGE HEAD-->
+		<!-- BEGIN PAGE CONTENT BODY -->
+		<div class="page-content">
+			<div class="container-fluid">
+				<%= link_to pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
+				<% end %>
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+				<!-- END PAGE BREADCRUMBS -->
+				<!-- BEGIN PAGE CONTENT INNER -->
+				<div class="page-content-inner">
+					<div class="row ">
+						<!-- editar punto de venta -->
+						<div class='col-md-12'>
+							<div class="portlet light">
+								<div class="portlet-title">
+									<div class="caption">
+										<i class="fa fa-edit font-blue-sharp"></i>
+										<span class="caption-subject font-blue-sharp bold uppercase">
+											<% if @todo == "products" %>
 												actualizar productos del punto de venta
-												<% else %>
+											<% else %>
 												EDITAR PUNTO DE VENTA
-												<% end %>
-											</span>
-										</div>
+											<% end %>
+										</span>
 									</div>
-									<% if @todo == "products" %>
+								</div>
+								<% if @todo == "products" %>
 									<%= render 'assign_delete_prods' %>
-									<% else %>
+								<% else %>
 									<%= render 'form' %>
-									<% end %>
-								</div>
-							</div>						
-						</div> 
+								<% end %>
+							</div>
+						</div>
 					</div>
-					<!-- END PAGE CONTENT INNER -->
 				</div>
+				<!-- END PAGE CONTENT INNER -->
 			</div>
-			<!-- END PAGE CONTENT BODY -->
-			<!-- END CONTENT BODY -->
 		</div>
-		<!-- END CONTENT -->
+		<!-- END PAGE CONTENT BODY -->
+		<!-- END CONTENT BODY -->
 	</div>
-	<!-- END CONTAINER -->
+	<!-- END CONTENT -->
+</div>

+ 77 - 78
app/views/pointsales/index.html.erb

@@ -1,87 +1,86 @@
-		<!-- BEGIN CONTAINER -->
-		<div class="page-container">
-			<!-- BEGIN CONTENT -->
-			<div class="page-content-wrapper">
-				<!-- BEGIN CONTENT BODY -->
-				<!-- BEGIN PAGE HEAD-->
-				<div class="page-head">
-					<div class="container-fluid">
-						<!-- BEGIN PAGE TITLE -->
-						<div class="page-title">
-							<h1>Puntos de Ventas </h1>
-						</div>
-						<!-- END PAGE TITLE -->
-					</div>
+<!-- BEGIN CONTAINER -->
+<div class="page-container">
+	<!-- BEGIN CONTENT -->
+	<div class="page-content-wrapper">
+		<!-- BEGIN CONTENT BODY -->
+		<!-- BEGIN PAGE HEAD-->
+		<div class="page-head">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE TITLE -->
+				<div class="page-title">
+					<h1>Puntos de Ventas </h1>
 				</div>
-				<!-- END PAGE HEAD-->
-				<!-- BEGIN PAGE CONTENT BODY -->
-				<div class="page-content">
-					<div class="container-fluid">
-						<!-- BEGIN PAGE BREADCRUMBS -->
-						<ul class="page-breadcrumb breadcrumb">
-							<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-						</ul>
-						<!-- END PAGE BREADCRUMBS -->
-						<!-- BEGIN PAGE CONTENT INNER -->
-						<div class="page-content-inner">
-							<div id="notice">
-								<% if success %>
-								<div class="alert alert-success">
-									<p><%= success %></p>
-								</div>
-								<% elsif warning %>
-								<div class="alert alert-warning">
-									<p><%= warning %></p>
-								</div>
-								<% end %>
-							 </div>
-							<div class="row">
-								<div class="col-md-12">
-									<div class="portlet light ">
-										<div class="portlet-title">
-											<div class="caption">
-												<i class="fa fa-list "></i>
-												<span class="caption-subject bold uppercase">Lista de Puntos de venta</span>
-											</div>
-											<div class="actions">
-												<% if can? :create, Pointsale %>
-												<%= link_to new_pointsale_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo punto de venta <i class="fa fa-plus"></i>
-												<% end %>
-												<% end %>
-											</div>
-										</div>
-										<div class="portlet-body">
-											<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
-											<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
-											<table class="table table-striped table-bordered table-hover tableadvanced">
-												<thead>
-													<tr>
-														<th>#</th>
-														<th>Nombre</th>
-														<th>Prefijo</th>
-														<th>Direcci&oacute;n</th>
-														<th>Productos<br>disponibles</th>
-														<th>¿Tiene inventario?</th>
-														<th>Status</th>
-														<th>Acciones</th>
-													</tr>
-												</thead>
-												<tbody  class="pointsale-index">
-													<%= render "index" %>
-												</tbody>
-											</table>
-										</div>
+				<!-- END PAGE TITLE -->
+			</div>
+		</div>
+		<!-- END PAGE HEAD-->
+		<!-- BEGIN PAGE CONTENT BODY -->
+		<div class="page-content">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+				<!-- END PAGE BREADCRUMBS -->
+				<!-- BEGIN PAGE CONTENT INNER -->
+				<div class="page-content-inner">
+					<div id="notice">
+						<% if success %>
+						<div class="alert alert-success">
+							<p><%= success %></p>
+						</div>
+						<% elsif warning %>
+						<div class="alert alert-warning">
+							<p><%= warning %></p>
+						</div>
+						<% end %>
+					 </div>
+					<div class="row">
+						<div class="col-md-12">
+							<div class="portlet light ">
+								<div class="portlet-title">
+									<div class="caption">
+										<i class="fa fa-list "></i>
+										<span class="caption-subject bold uppercase">Lista de Puntos de venta</span>
 									</div>
+									<div class="actions">
+										<% if can? :create, Pointsale %>
+											<%= link_to new_pointsale_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo punto de venta <i class="fa fa-plus"></i><% end %>
+										<% end %>
+									</div>
+								</div>
+								<div class="portlet-body">
+									<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
+									<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
+									<table class="table table-striped table-bordered table-hover tableadvanced">
+										<thead>
+											<tr>
+												<th>#</th>
+												<th>Nombre</th>
+												<th>Prefijo</th>
+												<th>Direcci&oacute;n</th>
+												<th>Productos<br>disponibles</th>
+												<th>¿Tiene inventario?</th>
+												<th>Status</th>
+												<th>Acciones</th>
+											</tr>
+										</thead>
+										<tbody  class="pointsale-index">
+											<%= render "index" %>
+										</tbody>
+									</table>
 								</div>
 							</div>
 						</div>
-						<!-- END PAGE CONTENT INNER -->
 					</div>
 				</div>
-				<!-- END PAGE CONTENT BODY -->
-				<!-- END CONTENT BODY -->
+				<!-- END PAGE CONTENT INNER -->
 			</div>
-			<!-- END CONTENT -->	
 		</div>
-		<!-- END CONTAINER -->
-		<div id="form-modal" class="modal fade" tabindex="-1" role="basic" aria-hidden="true"> </div>
+		<!-- END PAGE CONTENT BODY -->
+		<!-- END CONTENT BODY -->
+	</div>
+	<!-- END CONTENT -->
+</div>
+<!-- END CONTAINER -->
+<div id="form-modal" class="modal fade" tabindex="-1" role="basic" aria-hidden="true"> </div>

+ 30 - 30
app/views/pos_configs/_form.html.erb

@@ -9,70 +9,70 @@
     <div class="row">
       <div class="col-md-11 col-sm-12">
         <div class="form-group">
-          <%= f.label :cancel_partial_payment, { class: "col-md-3 col-sm-6 control-label" } do %>Días para cancelar abono
+          <%= f.label :cancel_partial_payment, { class: "col-md-3 col-sm-3 control-label" } do %>Días para cancelar abono
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :cancel_partial_payment, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :refund_sale, { class: "col-md-3 col-sm-6 control-label" } do %>Días para aceptar devolución
+          <%= f.label :refund_sale, { class: "col-md-3 col-sm-3 control-label" } do %>Días para aceptar devolución
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :refund_sale, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :days_cancel_sale, { class: "col-md-3 col-sm-6 control-label" } do %>Días para cancelar venta
+          <%= f.label :days_cancel_sale, { class: "col-md-3 col-sm-3 control-label" } do %>Días para cancelar venta
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :days_cancel_sale, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :days_cancel_purchase, { class: "col-md-3 col-sm-6 control-label"} do %>Días para cancelar compra
+          <%= f.label :days_cancel_purchase, { class: "col-md-3 col-sm-3 control-label"} do %>Días para cancelar compra
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :days_cancel_purchase, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :reserve_sale_percent, { class: "col-md-3 col-sm-6 control-label" } do %>Porcentaje para realizar apartado
+          <%= f.label :reserve_sale_percent, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje para realizar apartado
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :reserve_sale_percent, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :days_cancel_reserved, { class: "col-md-3 control-label" } do %>Días para cancelar apartado
+          <%= f.label :days_cancel_reserved, { class: "col-md-3 col-sm-3 control-label" } do %>Días para cancelar apartado
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :days_cancel_reserved, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :tax_percent, { class: "col-md-3 control-label" } do %>IVA a aplicar
+          <%= f.label :tax_percent, { class: "col-md-3 col-sm-3 control-label" } do %>IVA a aplicar
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :tax_percent, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :commission_percent, { class: "col-md-3 control-label" } do %>Porcentaje por comisión de venta
+          <%= f.label :commission_percent, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje por comisión de venta
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :commission_percent, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :gain_margin, { class: "col-md-3 control-label" } do %>Porcentaje de margen de ganancia
+          <%= f.label :gain_margin, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje de margen de ganancia
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :gain_margin, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :enable_haggle, { class: "col-md-3 control-label" } do %> ¿Permitir regateo en ventas? <span class="required">*</span><% end %>
-          <div class="col-md-1">
+          <%= f.label :enable_haggle, { class: "col-md-3 col-sm-3 control-label" } do %> ¿Permitir regateo en ventas? <span class="required">*</span><% end %>
+          <div class="col-md-1 col-sm-2">
             <%= f.check_box(:enable_haggle,
               {
                 class: "make-switch",
@@ -89,42 +89,42 @@
         </div>
         <div class="form-group">
           <div id="haggle_div" class="<%= 'hidden' unless @pos_config.enable_haggle %>">
-            <%= f.label :haggle_in_sale_percent, { class: "col-md-3 control-label" } do %>Porcentaje máximo de regateo para ventas
+            <%= f.label :haggle_in_sale_percent, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje máximo de regateo para ventas
               <span class="required">*</span>
             <% end %>
-            <div class="col-md-3">
+            <div class="col-md-3 col-sm-2">
               <%= f.number_field :haggle_in_sale_percent, { class: "form-control input-xsmall" } %>
             </div>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :time_zone, { class: "col-md-3 control-label" } do %>Zona horaria
+          <%= f.label :time_zone, { class: "col-md-3 col-sm-3 control-label" } do %>Zona horaria
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones, {}, {:class => 'form-control select2 input-large' } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :ticket_description, { class: "col-md-3 control-label" } do %>Encabezado para tickets
+          <%= f.label :ticket_description, { class: "col-md-3 col-sm-3 control-label" } do %>Encabezado para tickets
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-7">
+          <div class="col-md-7 col-sm-6">
             <%= f.text_area :ticket_description, { class: "form-control", rows: 5 } %>
             <span class="help-block">Si no se especifica un encabezado para cada uno de los puntos de venta, se usará este de manera general.</span>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :ticket_footer, { class: "col-md-3 control-label" } do %>Pie de página para tickets
+          <%= f.label :ticket_footer, { class: "col-md-3 col-sm-3 control-label" } do %>Pie de página para tickets
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-7">
+          <div class="col-md-7 col-sm-6">
             <%= f.text_area :ticket_footer, { class: "form-control", rows: 5 } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :ticket_img, "Imagen para el ticket", { class: "col-md-3 control-label"} %>
-          <div class="col-md-9">
+          <%= f.label :ticket_img, "Imagen para el ticket", { class: "col-md-3 col-sm-3 control-label"} %>
+          <div class="col-md-9 col-sm-3">
             <div class="fileinput fileinput-new" data-provides="fileinput">
               <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                 <% if @pos_config.ticket_img? %>

+ 2 - 2
app/views/products/_form.html.erb

@@ -288,9 +288,9 @@
     <% end %>
 
     presentaciones();
-    <% if @product.children.present? %>
+    // < % if @product.children.present? %>
       getVariants();
-    <% end %>
+    // < % end %>
     showPriceBaseInput(<%= @product.is_in_dollars? %>);
 
     $(document).on("cut copy paste",'form#new_product .presentaciones input[type=text]', function(e) {

+ 2 - 2
app/views/sales/_sale.html.erb

@@ -1,7 +1,7 @@
 <tr class=<%= (sale.cancelled? ? 'danger' : '') %>>
 	<td><%= sale.id %></td>
 	<td><%= sale.sale_code %> </td>
-	<% if current_user.usertype == 'A' %>
+	<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 		<td> <%= sale.get_pointsale.name %> </td>
 	<% end %>
 	<td><%= sale.customer.nick_name %> </td>
@@ -29,4 +29,4 @@
       <%= link_to sale, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar venta", data: { confirm: '¿Está seguro que desea cancelar la venta?' } do %> <i class="fa fa-ban"></i><% end %>
     <% end %>
   </td>
-</tr>
+</tr>

+ 3 - 13
app/views/sales/_sale_for_report.html.erb

@@ -9,24 +9,14 @@
     Crédito
     <% elsif sale.saletype == "credit" && sale.credit_note.present? %>
     Crédito/vale
-    <% elsif sale.saletype == "cash"%>
+    <% elsif sale.saletype == "cash" %>
     Contado
-    <% elsif sale.saletype == "reserved"%>
+    <% elsif sale.saletype == "reserved" %>
     Apartado
     <% end %>
   </td>
   <td>
-    <% case sale.status %>
-    <% when "paid"%>
-      <span class="label label-success"> PAGADA </span>
-    <% when "cancelled"%>
-      <span class="label label-danger"> CANCELADO </span>
-    <% when "parcial"%>
-      <span class="label label-warning"> ABONADA </span>
-
-    <% when "notpaid"%>
-      <span class="label label-default">PAGO PENDIENTE</span>
-    <% end %>
+    <%= sale_status(sale) %>
   </td>
   <td><%= number_to_currency(sale.amount, precision: 2) %></td>
   <td><%= number_to_currency(sale.tax, precision: 2) %></td>

+ 2 - 11
app/views/sales/_sale_for_return.html.erb

@@ -1,6 +1,6 @@
 <tr id="sale_<%=sale.id%>">
   <td><%= sale.id %></td>
-  <td><%= sale.sale_code %> </td>     
+  <td><%= sale.sale_code %> </td>
   <td><%= sale.customer.nick_name %> </td>
   <td><%= sale.seller.name %> </td>
   <td><%= l(sale.date_sale, :format => '%d/%m/%Y') %></td>
@@ -17,16 +17,7 @@
   </td>
   <td><%= sale.products.count %></td>
   <td>
-    <% case sale.status %>
-    <% when "paid"%>
-      <span class="label label-success"> PAGADA </span>
-    <% when "cancelled"%>
-      <span class="label label-danger"> CANCELADO </span>
-    <% when "parcial"%>                     
-      <span class="label label-warning"> ABONADA </span> 
-    <% when "notpaid"%>                     
-      <span class="label label-default"> PENDIENTE PAGO </span>                             
-    <% end %>
+    <%= sale_status(sale) %>
   </td>
   <td><%= number_to_currency(sale.total, precision: 2) %></td>
 </tr>

+ 6 - 8
app/views/sales/sales_per_month_report.html.erb

@@ -32,14 +32,14 @@
                       <div class="col-md-3">
                         <div class="search-label uppercase">Punto de venta</div>
                         <div class="col-md-12">
-                          <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name), :include_blank => "Todas",  class: "form-control  input-medium" %>
+                          <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name), :include_blank => "Todos", class: "form-control  input-medium" %>
                         </div>
                       </div>
                       <div class="col-md-3">
                         <div class="search-label uppercase"> Del </div>
                         <div class="col-md-6">
                           <div class="input-group input-medium date date-picker" data-date-format="dd/mm/yyyy">
-                            <input id="start" type='text' class="form-control"/>
+                            <input id="start" type='text' class="form-control" value="<%= l(Date.today.beginning_of_month, format: '%d/%m/%Y') %>" />
                             <span class="input-group-addon">
                               <span class="glyphicon glyphicon-calendar"></span>
                             </span>
@@ -50,7 +50,7 @@
                         <div class="search-label uppercase"> Al </div>
                         <div class="col-md-6">
                           <div class="input-group input-medium date date-picker" data-date-format="dd/mm/yyyy">
-                            <input id="end" type='text' class="form-control"/>
+                            <input id="end" type='text' class="form-control" value="<%= l(Date.today.end_of_month, format: '%d/%m/%Y') %>" />
                             <span class="input-group-addon">
                               <span class="glyphicon glyphicon-calendar"></span>
                             </span>
@@ -58,7 +58,7 @@
                         </div>
                       </div>
                       <div class="col-md-3" style="margin-top: 20px">
-                        <button class="btn green bold  btn-block" onclick="findSalesByPeriod()" style="margin:0px">Filtrar <i class="m-icon-swapright m-icon-white"></i> </button>
+                        <button class="btn green bold btn-block" onclick="findSalesByPeriod()" style="margin:0px">Filtrar <i class="m-icon-swapright m-icon-white"></i> </button>
                       </div>
                     </div>
                   </div>
@@ -82,10 +82,9 @@
                         <div class="note note-success hidden" id="note_info">
                           <h4 class="block">Detalle de ventas e ingresos del periodo: <strong><span id="start_date_display"></span></strong> al <strong><span id="end_date_display"></span></strong> en <strong><span id="pointsale_display"></span></strong></h4>
                         </div>
-
                         <div class="col-xs-offset-1 col-xs-5">
                           <div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
-                            <div class="font-grey-mint font-sm">NUMERO DE VENTAS</div>
+                            <div class="font-grey-mint font-sm">NÚMERO DE VENTAS</div>
                             <div class="uppercase font-hg font-blue-sharp" id="sales_quantity">0</div>
                           </div>
                         </div>
@@ -223,9 +222,8 @@
             $('#note_info').removeClass('hidden');
           }
         });
-      }else{
+      } else {
         toastr["error"]("Es necesario seleccionar fechas.");
       }
     }
-
   </script>

+ 60 - 71
app/views/sales/show.html.erb

@@ -19,17 +19,16 @@
 			<div class="container-fluid">
 				<div class="pull-right margin-bottom-10 ">
 					<% if @sale.reserved? %>
-						<%= link_to  sales_reserved_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
+						<%= link_to sales_reserved_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
 							<i class="fa fa-angle-left "></i>
 							Regresar
 						<% end %>
 					<% else %>
-						<%= link_to  sales_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
+						<%= link_to sales_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
 							<i class="fa fa-angle-left "></i>
 							Regresar
 						<% end %>
 					<% end %>
-
 				</div>
 				<!-- BEGIN PAGE BREADCRUMBS -->
 				<ul class="page-breadcrumb breadcrumb">
@@ -69,15 +68,15 @@
 									<div class="row static-info">
 										<div class="col-md-1 name"> <i class="fa fa-credit-card"></i> </div>
 										<div class="col-md-8 value">
-				                        <% if @sale.saletype == "credit" && @sale.credit_note.blank? %>
-				                          	<span class="label label-warning"> Venta a crédito </span>
-				                        <% elsif @sale.saletype == "credit" && @sale.credit_note.present? %>
-				                          	<span class="label label-warning"> Crédito/vale </span>
-										<% elsif @sale.saletype == "cash" %>
-											<span class="label label-success"> Venta a contado </span>
-										<% elsif @sale.saletype == "reserved" %>
-											<span class="label label-primary"> Apartado </span>
-										<% end %>
+                  	  <% if @sale.saletype == "credit" && @sale.credit_note.blank? %>
+                      	<span class="label label-warning"> Venta a crédito </span>
+                      <% elsif @sale.saletype == "credit" && @sale.credit_note.present? %>
+                      	<span class="label label-warning"> Crédito/vale </span>
+											<% elsif @sale.saletype == "cash" %>
+												<span class="label label-success"> Venta a contado </span>
+											<% elsif @sale.saletype == "reserved" %>
+												<span class="label label-primary"> Apartado </span>
+											<% end %>
 										</div>
 									</div>
 									<div class="row static-info">
@@ -87,16 +86,7 @@
 									<div class="row static-info">
 										<div class="col-md-1 name"> <i class="fa fa-info-circle"></i> </div>
 										<div class="col-md-8 value">
-											<% case @sale.status %>
-					                          <% when "paid"%>
-					                            <span class="label label-success"> <i class="fa fa-check"></i> Pagada </span>
-					                          <% when "canceled"%>
-					                             <span class="label label-danger"> <i class="fa fa-close"></i> Cancelada </span>
-					                          <% when "parcial"%>
-					                            <span class="label label-warning"> <i class="fa fa-clock-o"></i> Abonada </span>
-					                          <% when "notpaid"%>
-					                            <span class="label label-default"> <i class="fa fa-clock-o"></i> Pendiente de pago </span>
-					                      	<% end %>
+											<%= sale_status(@sale) %>
 										</div>
 									</div>
 									<% if @sale.credit_note.present? %>
@@ -118,18 +108,17 @@
 								</div>
 								<div class="portlet-body">
 									<table class="table table-striped table-hover">
-
 										<thead>
 											<tr>
 												<th>#</th>
-									            <th>SKU</th>
-									            <th>Imagen</th>
-									            <th>Producto</th>
-									            <th>Cantidad</th>
-									            <th>Precio</th>
-									            <th>IVA</th>
-									            <th>Descuento</th>
-									            <th>Importe</th>
+						            <th>SKU</th>
+						            <th>Imagen</th>
+						            <th>Producto</th>
+						            <th>Cantidad</th>
+						            <th>Precio</th>
+						            <th>IVA</th>
+						            <th>Descuento</th>
+						            <th>Importe</th>
 											</tr>
 										</thead>
 										<tbody>
@@ -167,49 +156,49 @@
 									<div class="portlet-body">
 										<div class="row">
 											<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"> Monto devuelto
-												        <span class="pull-right label label-warning">
-												        	<%= number_to_currency(@products_return.returned_amount, precision: 2) %>
-											        	</span>
-											        </li>
-											      </ul>
-											    </div>
+										    <div class="hidden-print" style="padding-left: 0px">
+										      <ul class="list-group">
+										        <li class="list-group-item list-group-item-default"> Monto devuelto
+											        <span class="pull-right label label-warning">
+											        	<%= number_to_currency(@products_return.returned_amount, precision: 2) %>
+										        	</span>
+										        </li>
+										      </ul>
+										    </div>
 											</div>
 											<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"> Nuevo monto
-											        	<span class="pull-right label label-warning">
-											        		<%= number_to_currency(@products_return.new_amount, precision: 2) %>
-											        	</span>
-											        </li>
-											      </ul>
-											    </div>
+										    <div class="hidden-print" style="padding-left: 0px">
+										      <ul class="list-group">
+										        <li class="list-group-item list-group-item-default"> Nuevo monto
+										        	<span class="pull-right label label-warning">
+										        		<%= number_to_currency(@products_return.new_amount, precision: 2) %>
+										        	</span>
+										        </li>
+										      </ul>
+										    </div>
 											</div>
 											<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"> Diferencia
-											        	<span class="pull-right label label-warning">
-											        		<%= number_to_currency(@products_return.difference_amount, precision: 2) %>
-											        	</span>
-											        </li>
-											      </ul>
-											    </div>
+										    <div class="hidden-print" style="padding-left: 0px">
+										      <ul class="list-group">
+										        <li class="list-group-item list-group-item-default"> Diferencia
+										        	<span class="pull-right label label-warning">
+										        		<%= number_to_currency(@products_return.difference_amount, precision: 2) %>
+										        	</span>
+										        </li>
+										      </ul>
+										    </div>
 											</div>
 										</div>
 										<h3>Productos devueltos</h3>
 										<table class="table table-striped table-hover">
 											<thead>
 												<tr>
-										            <th>Cantidad</th>
-										            <th>Imagen</th>
-										            <th>Producto</th>
-										            <th>Monto</th>
-										            <th>Razón</th>
-										            <th>Destino</th>
+							            <th>Cantidad</th>
+							            <th>Imagen</th>
+							            <th>Producto</th>
+							            <th>Monto</th>
+							            <th>Razón</th>
+							            <th>Destino</th>
 												</tr>
 											</thead>
 											<tbody>
@@ -237,10 +226,10 @@
 										<table class="table table-striped table-hover">
 											<thead>
 												<tr>
-										            <th>Cantidad</th>
-										            <th>Imagen</th>
-										            <th>Producto</th>
-										            <th>Monto</th>
+							            <th>Cantidad</th>
+							            <th>Imagen</th>
+							            <th>Producto</th>
+							            <th>Monto</th>
 												</tr>
 											</thead>
 											<tbody>
@@ -278,9 +267,9 @@
 											<tr>
 												<th>#</th>
 												<th>Fecha</th>
-									            <th>Metodo de pago</th>
-									            <th>Monto</th>
-									            <th>Info. Adicional</th>
+						            <th>Metodo de pago</th>
+						            <th>Monto</th>
+						            <th>Info. Adicional</th>
 											</tr>
 										</thead>
 										<tbody>

+ 87 - 97
app/views/special_prices/_form.html.erb

@@ -1,92 +1,84 @@
-<%= form_for(@special_price, :remote => true, :html => {:class=>"form-horizontal"}) do |f| %>
-<div class="portlet-body form">
-   <div id="error_explanation"></div>
-  <div class="form-body">
-    <div class="row">
-      <div class="col-md-12">
-        <!-- cliente -->
-
-        <div class="note note-success">
-          <h4 class="block">Instrucciones:</h4>
-          <p> Al seleccionar un cliente se mostrará en la tabla los productos que tiene asignados con precio especial.</br>
-          Tras buscar y seleccionar un producto, se agrega automaticamente al cliente y se debe asignar ya sea el precio o el porcentaje de descuento que tendra al momento de la venta.</p>
-        </div>
-        <div class="form-group">
-            <%= f.label :customer_id, "Cliente", {:class=>"col-md-2 control-label"} do %> Cliente
-            <span class="required">*</span>
-            <% end %>
+<%= form_for(@special_price, remote: true, html: { class: "form-horizontal" }) do |f| %>
+  <div class="portlet-body form">
+    <div id="error_explanation"></div>
+    <div class="form-body">
+      <div class="row">
+        <div class="col-md-12">
+          <!-- cliente -->
+          <div class="note note-success">
+            <h4 class="block">Instrucciones:</h4>
+            <p> Al seleccionar un cliente se mostrará en la tabla los productos que tiene asignados con precio especial.</br>
+            Tras buscar y seleccionar un producto, se agrega automaticamente al cliente y se debe asignar ya sea el precio o el porcentaje de descuento que tendra al momento de la venta.</p>
+          </div>
+          <div class="form-group">
+            <%= f.label :customer_id, "Cliente", { class: "col-md-2 control-label" } do %> Cliente <span class="required">*</span> <% end %>
             <div class="input-group col-md-5 select2-bootstrap-prepend">
-              <%= f.collection_select :customer_id, Customer.vigentes, :id, :nick_name, {:prompt => "Seleccione"}, {:class => "form-control select2", :disabled => @disabled_select} %>
-              <%= f.hidden_field :customer_id, {:id => 'customer'} %>
-              <%= f.hidden_field :product_id, {:id => 'product'} %>
+              <%= f.collection_select :customer_id, Customer.vigentes, :id, :nick_name, { prompt: "Seleccione" }, { class: "form-control select2", disabled: @disabled_select} %>
+              <%= f.hidden_field :customer_id, { id: 'customer' } %>
+              <%= f.hidden_field :product_id, { id: 'product' } %>
             </div>
           </div>
         </div>
-        <!-- agregar productos -->
-        <h4 class="form-section"> Agregar producto</h4>
-
-        <div class="row">
-
-          <div class='col-md-12'>
-
-            <div class="form-group">
-              <%= label_tag 'destiny', {:class=>"col-md-2 control-label"} do %> ¿El producto tiene variantes?
-              <span class="required">*</span>
-              <% end %>
-              <div class="col-md-3" style="padding-left:0px;padding-right:0px">
-                <%= check_box_tag('product_has_variants', 'no', false,
-                  {
-                    class: "make-switch",
-                    disabled: false,
-                    data: {
-                      on_color: "success",
-                      off_color: "warning",
-                      on_text: "SI",
-                      off_text: "NO"
-                    }
-                  }) %>
+          <!-- agregar productos -->
+          <h4 class="form-section"> Agregar producto</h4>
+          <div class="row">
+            <div class='col-md-12'>
+              <div class="form-group">
+                <%= label_tag 'destiny', { class: "col-md-2 control-label" } do %> ¿El producto tiene variantes? <span class="required">*</span> <% end %>
+                <div class="col-md-3" style="padding-left:0px;padding-right:0px">
+                  <%= check_box_tag('product_has_variants', 'no', false,
+                    {
+                      class: "make-switch",
+                      disabled: false,
+                      data: {
+                        on_color: "success",
+                        off_color: "warning",
+                        on_text: "SI",
+                        off_text: "NO"
+                      }
+                    }) %>
+                </div>
               </div>
-            </div>
-
-            <div class="form-group">
-              <label class="col-md-2 control-label" for="typeahead"> Producto
-                <span class="required">*</span>
-              </label>
-              <div class="col-md-4" style="padding-left:0px">
-                <input class="form-control" type="text" id="typeahead" data-option-url="/URL/%QUERY">
+              <div class="form-group">
+                <label class="col-md-2 control-label" for="typeahead"> Producto
+                  <span class="required">*</span>
+                </label>
+                <div class="col-md-4" style="padding-left:0px">
+                  <input class="form-control" type="text" id="typeahead" data-option-url="/URL/%QUERY">
+                </div>
+                <button id="products_new" disabled class="btn btn-success" type="button" onclick="addRow()"> Agregar <i class="fa fa-plus"></i> </button>
+              </div>
+              <div class="alert alert-info col-md-offset-2 col-md-8">
+                <strong>Aviso:</strong> Para agregar un producto a la lista puede escanear su código de barras o buscar por nombre o SKU.
               </div>
-              <button id="products_new" disabled class="btn btn-success" type="button" onclick="addRow()"> Agregar <i class="fa fa-plus"></i> </button>
-            </div>
-            <div class="alert alert-info col-md-offset-2 col-md-8">
-              <strong>Aviso:</strong> Para agregar un producto a la lista puede scannear su código de barras ó buscar por nombre o SKU.
             </div>
           </div>
-        </div>
-        <!-- lista de productos -->
-        <h4 class="form-section"> Lista de productos</h4>
-        <div class="portlet-body">
-          <table class="table table-striped table-bordered table-hover tableadvanced" id="products_table">
-            <thead>
-              <tr>
-                <th>#</th>
-                <th>SKU</th>
-                <th>Producto</th>
-                <th>Imagen</th>
-                <th>Precio de venta</th>
-                <th>Descuento en cantidad</th>
-                <th>% de descuento</th>
-                <th width="15%">Acciones</th>
-              </tr>
-            </thead>
-            <tbody>
-            </tbody>
-          </table>
+          <!-- lista de productos -->
+          <h4 class="form-section"> Lista de productos</h4>
+          <div class="portlet-body">
+            <table class="table table-striped table-bordered table-hover tableadvanced" id="products_table">
+              <thead>
+                <tr>
+                  <th>#</th>
+                  <th>SKU</th>
+                  <th>Producto</th>
+                  <th>Imagen</th>
+                  <th>Precio de venta</th>
+                  <th>Descuento en cantidad</th>
+                  <th>% de descuento</th>
+                  <th width="15%">Acciones</th>
+                </tr>
+              </thead>
+              <tbody>
+              </tbody>
+            </table>
+          </div>
         </div>
       </div>
     </div>
   </div>
-</div>
 <% end %>
+
 <script type="text/javascript">
 
   var selectedProduct;
@@ -94,7 +86,6 @@
 
   $(document).on("page:change", function() {
     App.init();
-
   });
 
   $('body').barcodeListener().on('barcode.valid', function(e, code) {
@@ -104,11 +95,11 @@
   $('#special_price_customer_id').on('change', function() {
     $('#customer').val($(this).val());
     $.ajax({
-        type: "GET",
-        url: "/get_special_price_by_customer/" + $(this).val(),
-        dataType: "script",
-        success: function(xhr, status, error) {
-        }
+      type: "GET",
+      url: "/get_special_price_by_customer/" + $(this).val(),
+      dataType: "script",
+      success: function(xhr, status, error) {
+      }
     });
   });
 
@@ -198,13 +189,13 @@
           toastr["error"]("El descuento no puede ser mayor al precio de venta del producto.");
         } else {
           $.ajax({
-              type: "PUT",
-              url: "/special_prices/" + specialPriceId,
-              dataType: "json",
-              data: {special_price: {price: newPrice}},
-              success: function(xhr, status, error) {
-                toastr["success"]("Precio especial actualizado.");
-              }
+            type: "PUT",
+            url: "/special_prices/" + specialPriceId,
+            dataType: "json",
+            data: {special_price: {price: newPrice}},
+            success: function(xhr, status, error) {
+              toastr["success"]("Precio especial actualizado.");
+            }
           });
         }
       }, 300);
@@ -215,7 +206,6 @@
     if(input.val()) {
       clearTimeout(timeout);
       timeout = setTimeout(function () {
-
         var idText = input.closest('tr').attr('id');
         var specialPriceId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
         input.closest('tr').find('td:eq(5) input').val("");
@@ -224,13 +214,13 @@
           toastr["error"]("El porcentaje de descuento no puede ser mayor a 100%");
         } else {
           $.ajax({
-              type: "PUT",
-              url: "/special_prices/" + specialPriceId,
-              dataType: "json",
-              data: {special_price: {percent: input.val()}},
-              success: function(xhr, status, error) {
-                toastr["success"]("Precio especial actualizado.");
-              }
+            type: "PUT",
+            url: "/special_prices/" + specialPriceId,
+            dataType: "json",
+            data: {special_price: {percent: input.val()}},
+            success: function(xhr, status, error) {
+              toastr["success"]("Precio especial actualizado.");
+            }
           });
         }
       }, 300);