Class: UOB::Payroll::TXTFile::Footer
- Inherits:
-
Object
- Object
- UOB::Payroll::TXTFile::Footer
- Includes:
- ActiveModel::Model, TxtData::TxtDataRowDSL
- Defined in:
- lib/uob/payroll/txt_file/footer.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#number_of_records ⇒ Object
readonly
Returns the value of attribute number_of_records.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#total_amount ⇒ Object
readonly
Returns the value of attribute total_amount.
Instance Method Summary collapse
- #formatted_number_of_records ⇒ Object
- #formatted_total_amount ⇒ Object
- #hash_total ⇒ Object
-
#initialize(total_amount:, header:, rows:) ⇒ Footer
constructor
A new instance of Footer.
Methods included from TxtData::TxtDataRowDSL
Constructor Details
#initialize(total_amount:, header:, rows:) ⇒ Footer
Returns a new instance of Footer.
22 23 24 25 26 27 28 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 22 def initialize(total_amount:, header:, rows:) @total_amount = total_amount @number_of_records = rows.count @header = header @rows = rows raise Errors::Invalid, errors..to_sentence unless valid? end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
17 18 19 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 17 def header @header end |
#number_of_records ⇒ Object (readonly)
Returns the value of attribute number_of_records.
17 18 19 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 17 def number_of_records @number_of_records end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
17 18 19 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 17 def rows @rows end |
#total_amount ⇒ Object (readonly)
Returns the value of attribute total_amount.
17 18 19 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 17 def total_amount @total_amount end |
Instance Method Details
#formatted_number_of_records ⇒ Object
34 35 36 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 34 def formatted_number_of_records format '%06d', number_of_records end |
#formatted_total_amount ⇒ Object
38 39 40 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 38 def formatted_total_amount (format '%015.2f', total_amount).gsub('.','') end |
#hash_total ⇒ Object
30 31 32 |
# File 'lib/uob/payroll/txt_file/footer.rb', line 30 def hash_total HashCalculator.calculate(header: header, rows: rows) end |