lib/uob/payroll/txt_file/row.rb in uob-payroll-1.0.8 vs lib/uob/payroll/txt_file/row.rb in uob-payroll-1.1.0

- old
+ new

@@ -1,13 +1,13 @@ require 'active_model' -require 'ph_utility' +require 'txt_data/txt_data_row_dsl' module UOB module Payroll class TXTFile::Row include ActiveModel::Model - include PhUtility::TxtData::TxtDataRowDSL + include TxtData::TxtDataRowDSL number :record_type, 1..1, value: 2 text :receiving_bic_code, 2..12, just: :left text :receiving_account_number, 13..46, just: :left text :receiving_account_name, 47..186, just: :left @@ -28,16 +28,16 @@ # @param [BigDecimal] amount The amount to be received def initialize(bic_code:, account_number:, account_name:, amount:) @bic_code = bic_code @account_number = account_number @account_name = account_name - @amount = amount + @amount = amount.is_a?(String) ? BigDecimal(amount) : amount raise Errors::Invalid, errors.full_messages.to_sentence unless valid? end def formatted_amount - (format '%014.2f', amount).gsub('.','') + (format '%014.2f', amount.round(2)).gsub('.','') end def receiving_bic_code String(bic_code).upcase end