credit.rb 368 B

1234567891011121314
  1. class Credit < ActiveRecord::Base
  2. belongs_to :customer
  3. belongs_to :pointsale
  4. belongs_to :sale
  5. has_many :credit_payments
  6. has_many :cash_registers_moves, :through => :credit_payments
  7. enum status: [ :active, :cancelled, :expired ]
  8. scope :debtors, -> { where( "rest > 0").group(:customer_id).sum(:rest) }
  9. scope :activos, -> { where( "status != 1") }
  10. end