Class: Exception29

Inherits:
BaseException show all
Defined in:
lib/uk_account_validator/exceptions/exception_2_9.rb

Overview

Only occurs for some standard modulus 11 checks, when there is a 2 in the exception column for the first check for a sorting code and a 9 in the exception column for the second check for the same sorting code. This is used specifically for Lloyds euro accounts.

Perform the standard check, except:

* If a <> 0 and g <> 9, substitute the weight specified in the modulus weight
  table with:
    u v w x y z a b c d e  f g h
    0 0 1 2 5 3 6 4 8 7 10 9 3 1

* If a <> 0 and g = 9, substitute the weight specified in the modulus weight
  table with:
    u v w x y z a b c d e f g h
    0 0 0 0 0 0 0 0 8 7 10 9 3 1

If the first row with exception 2 passes the standard modulus 11 check, you do not need to carry out the second check (ie it is deemed to be a valid sterling account).

All Lloyds euro accounts are held at sorting code 30-96-34, however customers may perceive that their euro account is held at the branch where sterling accounts are held and thus quote a sorting code other than 30-96-34. The combination of the “sterling” sorting code and “euro” account number will cause the first standard modulus 11 check to fail. In such cases, carry out the second modulus 11 check, substituting the sorting code with 309634 and the appropriate weighting. If this check passes it is deemed to be a valid euro account.

Constant Summary

Constants included from NumberIndices

NumberIndices::NUMBER_INDEX

Instance Attribute Summary

Attributes inherited from BaseException

#account_number, #check_number, #modulus_weight, #sort_code

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseException

#after_calculate_total, #apply_account_number_substitutions, #initialize, #override_test?, #zero_all, #zero_u_b

Constructor Details

This class inherits a constructor from BaseException

Class Method Details

.allow_any?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/uk_account_validator/exceptions/exception_2_9.rb', line 31

def self.allow_any?
  true
end

Instance Method Details

#apply_sort_code_substitutionsObject



35
36
37
38
39
# File 'lib/uk_account_validator/exceptions/exception_2_9.rb', line 35

def apply_sort_code_substitutions
  return '309634' if check_number == 2

  return sort_code
end

#replace_weight(test_digits) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/uk_account_validator/exceptions/exception_2_9.rb', line 41

def replace_weight(test_digits)
  return modulus_weight if test_digits[NUMBER_INDEX[:a]] == 0
  return substitute_modulus_weight if check_number == 2

  if test_digits[NUMBER_INDEX[:g]] != 9
    return UkAccountValidator::ModulusWeight.new(
      modulus_weight.sort_code_start,
      modulus_weight.sort_code_end,
      modulus_weight.modulus,
      0, 0, 1, 2, 5, 3, 6, 4, 8, 7, 10, 9, 3, 1,
      modulus_weight.exception
    )
  else
    return UkAccountValidator::ModulusWeight.new(
      modulus_weight.sort_code_start,
      modulus_weight.sort_code_end,
      modulus_weight.modulus,
      0, 0, 0, 0, 0, 0, 0, 0, 8, 7, 10, 9, 3, 1,
      modulus_weight.exception
    )
  end
end

#substitute_modulus_weightObject

Returns the modulus weight for 309634



65
66
67
# File 'lib/uk_account_validator/exceptions/exception_2_9.rb', line 65

def substitute_modulus_weight
  UkAccountValidator.modulus_weights_table.find('309634').first
end