diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 16f42f4d0..298fae6e6 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 711ac4c1f..1f2d1c5c6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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'