mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
24 lines
429 B
Ruby
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
|