Class: ModernTreasury::Reason

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

Overview

The reason for the reversal.

Constant Summary collapse

REASON =
[
  # 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



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

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



26
27
28
29
30
# File 'lib/modern_treasury/models/reason.rb', line 26

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

  REASON.include?(value)
end