Class: LedgerAccount
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- LedgerAccount
- Includes:
- Models::Auditable, Models::Lineage
- Defined in:
- app/models/ledger_account.rb
Overview
== Schema Information
Table name: ledger_accounts
Database name: primary
id :integer not null, primary key
classification :string(255)
closed :boolean default(FALSE), not null
description :text
name :string(50) not null
number :integer not null
type :string(255) not null
visible :boolean default(TRUE), not null
created_at :datetime
updated_at :datetime
parent_id :integer
Indexes
idx_id_type (id,type)
idx_la_parent_id (parent_id)
index_ledger_accounts_on_number (number)
Direct Known Subclasses
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Has many collapse
- #budgets ⇒ ActiveRecord::Relation<Budget>
- #ledger_company_accounts ⇒ ActiveRecord::Relation<LedgerCompanyAccount>
- #ledger_entries ⇒ ActiveRecord::Relation<LedgerEntry>
Class Method Summary collapse
-
.available ⇒ ActiveRecord::Relation<LedgerAccount>
A relation of LedgerAccounts that are available.
- .company_account_array ⇒ Object
- .select_account ⇒ Object
- .select_bank_balance_account ⇒ Object
- .select_options ⇒ Object
- .types_for_select ⇒ Object
Instance Method Summary collapse
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater
Methods included from Models::Lineage
#ancestors, #ancestors_ids, #children_and_roots, #descendants, #descendants_ids, #ensure_non_recursive_lineage, #family_members, #generate_full_name, #generate_full_name_array, #lineage, #lineage_array, #lineage_simple, #root, #root_id, #self_ancestors_and_descendants, #self_ancestors_and_descendants_ids, #self_and_ancestors, #self_and_ancestors_ids, #self_and_children, #self_and_descendants, #self_and_descendants_ids, #self_and_siblings, #self_and_siblings_ids, #siblings, #siblings_ids
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.available ⇒ ActiveRecord::Relation<LedgerAccount>
A relation of LedgerAccounts that are available. Active Record Scope
37 |
# File 'app/models/ledger_account.rb', line 37 scope :available, -> { where(visible: true, closed: false) } |
.company_account_array ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/models/ledger_account.rb', line 63 def self.company_account_array accounts = [] LedgerAccount.all.each do |ledger_account| accounts[ledger_account.id] = {} accounts[ledger_account.id][Company::USA] = ledger_account.company_account_ids_for(Company::USA) accounts[ledger_account.id][Company::CAN] = ledger_account.company_account_ids_for(Company::CAN) accounts[ledger_account.id][Company::NLD] = ledger_account.company_account_ids_for(Company::NLD) accounts[ledger_account.id][[Company::USA, Company::CAN]] = accounts[ledger_account.id][Company::USA] + accounts[ledger_account.id][Company::CAN] end accounts end |
.select_account ⇒ Object
47 48 49 |
# File 'app/models/ledger_account.rb', line 47 def self.select_account LedgerAccount.all.order(:number).pluck(Arel.sql("concat(number, ' ', name)"), :number) end |
.select_bank_balance_account ⇒ Object
51 52 53 |
# File 'app/models/ledger_account.rb', line 51 def self.select_bank_balance_account LedgerAccount.where(number: [1122,1123,1130,1135,1140,1141]).order(:number).pluck(Arel.sql("concat(number, ' ', name)"), :number) end |
.select_options ⇒ Object
43 44 45 |
# File 'app/models/ledger_account.rb', line 43 def self. LedgerAccount.all.order(:number).pluck(Arel.sql("concat(number, ' ', name)"), :id) end |
.types_for_select ⇒ Object
39 40 41 |
# File 'app/models/ledger_account.rb', line 39 def self.types_for_select [["Detail", "LedgerDetailAccount"], ["Summary", "LedgerSummaryAccount"]] end |
Instance Method Details
#budgets ⇒ ActiveRecord::Relation<Budget>
35 |
# File 'app/models/ledger_account.rb', line 35 has_many :budgets |
#ledger_company_accounts ⇒ ActiveRecord::Relation<LedgerCompanyAccount>
33 |
# File 'app/models/ledger_account.rb', line 33 has_many :ledger_company_accounts |
#ledger_entries ⇒ ActiveRecord::Relation<LedgerEntry>
34 |
# File 'app/models/ledger_account.rb', line 34 has_many :ledger_entries, :through => :ledger_company_accounts |
#requires_business_unit? ⇒ Boolean
59 60 61 |
# File 'app/models/ledger_account.rb', line 59 def requires_business_unit? number >= 5000 end |
#summary_name ⇒ Object
55 56 57 |
# File 'app/models/ledger_account.rb', line 55 def summary_name "#{number} #{name}" end |