Class: Appydave::Tools::Configuration::Models::BankReconciliationConfig
- Inherits:
-
ConfigBase
- Object
- ConfigBase
- Appydave::Tools::Configuration::Models::BankReconciliationConfig
- Defined in:
- lib/appydave/tools/configuration/models/bank_reconciliation_config.rb
Overview
Bank reconciliation configuration
Defined Under Namespace
Classes: BankAccount, ChartOfAccount, SignFlipRule
Instance Attribute Summary
Attributes inherited from ConfigBase
Instance Method Summary collapse
-
#bank_accounts ⇒ Object
def Retrieve all bank accounts.
- #chart_of_accounts ⇒ Object
- #coa_csv_to_json ⇒ Object
- #coa_to_csv ⇒ Object
- #get_bank_account(account_number, bsb = nil) ⇒ Object
-
#get_chart_of_account(code) ⇒ Object
Retrieve a chart of account entry by code.
- #print ⇒ Object
-
#sign_flip_rules ⇒ Object
Sign-flip rules — per-account, per-fin-year, per-COA exceptions where the raw bank-export sign is wrong and needs flipping during clean_amount.
Methods inherited from ConfigBase
#config_name, #debug, #initialize, #load, #name, #save
Constructor Details
This class inherits a constructor from Appydave::Tools::Configuration::Models::ConfigBase
Instance Method Details
#bank_accounts ⇒ Object
def Retrieve all bank accounts
11 12 13 14 15 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 11 def bank_accounts data['bank_accounts'].map do |account| BankAccount.new(account) end end |
#chart_of_accounts ⇒ Object
17 18 19 20 21 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 17 def chart_of_accounts data['chart_of_accounts'].map do |entry| ChartOfAccount.new(entry) end end |
#coa_csv_to_json ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 70 def coa_csv_to_json csv_file_path = File.join(Config.config_path, 'bank_reconciliation.chart_of_accounts.csv') coa_data = CSV.read(csv_file_path, headers: true).map(&:to_h) data['chart_of_accounts'] = coa_data save end |
#coa_to_csv ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 58 def coa_to_csv csv_file_path = File.join(Config.config_path, 'bank_reconciliation.chart_of_accounts.csv') CSV.open(csv_file_path, 'w') do |csv| csv << %w[code narration] chart_of_accounts.sort_by(&:code).each do |entry| csv << [entry.code, entry.narration] end end end |
#get_bank_account(account_number, bsb = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 32 def get_bank_account(account_number, bsb = nil) normalized_bsb = bsb.to_s.empty? ? nil : bsb account_data = data['bank_accounts'].find do |account| acct_bsb = account['bsb'].to_s.empty? ? nil : account['bsb'] account['account_number'] == account_number && (normalized_bsb.nil? || acct_bsb == normalized_bsb) end BankAccount.new(account_data) if account_data end |
#get_chart_of_account(code) ⇒ Object
Retrieve a chart of account entry by code
43 44 45 46 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 43 def get_chart_of_account(code) entry_data = data['chart_of_accounts'].find { |entry| entry['code'] == code } ChartOfAccount.new(entry_data) if entry_data end |
#print ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 48 def print log.subheading 'Bank Reconciliation - Accounts' tp bank_accounts, :account_number, :bsb, :name, :bank log.subheading 'Bank Reconciliation - Chart of Accounts' tp chart_of_accounts, :code, :narration end |
#sign_flip_rules ⇒ Object
Sign-flip rules — per-account, per-fin-year, per-COA exceptions where the raw bank-export sign is wrong and needs flipping during clean_amount. Personal account numbers belong here (in config), not in source.
26 27 28 29 30 |
# File 'lib/appydave/tools/configuration/models/bank_reconciliation_config.rb', line 26 def sign_flip_rules (data['sign_flip_rules'] || []).map do |rule| SignFlipRule.new(rule) end end |