Class: FinancialTransactionType

Inherits:
ApplicationRecord show all
Defined in:
app/models/financial_transaction_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject


16
17
18
# File 'app/models/financial_transaction_type.rb', line 16

def self.default
  first
end

.has_multiple_typesObject


20
21
22
# File 'app/models/financial_transaction_type.rb', line 20

def self.has_multiple_types
  self.count > 1
end

Instance Method Details

#restrict_deleting_last_financial_transaction_typeObject (protected)

check if this is the last financial transaction type and deny


27
28
29
# File 'app/models/financial_transaction_type.rb', line 27

def restrict_deleting_last_financial_transaction_type
  raise I18n.t('model.financial_transaction_type.no_delete_last') if FinancialTransactionType.count == 1
end