Class: CFONB::OperationDetails::MMO

Inherits:
Base
  • Object
show all
Defined in:
lib/cfonb/operation_details/mmo.rb

Constant Summary collapse

ATTRIBUTES =
%i[original_currency original_amount exchange_rate].freeze

Class Method Summary collapse

Methods inherited from Base

inherited

Class Method Details

.apply(details, line) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cfonb/operation_details/mmo.rb', line 10

def self.apply(details, line)
  details.original_currency = line.detail[0..2]
  scale = line.detail[3].to_i

  details.original_amount = BigDecimal(line.detail[4..17]) / (10**scale)
  exchange_rate_value = line.detail[26..29]

  return if exchange_rate_value.nil? || exchange_rate_value.strip.empty?

  exchange_rate_scale = line.detail[18]
  details.exchange_rate = BigDecimal(exchange_rate_value) / (10**BigDecimal(exchange_rate_scale))
end