internetee-registry/app/models/concerns/invoice/payable.rb
2021-04-12 17:22:35 +05:00

24 lines
429 B
Ruby

module Invoice::Payable
extend ActiveSupport::Concern
included do
scope :unpaid, -> { where('id NOT IN (SELECT invoice_id FROM account_activities WHERE' \
' invoice_id IS NOT NULL)') }
end
def payable?
unpaid? && not_cancelled?
end
def paid?
account_activity.present?
end
def receipt_date
account_activity.created_at.to_date
end
def unpaid?
!paid?
end
end