class OpenCashRegister < ActiveRecord::Base
	belongs_to :cash_register
	belongs_to :user
	has_many :cash_registers_moves
	has_many :sales
	has_many :sales_details, :through => :sales
	has_many :products, :through => :sales_details
	has_many :categories, :through => :products
	has_many :expenses
	has_many :pre_sales
	has_many :cash_outs
	has_one :pointsale, :through => :cash_register

  	##--- Llevar registro de Actividad del usuario
	audited

	enum status: [:open, :closed]

	scope :abiertas, -> { where( "open_cash_registers.status = 0") }

	def self.get_pointsale(id, option)
		if option == "open_cash_register"
			Pointsale.find(CashRegister.find(OpenCashRegister.find(id).cash_register_id).pointsale_id)
		end
	end
end
