class BankPayments::SwedbankImport::AmountConverter

Used to convert Swedbanks numeric representation to a Ruby BigDecimal. It especially handles the convetion that that negative numbers have the last digits set as a char according to the DIGIT_MAP

@author Michael Litton

Constants

DIGIT_MAP

Public Class Methods

value_to_decimal(value) click to toggle source
# File lib/bank_payments/swedbank_import/amount_converter.rb, line 26
def self.value_to_decimal(value)
  modifier = 1

  if value[-1] =~ /\D/
    modifier = -1
    value = value[0..-2] + DIGIT_MAP[value[-1]]
  end

  BigDecimal("#{value[0..-3]}.#{value[-2..-1]}") * modifier
end