Class: ChinaBank::PayrollTextFile::Line
- Inherits:
-
Object
- Object
- ChinaBank::PayrollTextFile::Line
- Includes:
- ActiveModel::Model
- Defined in:
- lib/china_bank/payroll_text_file/line.rb
Overview
Describes each line on China Bank’s payroll text file.
Constant Summary collapse
- AMOUNT_RANGE =
BigDecimal("0").. BigDecimal("99999999999.99")
- TYPES =
{ credit: "C", debit: "D" }
Instance Attribute Summary collapse
-
#account_number ⇒ Object
Returns the value of attribute account_number.
-
#account_type ⇒ Object
Returns the value of attribute account_type.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#bank_code ⇒ Object
Returns the value of attribute bank_code.
-
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
Instance Method Summary collapse
-
#initialize(account_type: "00", account_number:, amount:, transaction_type:, bank_code: "888") ⇒ Line
constructor
A new instance of Line.
-
#to_s ⇒ String
@example: “*SA1850889513 00000053931.70 D102*”.
Constructor Details
#initialize(account_type: "00", account_number:, amount:, transaction_type:, bank_code: "888") ⇒ Line
Returns a new instance of Line.
33 34 35 36 37 38 39 40 41 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 33 def initialize(account_type: "00", account_number:, amount:, transaction_type:, bank_code: "888") @account_number = account_number @account_type = account_type @bank_code = bank_code @transaction_type = transaction_type @amount = BigDecimal(amount.to_s) raise ArgumentError, errors..to_sentence unless valid? end |
Instance Attribute Details
#account_number ⇒ Object
Returns the value of attribute account_number.
15 16 17 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 15 def account_number @account_number end |
#account_type ⇒ Object
Returns the value of attribute account_type.
15 16 17 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 15 def account_type @account_type end |
#amount ⇒ Object
Returns the value of attribute amount.
15 16 17 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 15 def amount @amount end |
#bank_code ⇒ Object
Returns the value of attribute bank_code.
15 16 17 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 15 def bank_code @bank_code end |
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
15 16 17 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 15 def transaction_type @transaction_type end |
Instance Method Details
#to_s ⇒ String
@example: “*SA1850889513 00000053931.70 D102*”
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/china_bank/payroll_text_file/line.rb', line 45 def to_s [ terminator_character, # "*" account_type, # "SA" formatted_account_number, # "1850889513 " spacer, # " " formatted_amount, # 00000053931.70 spacer, # " " transaction_type, # "D" bank_code, # "102" terminator_character # "*" ].join end |