mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
24 lines
414 B
Ruby
24 lines
414 B
Ruby
module Invoice::Cancellable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
scope :non_cancelled, -> { where(cancelled_at: nil) }
|
|
end
|
|
|
|
def cancellable?
|
|
unpaid? && not_cancelled?
|
|
end
|
|
|
|
def cancel
|
|
raise 'Invoice cannot be cancelled' unless cancellable?
|
|
update!(cancelled_at: Time.zone.now)
|
|
end
|
|
|
|
def cancelled?
|
|
cancelled_at.present?
|
|
end
|
|
|
|
def not_cancelled?
|
|
!cancelled?
|
|
end
|
|
end
|