Class: QuickETL::QifTran

Inherits:
QuickETLObject show all
Defined in:
lib/quick_etl_qif_transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from QuickETLKernel

#command_line_arg, #command_line_array_arg, #command_line_boolean_arg, #default_delimiter, #display_general_info, #display_usage_instructions, #get_array_property, #get_property, #home_dir, #line_value, #load_properties, #parse_qif_files, #project_author, #project_copyright, #project_date, #project_embedded_comment, #project_license, #project_name, #project_version_number, #project_year, #read_as_ascii_lines, #read_lines, #startup, #strip_lines, #tokenize, #usage_instructions, #write_file, #write_lines

Constructor Details

#initialize(anOwner, aName, aType, line_num, delim = '|') ⇒ QifTran

Returns a new instance of QifTran.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/quick_etl_qif_transaction.rb', line 20

def initialize(anOwner, aName, aType, line_num, delim='|')
  @acct_owner = "#{anOwner}"
  @acct_name  = "#{aName}"
  @acct_type  = "#{aType}"
  @line_num   = line_num
  @delim      = delim
  @valid      = false
  @cleared    = ' '
  @number     = ' '
  @memo       = ' '
  @raw_lines  = Array.new 
  @splits     = Array.new    
end

Instance Attribute Details

#acct_nameObject

Returns the value of attribute acct_name.



17
18
19
# File 'lib/quick_etl_qif_transaction.rb', line 17

def acct_name
  @acct_name
end

#acct_ownerObject

Returns the value of attribute acct_owner.



17
18
19
# File 'lib/quick_etl_qif_transaction.rb', line 17

def acct_owner
  @acct_owner
end

#acct_typeObject

Returns the value of attribute acct_type.



17
18
19
# File 'lib/quick_etl_qif_transaction.rb', line 17

def acct_type
  @acct_type
end

#amountObject

Returns the value of attribute amount.



17
18
19
# File 'lib/quick_etl_qif_transaction.rb', line 17

def amount
  @amount
end

#balanceObject

Returns the value of attribute balance.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def balance
  @balance
end

#categoryObject

Returns the value of attribute category.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def category
  @category
end

#clearedObject

Returns the value of attribute cleared.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def cleared
  @cleared
end

#dateObject

Returns the value of attribute date.



17
18
19
# File 'lib/quick_etl_qif_transaction.rb', line 17

def date
  @date
end

#memoObject

Returns the value of attribute memo.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def memo
  @memo
end

#numberObject

Returns the value of attribute number.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def number
  @number
end

#payeeObject

Returns the value of attribute payee.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def payee
  @payee
end

#raw_linesObject

Returns the value of attribute raw_lines.



17
18
19
# File 'lib/quick_etl_qif_transaction.rb', line 17

def raw_lines
  @raw_lines
end

#validObject

Returns the value of attribute valid.



18
19
20
# File 'lib/quick_etl_qif_transaction.rb', line 18

def valid
  @valid
end

Instance Method Details

#add_line(line) ⇒ Object



36
37
38
# File 'lib/quick_etl_qif_transaction.rb', line 36

def add_line(line)    
  @raw_lines.push(line) 
end

#parseObject

Field Indicator Explanations:

D Date 
T Amount 
C Cleared status 
N Num (check or reference number)  
P Payee 
M Memo 
A Address (up to five lines; the sixth line is an optional message)     NOT IMPLEMENTED IN QUICK-ETL
L Category (Category/Subcategory/Transfer/Class)  
S Category in split (Category/Transfer/Class)  
E Memo in split 
$ Dollar amount of split 
^ End of the entry


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/quick_etl_qif_transaction.rb', line 56

def parse
  @raw_lines.each { | line |
    if (line.match(/^D/))
      @date = QifDate.new(line_value(line))
    elsif (line.match(/^T/))
      s = line_value(line)
      @amount = Money.new(s)
    elsif (line.match(/^P/))
      @payee = line_value(line)
    elsif (line.match(/^C/))
      @cleared = line_value(line)
    elsif (line.match(/^N/))
      @number = line_value(line)
    elsif (line.match(/^M/))
      @memo = line_value(line)
    elsif (line.match(/^L/))
      @category = line_value(line)
    elsif (line.match(/^S/))
      @split_category = line_value(line)
    elsif (line.match(/^E/))
      @split_memo = line_value(line)
    elsif (line.match(/^$/))
      @split_amount = Money.new(line_value(line))
    end                     
  }
  if (@date && @amount && @payee)
    @valid = true
  end    
end

#to_sObject



86
87
88
# File 'lib/quick_etl_qif_transaction.rb', line 86

def to_s
  "#{@delim}#{@acct_owner}#{@delim}#{@acct_name}#{@delim}#{@acct_type}#{@delim}#{@date.ccyymmdd}#{@delim}#{@cleared}#{@delim}#{@number}#{@delim}#{@amount.to_s}#{@delim}#{@payee}#{@delim}#{@category}#{@delim}#{@memo}#{@delim}#{@line_num}"
end