Class: CreditInvoice

Inherits:
Invoice
  • Object
show all
Defined in:
app/models/credit_invoice.rb

Constant Summary

Constants inherited from Invoice

Invoice::STATES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Invoice

#active, #amount, #build_booking, #open, #overdue?, #state_adverb, #state_noun, #update_code

Methods included from ApplicationHelper

#currency_fmt, #current_tenant, #engine_stylesheet_link_tag, #icon_delete_link_to, #icon_edit_link_to, #list_item_actions_for, #show_new_form

Class Method Details

.direct_accountObject

Accounts



21
22
23
# File 'app/models/credit_invoice.rb', line 21

def self.
  Account.find_by_code("2000")
end

Instance Method Details

#balance_accountObject



25
26
27
# File 'app/models/credit_invoice.rb', line 25

def 
  bookings.first.try(:debit_account)
end

#profit_accountObject



29
30
31
# File 'app/models/credit_invoice.rb', line 29

def 
  bookings.first.try(:credit_account)
end

#to_s(format = :default) ⇒ Object

String



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/credit_invoice.rb', line 3

def to_s(format = :default)
  return "" if amount.nil?

  identifier = title
  identifier += " / #{code}" if code.present?

  case format
    when :reference
      return identifier + " (#{company.to_s})"
    when :long
      return "%s: %s für %s à %s"  % [I18n::localize(value_date), ident, company, currency_fmt(amount)]
    else
      return identifier
  end
end