Class: Headache::Record::Entry

Inherits:
Base
  • Object
show all
Includes:
Definition::Entry
Defined in:
lib/headache/record/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

fields, #normalize_field_value, normalize_field_value, #parse, parse_fields, #parse_fields, parse_fields_normalize

Constructor Details

#initialize(batch = nil, document = nil) ⇒ Entry

Returns a new instance of Entry.



55
56
57
58
# File 'lib/headache/record/entry.rb', line 55

def initialize(batch = nil, document = nil)
  @batch    = batch
  @document = document
end

Instance Attribute Details

#account_numberObject

Returns the value of attribute account_number.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def 
  @account_number
end

#amountObject

Returns the value of attribute amount.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def amount
  @amount
end

#batchObject

Returns the value of attribute batch.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def batch
  @batch
end

#check_digitObject

Returns the value of attribute check_digit.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def check_digit
  @check_digit
end

#discretionaryObject

Returns the value of attribute discretionary.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def discretionary
  @discretionary
end

#documentObject

Returns the value of attribute document.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def document
  @document
end

#individual_nameObject

Returns the value of attribute individual_name.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def individual_name
  @individual_name
end

#internal_idObject

Returns the value of attribute internal_id.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def internal_id
  @internal_id
end

#routing_identificationObject

Returns the value of attribute routing_identification.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def routing_identification
  @routing_identification
end

#routing_numberObject

Returns the value of attribute routing_number.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def routing_number
  @routing_number
end

#trace_numberObject

Returns the value of attribute trace_number.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def trace_number
  @trace_number
end

#transaction_codeObject

Returns the value of attribute transaction_code.



6
7
8
# File 'lib/headache/record/entry.rb', line 6

def transaction_code
  @transaction_code
end

Instance Method Details

#assemble_routing_numberObject



28
29
30
31
32
# File 'lib/headache/record/entry.rb', line 28

def assemble_routing_number
  if @routing_identification.present? && @check_digit.present?
    @routing_number = "#{@routing_identification}#{@check_digit}"
  end
end

#generate(*args) ⇒ Object



17
18
19
20
# File 'lib/headache/record/entry.rb', line 17

def generate(*args)
  fail ArgumentError, 'transaction_code cannot be blank' unless transaction_code.present?
  super(*args)
end

#to_hObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/headache/record/entry.rb', line 34

def to_h
  new_hsh = {}
  super.each_pair do |key, value|
    next if key == :check_digit
    if key == :routing_identification
      key   = :routing_number
      value = @routing_number
    end
    new_hsh[key] = value
  end
  new_hsh
end