Class: ChinaBank::PayrollTextFile::File
- Inherits:
-
Object
- Object
- ChinaBank::PayrollTextFile::File
- Defined in:
- lib/china_bank/payroll_text_file/file.rb
Overview
Describes the payroll text file’s content including the lines that builds it.
Instance Method Summary collapse
- #content ⇒ String
-
#credit_lines ⇒ Array<ChinaBank::PayrollTextFile::Line>
Array<ChinaBank::PayrollTextFile::Line>.
- #debit_line ⇒ ChinaBank::PayrollTextFile::Line
-
#initialize(account_number:, account_type: "00", bank_code: "888", transactions: []) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(account_number:, account_type: "00", bank_code: "888", transactions: []) ⇒ File
Returns a new instance of File.
11 12 13 14 15 16 |
# File 'lib/china_bank/payroll_text_file/file.rb', line 11 def initialize(account_number:, account_type: "00", bank_code: "888", transactions: []) @account_number = account_number @account_type = account_type @bank_code = bank_code @transactions = transactions end |
Instance Method Details
#content ⇒ String
19 20 21 |
# File 'lib/china_bank/payroll_text_file/file.rb', line 19 def content (credit_lines + [debit_line]).join(new_line) + new_line end |
#credit_lines ⇒ Array<ChinaBank::PayrollTextFile::Line>
Returns Array<ChinaBank::PayrollTextFile::Line>.
24 25 26 |
# File 'lib/china_bank/payroll_text_file/file.rb', line 24 def credit_lines transactions.map { |transaction| Line.new **transaction.merge(transaction_type: Line::TYPES[:credit]) } end |
#debit_line ⇒ ChinaBank::PayrollTextFile::Line
29 30 31 32 33 34 35 |
# File 'lib/china_bank/payroll_text_file/file.rb', line 29 def debit_line Line.new account_number: account_number, account_type: account_type, bank_code: bank_code, transaction_type: Line::TYPES[:debit], amount: total end |