open_cash_register.rb 727 B

1234567891011121314151617181920212223242526
  1. class OpenCashRegister < ActiveRecord::Base
  2. belongs_to :cash_register
  3. belongs_to :user
  4. has_many :cash_registers_moves
  5. has_many :sales
  6. has_many :sales_details, :through => :sales
  7. has_many :products, :through => :sales_details
  8. has_many :categories, :through => :products
  9. has_many :expenses
  10. has_many :pre_sales
  11. has_many :cash_outs
  12. has_one :pointsale, :through => :cash_register
  13. ##--- Llevar registro de Actividad del usuario
  14. audited
  15. enum status: [:open, :closed]
  16. scope :abiertas, -> { where( "open_cash_registers.status = 0") }
  17. def self.get_pointsale(id, option)
  18. if option == "open_cash_register"
  19. Pointsale.find(CashRegister.find(OpenCashRegister.find(id).cash_register_id).pointsale_id)
  20. end
  21. end
  22. end