Class: CanadaPayment::EFT::CPA005::Debit::Segment

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/canada_payment/eft/cpa005/debit/segment.rb

Constant Summary collapse

DEFAULT_TRANSACTION_CODE =
450

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helper

#char_padded, #ensure_length, #padded_date, #space_padded, #zero_padded

Constructor Details

#initialize(transaction_code: nil, amount_cents:, payment_date:, institution:, transit:, account_number:, client_short_name:, client_long_name:, client_sundry_info: nil, client_number:, operating_subsidiary: nil, customer_name:, customer_number:) ⇒ Segment

Returns a new instance of Segment.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 20

def initialize(transaction_code: nil,
               amount_cents:,
               payment_date:,
               institution:,
               transit:,
               account_number:,
               client_short_name:,
               client_long_name:,
               client_sundry_info: nil,
               client_number:,
               operating_subsidiary: nil,
               customer_name:,
               customer_number:)
  @transaction_code     = transaction_code || DEFAULT_TRANSACTION_CODE
  @amount_cents         = amount_cents
  @payment_date         = payment_date
  @institution          = institution
  @transit              = transit
  @account_number       = 
  @client_short_name    = client_short_name
  @client_long_name     = client_long_name
  @client_sundry_info   = client_sundry_info
  @client_number        = client_number
  @operating_subsidiary = operating_subsidiary
  @customer_name        = customer_name
  @customer_number      = customer_number
end

Instance Attribute Details

#account_numberObject

Returns the value of attribute account_number.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def 
  @account_number
end

#amount_centsObject

Returns the value of attribute amount_cents.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def amount_cents
  @amount_cents
end

#client_long_nameObject

Returns the value of attribute client_long_name.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def client_long_name
  @client_long_name
end

#client_numberObject

Returns the value of attribute client_number.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def client_number
  @client_number
end

#client_short_nameObject

Returns the value of attribute client_short_name.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def client_short_name
  @client_short_name
end

#client_sundry_infoObject

Returns the value of attribute client_sundry_info.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def client_sundry_info
  @client_sundry_info
end

#customer_nameObject

Returns the value of attribute customer_name.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def customer_name
  @customer_name
end

#customer_numberObject

Returns the value of attribute customer_number.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def customer_number
  @customer_number
end

#institutionObject

Returns the value of attribute institution.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def institution
  @institution
end

#operating_subsidiaryObject

Returns the value of attribute operating_subsidiary.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def operating_subsidiary
  @operating_subsidiary
end

#payment_dateObject

Returns the value of attribute payment_date.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def payment_date
  @payment_date
end

#transaction_codeObject

Returns the value of attribute transaction_code.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def transaction_code
  @transaction_code
end

#transitObject

Returns the value of attribute transit.



6
7
8
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 6

def transit
  @transit
end

Class Method Details

.blank_valuesObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 71

def self.blank_values
  ' ' * 3 +
  '0' * 10 +
  '0' * 6 +
  '0' * 9 +
  ' ' * 12 +
  '0' * 22 +
  '0' * 3 +
  ' ' * 15 +
  ' ' * 30 +
  ' ' * 30 +
  ' ' * 10 +
  ' ' * 19 +
  '0' * 9 +
  ' ' * 12 +
  ' ' * 15 +
  ' ' * 22 +
  ' ' * 2 +
  ' ' * 11
end

Instance Method Details

#to_sObject Also known as: output



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/canada_payment/eft/cpa005/debit/segment.rb', line 48

def to_s
  formatted_transaction_code +
  formatted_amount +
  padded_date(@payment_date, 6) +
  zero_padded(@institution, 4) +
  zero_padded(@transit, 5) +
  space_padded(@account_number, 12) +
  "0" * 22 +
  "0" * 3 +
  space_padded(@client_short_name, 15) +
  space_padded(@customer_name, 30) +
  space_padded(@client_long_name, 30) +
  client_number_with_subsidiary +
  space_padded(@customer_number, 19) +
  "0" * 9 +
  " " * 12 +
  space_padded(@client_sundry_info, 15) +
  " " * 22 +
  " " * 2 +
  " " * 11
end