Class: InvoiceBar::Account

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Searchable
Defined in:
app/models/invoice_bar/account.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.searchable_fieldsObject



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

def self.searchable_fields
  %w( name iban swift bank_account_number )
end

Instance Method Details

#balanceObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/invoice_bar/account.rb', line 39

def balance
  balance = amount

  receipts.expense.each do |receipt|
    balance -= receipt.amount
  end

  receipts.income.each do |receipt|
    balance += receipt.amount
  end

  balance
end

#currency_nameObject



31
32
33
# File 'app/models/invoice_bar/account.rb', line 31

def currency_name
  currency.name if currency
end

#currency_symbolObject



35
36
37
# File 'app/models/invoice_bar/account.rb', line 35

def currency_symbol
  currency.symbol if currency
end