Class: CFONB::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/cfonb/operation.rb

Constant Summary collapse

BASE_ATTRIBUTES =
%i[
  raw
  amount
  currency
  date
  exoneration_code
  interbank_code
  internal_code
  label
  number
  reference
  rejection_code
  unavailability_code
  value_date
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Operation

Returns a new instance of Operation.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cfonb/operation.rb', line 23

def initialize(line)
  self.raw = line.body
  self.internal_code = line.internal_operation_code
  self.interbank_code = line.interbank_operation_code
  self.rejection_code = line.rejection_code
  self.exoneration_code = line.exoneration_code
  self.unavailability_code = line.unavailability_code
  self.currency = line.currency
  self.amount = line.amount
  self.date = line.date
  self.value_date = line.value_date
  self.label = line.label.strip
  self.number = line.number
  self.reference = line.reference
end

Instance Method Details

#merge_detail(line) ⇒ Object



39
40
41
42
# File 'lib/cfonb/operation.rb', line 39

def merge_detail(line)
  self.raw += "\n#{line.body}"
  OperationDetail.for(line)&.apply(self, line)
end

#type_codeObject



44
45
46
# File 'lib/cfonb/operation.rb', line 44

def type_code
  "#{interbank_code}#{direction}"
end