Class: AchClient::ReturnCode

Inherits:
Object
  • Object
show all
Defined in:
lib/ach_client/objects/return_code.rb

Overview

Represents an Ach Return code. Consult NACHA documentation for a full list See config/return_codes.yml for our list.

Constant Summary collapse

CORRECTION_START_CHARACTER =

The first character in a correction code

'C'
INTERNAL_START_CHARACTER =

The first character in an internal return code

'X'
INTERNAL_CORRECTION_STRING =

Returns that are both internal and corrections start with this string

'XZ'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, description:, reason: nil, risk_and_enforcement_category: nil) ⇒ ReturnCode

Constructs a Ach return code

Parameters:

  • code (String)

    the 3 char code identifier (ie ‘R01’)

  • description (String)

    full explanation of the return

  • reason (String) (defaults to: nil)

    shorter explanation of the return



24
25
26
27
28
29
30
# File 'lib/ach_client/objects/return_code.rb', line 24

def initialize(code:, description:, reason: nil, risk_and_enforcement_category: nil)
  @code = code
  @description = description
  @reason = reason
  # See https://www.nacha.org/rules/ach-network-risk-and-enforcement-topics
  @risk_and_enforcement_category = risk_and_enforcement_category
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



15
16
17
# File 'lib/ach_client/objects/return_code.rb', line 15

def code
  @code
end

#descriptionObject

Returns the value of attribute description.



15
16
17
# File 'lib/ach_client/objects/return_code.rb', line 15

def description
  @description
end

#reasonObject

Returns the value of attribute reason.



15
16
17
# File 'lib/ach_client/objects/return_code.rb', line 15

def reason
  @reason
end

#risk_and_enforcement_categoryObject

Returns the value of attribute risk_and_enforcement_category.



15
16
17
# File 'lib/ach_client/objects/return_code.rb', line 15

def risk_and_enforcement_category
  @risk_and_enforcement_category
end

Instance Method Details

#administrative_return?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ach_client/objects/return_code.rb', line 44

def administrative_return?
  @risk_and_enforcement_category == "administrative"
end

#correction?Boolean

Returns Whether or not this return is a correction/notice of change.

Returns:

  • (Boolean)

    Whether or not this return is a correction/notice of change



33
34
35
# File 'lib/ach_client/objects/return_code.rb', line 33

def correction?
  @code.start_with?(CORRECTION_START_CHARACTER) || @code.start_with?(INTERNAL_CORRECTION_STRING)
end

#internal?Boolean

An “internal” return means that the ACH provider knew that the ACH

would fail and didn't bother to send it to their upstream provider

Returns:

  • (Boolean)

    Whether or not the return is internal



40
41
42
# File 'lib/ach_client/objects/return_code.rb', line 40

def internal?
  @code.start_with?(INTERNAL_START_CHARACTER)
end

#unauthorized_return?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/ach_client/objects/return_code.rb', line 48

def unauthorized_return?
  @risk_and_enforcement_category == "unauthorized"
end