Class: ModernTreasury::Reason1

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/models/reason1.rb

Overview

The reason for the reversal. Must be one of ‘duplicate`, `incorrect_amount`, `incorrect_receiving_account`, `date_earlier_than_intended`, `date_later_than_intended`.

Constant Summary collapse

REASON1 =
[
  # TODO: Write general description for DUPLICATE
  DUPLICATE = 'duplicate'.freeze,

  # TODO: Write general description for INCORRECT_AMOUNT
  INCORRECT_AMOUNT = 'incorrect_amount'.freeze,

  # TODO: Write general description for INCORRECT_RECEIVING_ACCOUNT
  INCORRECT_RECEIVING_ACCOUNT = 'incorrect_receiving_account'.freeze,

  # TODO: Write general description for DATE_EARLIER_THAN_INTENDED
  DATE_EARLIER_THAN_INTENDED = 'date_earlier_than_intended'.freeze,

  # TODO: Write general description for DATE_LATER_THAN_INTENDED
  DATE_LATER_THAN_INTENDED = 'date_later_than_intended'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = DUPLICATE) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/modern_treasury/models/reason1.rb', line 34

def self.from_value(value, default_value = DUPLICATE)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'duplicate' then DUPLICATE
  when 'incorrect_amount' then INCORRECT_AMOUNT
  when 'incorrect_receiving_account' then INCORRECT_RECEIVING_ACCOUNT
  when 'date_earlier_than_intended' then DATE_EARLIER_THAN_INTENDED
  when 'date_later_than_intended' then DATE_LATER_THAN_INTENDED
  else
    default_value
  end
end

.validate(value) ⇒ Object



28
29
30
31
32
# File 'lib/modern_treasury/models/reason1.rb', line 28

def self.validate(value)
  return false if value.nil?

  REASON1.include?(value)
end