Class: AUB::Payroll::EPFFile

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

Defined Under Namespace

Classes: Footer, Header, Row

Instance Method Summary collapse

Constructor Details

#initialize(company_name:, date:, transactions:) ⇒ EPFFile

Returns a new instance of EPFFile.



14
15
16
17
18
# File 'lib/aub/payroll/epf_file.rb', line 14

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

Instance Method Details

#contentObject



20
21
22
23
24
25
26
# File 'lib/aub/payroll/epf_file.rb', line 20

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