mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +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'))
|
errors.add(:base, I18n.t('cannot_cancel_paid_invoice'))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if cancelled?
|
||||||
|
errors.add(:base, I18n.t('cannot_cancel_cancelled_invoice'))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
self.cancelled_at = Time.zone.now
|
self.cancelled_at = Time.zone.now
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
|
@ -738,4 +738,5 @@ en:
|
||||||
cancelled: 'Cancelled'
|
cancelled: 'Cancelled'
|
||||||
cancel_date: 'Cancel date'
|
cancel_date: 'Cancel date'
|
||||||
cannot_cancel_paid_invoice: 'Cannot cancel paid invoice'
|
cannot_cancel_paid_invoice: 'Cannot cancel paid invoice'
|
||||||
|
cannot_cancel_cancelled_invoice: 'Cannot cancel cancelled invoice'
|
||||||
cannot_bind_cancelled_invoice: 'Cannot bind cancelled invoice'
|
cannot_bind_cancelled_invoice: 'Cannot bind cancelled invoice'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue