foodsoft/app/models/financial_transaction_class.rb
Patrick Gansterer d90d188dbf Add SupplierCategory
This allows the categorization of suppliers. For a better reporting
it is necessary to split the expenses of the invoices.
E.g. we want to be able to generate independent sums of general cost
like the rent or electricity and the cost of the bought articles.
2020-07-30 17:46:07 +02:00

21 lines
545 B
Ruby

class FinancialTransactionClass < ApplicationRecord
has_many :financial_transaction_types, dependent: :destroy
has_many :supplier_category, dependent: :restrict_with_exception
validates :name, presence: true
validates_uniqueness_of :name
scope :sorted, -> { order(name: :asc) }
def self.has_multiple_classes
FinancialTransactionClass.count > 1
end
def display
if FinancialTransactionClass.has_multiple_classes
name
else
I18n.t('activerecord.attributes.financial_transaction.amount')
end
end
end