ibandit 0.11.28 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +2 -5
- data/.rubocop_todo.yml +70 -15
- data/.travis.yml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -3
- data/README.md +6 -6
- data/data/structures.yml +4 -4
- data/ibandit.gemspec +2 -2
- data/lib/ibandit.rb +6 -3
- data/lib/ibandit/check_digit.rb +2 -0
- data/lib/ibandit/constants.rb +3 -1
- data/lib/ibandit/errors.rb +2 -0
- data/lib/ibandit/german_details_converter.rb +4 -1
- data/lib/ibandit/iban.rb +8 -4
- data/lib/ibandit/iban_assembler.rb +2 -0
- data/lib/ibandit/iban_splitter.rb +8 -7
- data/lib/ibandit/local_details_cleaner.rb +38 -35
- data/lib/ibandit/pseudo_iban_assembler.rb +5 -1
- data/lib/ibandit/pseudo_iban_splitter.rb +7 -1
- data/lib/ibandit/sweden/bank_lookup.rb +2 -0
- data/lib/ibandit/sweden/local_details_converter.rb +6 -2
- data/lib/ibandit/sweden/validator.rb +2 -0
- data/lib/ibandit/version.rb +3 -1
- data/spec/ibandit/constants_spec.rb +2 -0
- data/spec/ibandit/german_details_converter_spec.rb +9 -3
- data/spec/ibandit/iban_assembler_spec.rb +92 -3
- data/spec/ibandit/iban_spec.rb +197 -17
- data/spec/ibandit/iban_splitter_spec.rb +6 -0
- data/spec/ibandit/local_details_cleaner_spec.rb +135 -5
- data/spec/ibandit/pseudo_iban_assembler_spec.rb +2 -0
- data/spec/ibandit/pseudo_iban_splitter_spec.rb +2 -0
- data/spec/ibandit/structure_spec.rb +5 -3
- data/spec/ibandit/sweden/local_details_converter_spec.rb +3 -0
- data/spec/ibandit/sweden/validator_spec.rb +35 -0
- data/spec/spec_helper.rb +2 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 13ca505f43dfd880ea0de62afe35c6b6a18c5036b523f7656b0cc36983af4a06
|
4
|
+
data.tar.gz: 913d870c4c191e184189c3872bbbdef83abe3f5074670856ef8eb2d4166988cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 429b3a3de4af3d7b1a7620e7be46594f354e963bfedda97fcfb87ee983d17ae3cf87bcd7ae3891080e90392917b7c33955c0442efe38ab7404fd09484e55d1e9
|
7
|
+
data.tar.gz: ac9ff959b43a974efc436dbe809784e33c6e68c8065421b9a5a194b5bf24a5e64fd469cc79223c36d70f2f8bd43a12d8af82f3fe1ec0c2ff32ce9b5d02c4261b
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
inherit_gem:
|
3
|
-
|
3
|
+
gc_ruboconfig: rubocop.yml
|
4
4
|
|
5
5
|
AllCops:
|
6
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.4
|
7
7
|
|
8
8
|
# Limit lines to 80 characters.
|
9
9
|
LineLength:
|
@@ -21,9 +21,6 @@ SingleLineMethods:
|
|
21
21
|
NumericLiterals:
|
22
22
|
Enabled: false
|
23
23
|
|
24
|
-
Performance/RegexpMatch:
|
25
|
-
Enabled: false
|
26
|
-
|
27
24
|
# Wants you to use the same argument names for every reduce. This seems kinda
|
28
25
|
# naff compared to naming them semantically
|
29
26
|
SingleLineBlockParams:
|
data/.rubocop_todo.yml
CHANGED
@@ -1,27 +1,82 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
#
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-05-30 14:34:05 +0100 using RuboCop version 0.70.0.
|
3
4
|
# The point is for the user to remove these configuration records
|
4
5
|
# one by one as the offenses are removed from the code base.
|
5
6
|
# Note that changes in the inspected code, or installation of new
|
6
7
|
# versions of RuboCop, may require this file to be generated again.
|
7
8
|
|
8
|
-
# Offense count:
|
9
|
+
# Offense count: 10
|
9
10
|
Metrics/AbcSize:
|
10
|
-
Max:
|
11
|
+
Max: 25
|
12
|
+
|
13
|
+
# Offense count: 4
|
14
|
+
Metrics/CyclomaticComplexity:
|
15
|
+
Max: 8
|
11
16
|
|
12
17
|
# Offense count: 1
|
13
|
-
# Configuration parameters:
|
14
|
-
|
15
|
-
|
18
|
+
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
19
|
+
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
20
|
+
Naming/MemoizedInstanceVariableName:
|
21
|
+
Exclude:
|
22
|
+
- 'lib/ibandit/sweden/bank_lookup.rb'
|
16
23
|
|
17
24
|
# Offense count: 1
|
18
|
-
|
19
|
-
|
25
|
+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
26
|
+
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
27
|
+
Naming/UncommunicativeMethodParamName:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/ibandit/german_details_converter.rb'
|
20
30
|
|
21
|
-
# Offense count:
|
22
|
-
|
23
|
-
|
31
|
+
# Offense count: 1
|
32
|
+
RSpec/DescribeClass:
|
33
|
+
Exclude:
|
34
|
+
- 'spec/ibandit/structure_spec.rb'
|
24
35
|
|
25
|
-
# Offense count:
|
26
|
-
|
27
|
-
|
36
|
+
# Offense count: 1
|
37
|
+
# Configuration parameters: Max.
|
38
|
+
RSpec/ExampleLength:
|
39
|
+
Exclude:
|
40
|
+
- 'spec/ibandit/iban_spec.rb'
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
RSpec/ExpectInHook:
|
44
|
+
Exclude:
|
45
|
+
- 'spec/ibandit/german_details_converter_spec.rb'
|
46
|
+
|
47
|
+
# Offense count: 12
|
48
|
+
# Configuration parameters: AggregateFailuresByDefault.
|
49
|
+
RSpec/MultipleExpectations:
|
50
|
+
Max: 2
|
51
|
+
|
52
|
+
# Offense count: 20
|
53
|
+
# Configuration parameters: IgnoreSharedExamples.
|
54
|
+
RSpec/NamedSubject:
|
55
|
+
Exclude:
|
56
|
+
- 'spec/ibandit/iban_spec.rb'
|
57
|
+
|
58
|
+
# Offense count: 367
|
59
|
+
RSpec/NestedGroups:
|
60
|
+
Max: 6
|
61
|
+
|
62
|
+
# Offense count: 3
|
63
|
+
RSpec/ScatteredLet:
|
64
|
+
Exclude:
|
65
|
+
- 'spec/ibandit/iban_spec.rb'
|
66
|
+
|
67
|
+
# Offense count: 18
|
68
|
+
RSpec/ScatteredSetup:
|
69
|
+
Exclude:
|
70
|
+
- 'spec/ibandit/iban_assembler_spec.rb'
|
71
|
+
- 'spec/ibandit/iban_spec.rb'
|
72
|
+
|
73
|
+
# Offense count: 13
|
74
|
+
RSpec/SubjectStub:
|
75
|
+
Exclude:
|
76
|
+
- 'spec/ibandit/iban_spec.rb'
|
77
|
+
|
78
|
+
# Offense count: 5
|
79
|
+
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
80
|
+
RSpec/VerifiedDoubles:
|
81
|
+
Exclude:
|
82
|
+
- 'spec/ibandit/iban_spec.rb'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.0.0 - October 24, 2019
|
2
|
+
|
3
|
+
- Discontinued support for older Ruby versions (2.1.10, 2.2.7, 2.3.4 and 2.4.1)
|
4
|
+
- Update rubocop and ruboconfig
|
5
|
+
- Updates the example bank details for the United States
|
6
|
+
- Updates the definition of the structure for IBANs in Costa Rica (courtesy @sprileyMSTS)
|
7
|
+
|
1
8
|
## 0.11.28 - March 21, 2019
|
2
9
|
|
3
10
|
- Handle bad input more gracefully (`bank_code` being nil)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -566,16 +566,16 @@ iban.account_number # => "3333333044"
|
|
566
566
|
# USA
|
567
567
|
iban = Ibandit::IBAN.new(
|
568
568
|
country_code: 'US',
|
569
|
-
bank_code: '
|
570
|
-
account_number: '
|
569
|
+
bank_code: '026073150', # 9-digit routing number
|
570
|
+
account_number: '2715500356' # 1 to 17 digits
|
571
571
|
)
|
572
|
-
iban.pseudo_iban # => "
|
572
|
+
iban.pseudo_iban # => "USZZ026073150_______2715500356"
|
573
573
|
iban.iban # => nil
|
574
574
|
|
575
|
-
iban = Ibandit::IBAN.new('
|
575
|
+
iban = Ibandit::IBAN.new('USZZ026073150_______2715500356')
|
576
576
|
iban.country_code # => "US"
|
577
|
-
iban.bank_code # => "
|
578
|
-
iban.account_number # => "
|
577
|
+
iban.bank_code # => "026073150"
|
578
|
+
iban.account_number # => "_______2715500356"
|
579
579
|
iban.iban # => nil
|
580
580
|
```
|
581
581
|
|
data/data/structures.yml
CHANGED
@@ -149,15 +149,15 @@ CH:
|
|
149
149
|
:bank_code_format: "\\d{5}"
|
150
150
|
:account_number_format: "[A-Z0-9]{12}"
|
151
151
|
CR:
|
152
|
-
:bank_code_position:
|
152
|
+
:bank_code_position: 6
|
153
153
|
:bank_code_length: 3
|
154
154
|
:branch_code_position: 0
|
155
155
|
:branch_code_length: 0
|
156
|
-
:account_number_position:
|
156
|
+
:account_number_position: 9
|
157
157
|
:account_number_length: 14
|
158
|
-
:total_length:
|
158
|
+
:total_length: 22
|
159
159
|
:national_id_length: 3
|
160
|
-
:bban_format: "\\d{3}\\d{14}"
|
160
|
+
:bban_format: "0\\d{3}\\d{14}"
|
161
161
|
:bank_code_format: "\\d{3}"
|
162
162
|
:account_number_format: "\\d{14}"
|
163
163
|
CY:
|
data/ibandit.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path("
|
3
|
+
require File.expand_path("lib/ibandit/version", __dir__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.add_development_dependency "nokogiri", "~> 1.6"
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.add_development_dependency "pry-nav", "~> 0.2"
|
9
9
|
gem.add_development_dependency "rspec", "~> 3.3"
|
10
10
|
gem.add_development_dependency "rspec-its", "~> 1.2"
|
11
|
-
gem.add_development_dependency "rubocop", "~> 0.
|
11
|
+
gem.add_development_dependency "rubocop", "~> 0.70.0"
|
12
12
|
gem.add_development_dependency "sax-machine", "~> 1.3"
|
13
13
|
|
14
14
|
gem.add_runtime_dependency "i18n"
|
data/lib/ibandit.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "i18n"
|
2
4
|
require "ibandit/version"
|
3
5
|
require "ibandit/errors"
|
@@ -14,8 +16,8 @@ require "ibandit/pseudo_iban_splitter"
|
|
14
16
|
require "ibandit/local_details_cleaner"
|
15
17
|
require "ibandit/check_digit"
|
16
18
|
|
17
|
-
I18n.load_path += Dir[File.expand_path("
|
18
|
-
|
19
|
+
I18n.load_path += Dir[File.expand_path("../config/locales/*.{rb,yml}",
|
20
|
+
__dir__)]
|
19
21
|
|
20
22
|
module Ibandit
|
21
23
|
class << self
|
@@ -23,12 +25,13 @@ module Ibandit
|
|
23
25
|
|
24
26
|
def find_bic(country_code, national_id)
|
25
27
|
raise NotImplementedError, "BIC finder is not defined" unless @bic_finder
|
28
|
+
|
26
29
|
@bic_finder.call(country_code, national_id)
|
27
30
|
end
|
28
31
|
|
29
32
|
def structures
|
30
33
|
@structures ||= YAML.load_file(
|
31
|
-
File.expand_path("
|
34
|
+
File.expand_path("../data/structures.yml", __dir__),
|
32
35
|
)
|
33
36
|
end
|
34
37
|
|
data/lib/ibandit/check_digit.rb
CHANGED
data/lib/ibandit/constants.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ibandit
|
2
4
|
module Constants
|
3
5
|
CONSTRUCTABLE_IBAN_COUNTRY_CODES = %w[AT BE BG CY CZ DE DK EE ES FI FR GB GR
|
@@ -8,7 +10,7 @@ module Ibandit
|
|
8
10
|
DECONSTRUCTABLE_IBAN_COUNTRY_CODES =
|
9
11
|
CONSTRUCTABLE_IBAN_COUNTRY_CODES - PSEUDO_IBAN_COUNTRY_CODES
|
10
12
|
|
11
|
-
PSEUDO_IBAN_CHECK_DIGITS = "ZZ"
|
13
|
+
PSEUDO_IBAN_CHECK_DIGITS = "ZZ"
|
12
14
|
|
13
15
|
PSEUDO_IBAN_PADDING_CHARACTER_FOR = {
|
14
16
|
"SE" => "X", # Using X for backwards compatibility
|
data/lib/ibandit/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# German bank details don't map directly to IBANs in the same way as in other
|
2
4
|
# countries - each bank has idiosyncracies for translating its cusomers' bank
|
3
5
|
# details. These idiosyncracies are described in a document from the Bundesbank:
|
@@ -7,7 +9,7 @@ module Ibandit
|
|
7
9
|
module GermanDetailsConverter
|
8
10
|
def self.rules
|
9
11
|
@rules ||= YAML.load_file(
|
10
|
-
File.expand_path("
|
12
|
+
File.expand_path("../../data/german_iban_rules.yml", __dir__),
|
11
13
|
)
|
12
14
|
end
|
13
15
|
|
@@ -290,6 +292,7 @@ module Ibandit
|
|
290
292
|
|
291
293
|
def valid?
|
292
294
|
return false unless valid_length? && valid_account_type?
|
295
|
+
|
293
296
|
[master_number[-1].to_i, 10].include?(remainder)
|
294
297
|
end
|
295
298
|
|
data/lib/ibandit/iban.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "yaml"
|
2
4
|
|
3
5
|
module Ibandit
|
@@ -155,7 +157,7 @@ module Ibandit
|
|
155
157
|
|
156
158
|
def valid_bank_code_length?
|
157
159
|
return unless valid_country_code?
|
158
|
-
return true if structure[:bank_code_length]
|
160
|
+
return true if structure[:bank_code_length]&.zero?
|
159
161
|
|
160
162
|
if swift_bank_code.nil? || swift_bank_code.empty?
|
161
163
|
@errors[:bank_code] = Ibandit.translate(:is_required)
|
@@ -175,7 +177,7 @@ module Ibandit
|
|
175
177
|
return true
|
176
178
|
end
|
177
179
|
|
178
|
-
if structure[:branch_code_length]
|
180
|
+
if structure[:branch_code_length]&.zero?
|
179
181
|
@errors[:branch_code] = Ibandit.translate(:not_used_in_country,
|
180
182
|
country_code: country_code)
|
181
183
|
elsif swift_branch_code.nil? || swift_branch_code.empty?
|
@@ -208,6 +210,7 @@ module Ibandit
|
|
208
210
|
|
209
211
|
def valid_characters?
|
210
212
|
return if iban.nil?
|
213
|
+
|
211
214
|
if iban.scan(/[^A-Z0-9]/).any?
|
212
215
|
@errors[:characters] =
|
213
216
|
Ibandit.translate(:non_alphanumeric_characters,
|
@@ -233,7 +236,7 @@ module Ibandit
|
|
233
236
|
|
234
237
|
def valid_bank_code_format?
|
235
238
|
return unless valid_bank_code_length?
|
236
|
-
return true if structure[:bank_code_length]
|
239
|
+
return true if structure[:bank_code_length]&.zero?
|
237
240
|
|
238
241
|
if swift_bank_code =~ Regexp.new(structure[:bank_code_format])
|
239
242
|
true
|
@@ -477,7 +480,7 @@ module Ibandit
|
|
477
480
|
@swift_account_number = swift_details[:account_number]
|
478
481
|
|
479
482
|
return if Constants::PSEUDO_IBAN_COUNTRY_CODES.
|
480
|
-
|
483
|
+
include?(@country_code)
|
481
484
|
|
482
485
|
@bank_code = swift_details[:bank_code]
|
483
486
|
@branch_code = swift_details[:branch_code]
|
@@ -530,6 +533,7 @@ module Ibandit
|
|
530
533
|
|
531
534
|
def pseudo_iban?(input)
|
532
535
|
return false if input.nil?
|
536
|
+
|
533
537
|
input.slice(2, 2) == Constants::PSEUDO_IBAN_CHECK_DIGITS
|
534
538
|
end
|
535
539
|
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ibandit
|
2
4
|
module IBANSplitter
|
3
5
|
def self.split(iban)
|
4
6
|
{
|
5
|
-
country_code:
|
6
|
-
check_digits:
|
7
|
-
bank_code:
|
8
|
-
branch_code:
|
7
|
+
country_code: country_code_from(iban),
|
8
|
+
check_digits: check_digits_from(iban),
|
9
|
+
bank_code: bank_code_from(iban),
|
10
|
+
branch_code: branch_code_from(iban),
|
9
11
|
account_number: account_number_from(iban),
|
10
12
|
}
|
11
13
|
end
|
@@ -36,9 +38,8 @@ module Ibandit
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def self.branch_code_from(iban)
|
39
|
-
unless decomposable?(iban) &&
|
40
|
-
|
41
|
-
end
|
41
|
+
return unless decomposable?(iban) &&
|
42
|
+
structure(iban)[:branch_code_length]&.positive?
|
42
43
|
|
43
44
|
iban.slice(
|
44
45
|
structure(iban)[:branch_code_position] - 1,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Ibandit
|
2
4
|
module LocalDetailsCleaner
|
3
5
|
def self.clean(local_details)
|
@@ -57,8 +59,9 @@ module Ibandit
|
|
57
59
|
# Account number may be 4-11 digits long.
|
58
60
|
# Add leading zeros to account number if < 11 digits.
|
59
61
|
return {} unless local_details[:account_number].length >= 4
|
62
|
+
|
60
63
|
{
|
61
|
-
bank_code:
|
64
|
+
bank_code: local_details[:bank_code],
|
62
65
|
account_number: local_details[:account_number].rjust(11, "0"),
|
63
66
|
}
|
64
67
|
end
|
@@ -71,7 +74,7 @@ module Ibandit
|
|
71
74
|
return {} unless local_details[:account_number].length >= 5
|
72
75
|
|
73
76
|
{
|
74
|
-
branch_code:
|
77
|
+
branch_code: local_details[:branch_code].delete("-"),
|
75
78
|
account_number: local_details[:account_number].rjust(10, "0"),
|
76
79
|
}
|
77
80
|
end
|
@@ -80,7 +83,7 @@ module Ibandit
|
|
80
83
|
account_number = local_details[:account_number].tr("-", "")
|
81
84
|
|
82
85
|
{
|
83
|
-
bank_code:
|
86
|
+
bank_code: local_details[:bank_code] || account_number.slice(0, 3),
|
84
87
|
account_number: account_number,
|
85
88
|
}
|
86
89
|
end
|
@@ -137,8 +140,8 @@ module Ibandit
|
|
137
140
|
end
|
138
141
|
|
139
142
|
{
|
140
|
-
bank_code:
|
141
|
-
branch_code:
|
143
|
+
bank_code: bank_code,
|
144
|
+
branch_code: branch_code,
|
142
145
|
account_number: account_number,
|
143
146
|
}
|
144
147
|
end
|
@@ -158,7 +161,7 @@ module Ibandit
|
|
158
161
|
end
|
159
162
|
|
160
163
|
{
|
161
|
-
bank_code:
|
164
|
+
bank_code: local_details[:bank_code],
|
162
165
|
account_number: account_number,
|
163
166
|
}
|
164
167
|
end
|
@@ -180,7 +183,7 @@ module Ibandit
|
|
180
183
|
return {} unless converted_details[:account_number].length >= 4
|
181
184
|
|
182
185
|
{
|
183
|
-
bank_code:
|
186
|
+
bank_code: converted_details[:bank_code],
|
184
187
|
account_number: converted_details[:account_number].rjust(10, "0"),
|
185
188
|
}
|
186
189
|
end
|
@@ -202,7 +205,7 @@ module Ibandit
|
|
202
205
|
end
|
203
206
|
|
204
207
|
{
|
205
|
-
bank_code:
|
208
|
+
bank_code: bank_code.rjust(4, "0"),
|
206
209
|
account_number: account_number.delete("-").rjust(10, "0"),
|
207
210
|
}
|
208
211
|
end
|
@@ -246,8 +249,8 @@ module Ibandit
|
|
246
249
|
end
|
247
250
|
|
248
251
|
{
|
249
|
-
bank_code:
|
250
|
-
branch_code:
|
252
|
+
bank_code: bank_code,
|
253
|
+
branch_code: branch_code,
|
251
254
|
account_number: account_number,
|
252
255
|
}
|
253
256
|
end
|
@@ -267,15 +270,15 @@ module Ibandit
|
|
267
270
|
end
|
268
271
|
|
269
272
|
{
|
270
|
-
bank_code:
|
273
|
+
bank_code: local_details[:bank_code],
|
271
274
|
account_number: account_number,
|
272
275
|
}
|
273
276
|
end
|
274
277
|
|
275
278
|
def self.clean_fr_details(local_details)
|
276
279
|
{
|
277
|
-
bank_code:
|
278
|
-
branch_code:
|
280
|
+
bank_code: local_details[:bank_code],
|
281
|
+
branch_code: local_details[:branch_code],
|
279
282
|
account_number: local_details[:account_number].gsub(/[-\s]/, ""),
|
280
283
|
}
|
281
284
|
end
|
@@ -296,8 +299,8 @@ module Ibandit
|
|
296
299
|
account_number = account_number.rjust(8, "0") if account_number.length > 5
|
297
300
|
|
298
301
|
{
|
299
|
-
bank_code:
|
300
|
-
branch_code:
|
302
|
+
bank_code: bank_code,
|
303
|
+
branch_code: branch_code,
|
301
304
|
account_number: account_number,
|
302
305
|
}
|
303
306
|
end
|
@@ -317,7 +320,7 @@ module Ibandit
|
|
317
320
|
bank_code, account_number = local_details[:account_number].split("-", 2)
|
318
321
|
|
319
322
|
{
|
320
|
-
bank_code:
|
323
|
+
bank_code: bank_code,
|
321
324
|
account_number: account_number,
|
322
325
|
}
|
323
326
|
end
|
@@ -334,14 +337,14 @@ module Ibandit
|
|
334
337
|
case cleaned_acct_number.length
|
335
338
|
when 16
|
336
339
|
{
|
337
|
-
bank_code:
|
338
|
-
branch_code:
|
340
|
+
bank_code: cleaned_acct_number.slice(0, 3),
|
341
|
+
branch_code: cleaned_acct_number.slice(3, 4),
|
339
342
|
account_number: cleaned_acct_number.slice(7, 9).ljust(17, "0"),
|
340
343
|
}
|
341
344
|
when 24
|
342
345
|
{
|
343
|
-
bank_code:
|
344
|
-
branch_code:
|
346
|
+
bank_code: cleaned_acct_number.slice(0, 3),
|
347
|
+
branch_code: cleaned_acct_number.slice(3, 4),
|
345
348
|
account_number: cleaned_acct_number.slice(7, 17),
|
346
349
|
}
|
347
350
|
else local_details
|
@@ -363,8 +366,8 @@ module Ibandit
|
|
363
366
|
account_number = account_number.rjust(8, "0") if account_number.length > 5
|
364
367
|
|
365
368
|
{
|
366
|
-
bank_code:
|
367
|
-
branch_code:
|
369
|
+
bank_code: bank_code,
|
370
|
+
branch_code: branch_code,
|
368
371
|
account_number: account_number,
|
369
372
|
}
|
370
373
|
end
|
@@ -381,7 +384,7 @@ module Ibandit
|
|
381
384
|
end
|
382
385
|
|
383
386
|
{
|
384
|
-
bank_code:
|
387
|
+
bank_code: bank_code.rjust(4, "0"),
|
385
388
|
account_number: pad_is_account_number(parts),
|
386
389
|
}
|
387
390
|
end
|
@@ -389,8 +392,8 @@ module Ibandit
|
|
389
392
|
def self.clean_it_details(local_details)
|
390
393
|
# Add leading zeros to account number if < 12 digits.
|
391
394
|
{
|
392
|
-
bank_code:
|
393
|
-
branch_code:
|
395
|
+
bank_code: local_details[:bank_code],
|
396
|
+
branch_code: local_details[:branch_code],
|
394
397
|
account_number: local_details[:account_number].rjust(12, "0"),
|
395
398
|
}
|
396
399
|
end
|
@@ -430,8 +433,8 @@ module Ibandit
|
|
430
433
|
account_number = account_number.rjust(18, "0")
|
431
434
|
|
432
435
|
{
|
433
|
-
bank_code:
|
434
|
-
branch_code:
|
436
|
+
bank_code: bank_code,
|
437
|
+
branch_code: branch_code,
|
435
438
|
account_number: account_number,
|
436
439
|
}
|
437
440
|
end
|
@@ -439,7 +442,7 @@ module Ibandit
|
|
439
442
|
def self.clean_nl_details(local_details)
|
440
443
|
# Add leading zeros to account number if < 10 digits.
|
441
444
|
{
|
442
|
-
bank_code:
|
445
|
+
bank_code: local_details[:bank_code],
|
443
446
|
account_number: local_details[:account_number].rjust(10, "0"),
|
444
447
|
}
|
445
448
|
end
|
@@ -458,7 +461,7 @@ module Ibandit
|
|
458
461
|
end
|
459
462
|
|
460
463
|
{
|
461
|
-
bank_code:
|
464
|
+
bank_code: bank_code,
|
462
465
|
account_number: account_number,
|
463
466
|
}
|
464
467
|
end
|
@@ -496,8 +499,8 @@ module Ibandit
|
|
496
499
|
end
|
497
500
|
|
498
501
|
{
|
499
|
-
bank_code:
|
500
|
-
branch_code:
|
502
|
+
bank_code: bank_code,
|
503
|
+
branch_code: branch_code,
|
501
504
|
account_number: account_number,
|
502
505
|
}
|
503
506
|
end
|
@@ -516,7 +519,7 @@ module Ibandit
|
|
516
519
|
end
|
517
520
|
|
518
521
|
{
|
519
|
-
bank_code:
|
522
|
+
bank_code: bank_code,
|
520
523
|
account_number: account_number,
|
521
524
|
}
|
522
525
|
end
|
@@ -549,7 +552,7 @@ module Ibandit
|
|
549
552
|
def self.clean_si_details(local_details)
|
550
553
|
# Add leading zeros to account number if < 10 digits.
|
551
554
|
{
|
552
|
-
bank_code:
|
555
|
+
bank_code: local_details[:bank_code],
|
553
556
|
account_number: local_details[:account_number].rjust(10, "0"),
|
554
557
|
}
|
555
558
|
end
|
@@ -578,8 +581,8 @@ module Ibandit
|
|
578
581
|
|
579
582
|
def self.swift_details_for(local_details)
|
580
583
|
{
|
581
|
-
swift_bank_code:
|
582
|
-
swift_branch_code:
|
584
|
+
swift_bank_code: local_details[:bank_code],
|
585
|
+
swift_branch_code: local_details[:branch_code],
|
583
586
|
swift_account_number: local_details[:account_number],
|
584
587
|
}
|
585
588
|
end
|