class CashRegister < ActiveRecord::Base
    ## Associaciones
    belongs_to :pointsale
    has_many :open_cash_registers
    has_many :cash_registers_moves, :through => :open_cash_registers
    has_many :cash_outs, :through => :open_cash_registers
    
	enum status: [ :erased, :active, :inactive ]
    enum main: [:no, :yes]
	##--- Validaciones previas de guardar
    validates :name , presence: { message: "Debe capturar el nombre de la caja registradora." }
    validates :pointsale_id , presence: { message: "Debe seleccionar un punto de venta." }

	##--- Tipo de vistas / consultas
	scope :vigentes, -> { where("status != 0").order(" status ASC, name ASC") }
	scope :activos, -> { where( "status = 1").order(" name ASC") }
    
end
