Class: UOB::Payroll::TXTFile

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Autoload
Includes:
ActiveModel::Model
Defined in:
lib/uob/payroll/txt_file.rb

Defined Under Namespace

Classes: Footer, Header, Row

Instance Method Summary collapse

Constructor Details

#initialize(company_name:, account_number:, branch_code:, date:, payable_date:, transactions:) ⇒ TXTFile

Returns a new instance of TXTFile.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/uob/payroll/txt_file.rb', line 14

def initialize(company_name:, account_number:, branch_code:, date:, payable_date:, transactions:)
  @header = Header.new(
    company_name: company_name,
    account_number: ,
    branch_code: branch_code,
    creation_date: date,
    value_date: payable_date
  )
  @rows = transactions.map { |transaction| Row.new transaction }
  @footer = Footer.new total_amount: rows.sum(&:amount), header: header, rows: rows
end

Instance Method Details

#contentObject



26
27
28
29
30
31
32
# File 'lib/uob/payroll/txt_file.rb', line 26

def content
  [
    header,
    rows,
    footer,
  ].join("\n")
end