mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Check if invoice is already cancelled before cancelling
This commit is contained in:
parent
a26ce110b2
commit
41c2e2d5e4
2 changed files with 7 additions and 0 deletions
|
@ -72,6 +72,12 @@ class Invoice < ActiveRecord::Base
|
|||
errors.add(:base, I18n.t('cannot_cancel_paid_invoice'))
|
||||
return false
|
||||
end
|
||||
|
||||
if cancelled?
|
||||
errors.add(:base, I18n.t('cannot_cancel_cancelled_invoice'))
|
||||
return false
|
||||
end
|
||||
|
||||
self.cancelled_at = Time.zone.now
|
||||
save
|
||||
end
|
||||
|
|
|
@ -738,4 +738,5 @@ en:
|
|||
cancelled: 'Cancelled'
|
||||
cancel_date: 'Cancel date'
|
||||
cannot_cancel_paid_invoice: 'Cannot cancel paid invoice'
|
||||
cannot_cancel_cancelled_invoice: 'Cannot cancel cancelled invoice'
|
||||
cannot_bind_cancelled_invoice: 'Cannot bind cancelled invoice'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue