credit.rb 377 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, :liquidated]
  8. scope :debtors, -> { where("rest > 0").group(:customer_id).sum(:rest) }
  9. scope :activos, -> { where(status: [0, 2]) }
  10. end