Class: PaisLegacy::TrialBalance

Inherits:
Object
  • Object
show all
Defined in:
lib/pais_legacy/trial_balance.rb

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ TrialBalance

Returns a new instance of TrialBalance.



8
9
10
# File 'lib/pais_legacy/trial_balance.rb', line 8

def initialize(report)
  @report = report
end

Instance Method Details

#accounts_from_trial_balanceObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pais_legacy/trial_balance.rb', line 24

def accounts_from_trial_balance
  read = false
  accounts = []
  @report.each do |row|
    next if row.strip.length == 0

    read = false if end_reading(row)
    if read && (row[0..9].to_i>0)
      accounts << code_from_row(row)
    end
    read = true if start_reading(row)
  end

  accounts
end

#displayObject



12
13
14
# File 'lib/pais_legacy/trial_balance.rb', line 12

def display
  puts @report
end

#main_account(row) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/pais_legacy/trial_balance.rb', line 40

def (row)
  @main_code = row[0..7].strip
  @main_name = (row)
  {
    code: "#{@main_code}",
    name: "#{"#{@main_code}-#{@main_name}".strip}",
    dr: dr(row),
    cr: cr(row)
  }
end

#save_sampleObject



16
17
18
19
20
21
22
# File 'lib/pais_legacy/trial_balance.rb', line 16

def save_sample
  File.open("tmp/trial_balance_screen.sample","w") do |f|
    @report.each do |line|
      f.write "#{line}\n"
    end
  end
end

#sub_account(row) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/pais_legacy/trial_balance.rb', line 51

def (row)
  code = "#{@main_code}/#{row[0..9].strip}"
  name = "#{code}-#{@main_name} #{(row)}"
  {
    code: "#{code}",
    name: "#{name.strip}",
    dr: dr(row),
    cr: cr(row)
  }
end