banktools-se 3.3.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -1
- data/CHANGELOG.md +5 -0
- data/lib/banktools-se/account/clearing_number.rb +6 -5
- data/lib/banktools-se/account.rb +9 -6
- data/lib/banktools-se/version.rb +1 -1
- data/spec/account_spec.rb +17 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f88306b60a358141bee6be5459b368874cbacf93b902c49fa00bcb9301b5afd9
|
|
4
|
+
data.tar.gz: ef5e4b8daac88c910d062837481e78367eb59e58f26d3bcf90e86786c862e5bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3daa817d195a97aca47e6e96d4f1455c24f7673c8807f4299909297b3ce66718927fd4c8d2fe9b95aedd0402a74f6a014bc8e79553404f9b15d43616089b1a0b
|
|
7
|
+
data.tar.gz: 19e3092e3b94606ca94d8213c92bddca3e9a720cc50e90bbdc6104973593dd1ead85d19eb0be09c116b68005130bf975a5af95c549493fdb4fe0dd084a218693
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -6,6 +6,9 @@ on:
|
|
|
6
6
|
pull_request:
|
|
7
7
|
branches: [ master ]
|
|
8
8
|
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
9
12
|
jobs:
|
|
10
13
|
ruby-versions:
|
|
11
14
|
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
@@ -22,7 +25,7 @@ jobs:
|
|
|
22
25
|
ruby-version: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
23
26
|
|
|
24
27
|
steps:
|
|
25
|
-
- uses: actions/checkout@
|
|
28
|
+
- uses: actions/checkout@v7
|
|
26
29
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
27
30
|
uses: ruby/setup-ruby@v1
|
|
28
31
|
with:
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
- Zerofill Handelsbanken serial numbers to 9 digits in `Account#serial_number` and `Account#normalize`. 8-digit serial numbers are still valid; 7 or fewer are still too short.
|
|
6
|
+
- A Swedbank/Sparbanken account with no serial number digits at all (e.g. "8000-2") is now too short, rather than zerofilled to all zeroes.
|
|
7
|
+
|
|
3
8
|
## 3.3.2
|
|
4
9
|
|
|
5
10
|
- Revert erroneous changes introduced in 3.3.1
|
|
@@ -18,10 +18,11 @@ module BankTools
|
|
|
18
18
|
3782..3782 => { name: "Nordea", serial_number_length: 10, luhn_for_serial: true }, # Personkonto.
|
|
19
19
|
3783..4999 => { name: "Nordea" },
|
|
20
20
|
5000..5999 => { name: "SEB" },
|
|
21
|
-
|
|
21
|
+
# Can be 8 or 9 chars but must be zero-filled to 9.
|
|
22
|
+
6000..6999 => { name: "Handelsbanken", serial_number_length: 8..9, zerofill: true },
|
|
22
23
|
7000..7999 => { name: "Swedbank" },
|
|
23
|
-
# Can be fewer chars but must be zero-filled
|
|
24
|
-
8000..8999 => { name: "Swedbank", serial_number_length: 10, checksum_for_clearing: true, zerofill: true },
|
|
24
|
+
# Can be fewer chars but must be zero-filled to 10.
|
|
25
|
+
8000..8999 => { name: "Swedbank", serial_number_length: 1..10, checksum_for_clearing: true, zerofill: true },
|
|
25
26
|
9020..9029 => { name: "Länsförsäkringar Bank" },
|
|
26
27
|
9040..9049 => { name: "Citibank" },
|
|
27
28
|
9060..9069 => { name: "Länsförsäkringar Bank" },
|
|
@@ -38,13 +39,13 @@ module BankTools
|
|
|
38
39
|
9260..9269 => { name: "Den Norske Bank" },
|
|
39
40
|
9270..9279 => { name: "ICA Banken" },
|
|
40
41
|
9280..9289 => { name: "Resurs Bank" },
|
|
41
|
-
9300..9349 => { name: "Sparbanken Öresund", serial_number_length: 10, zerofill: true },
|
|
42
|
+
9300..9349 => { name: "Sparbanken Öresund", serial_number_length: 1..10, zerofill: true },
|
|
42
43
|
9400..9449 => { name: "Forex Bank" },
|
|
43
44
|
9460..9469 => { name: "GE Money Bank" },
|
|
44
45
|
9470..9479 => { name: "Fortis Bank" },
|
|
45
46
|
9500..9549 => { name: "Nordea/Plusgirot", serial_number_length: 1..10 },
|
|
46
47
|
9550..9569 => { name: "Avanza Bank" },
|
|
47
|
-
9570..9579 => { name: "Sparbanken Syd", serial_number_length: 10, zerofill: true },
|
|
48
|
+
9570..9579 => { name: "Sparbanken Syd", serial_number_length: 1..10, zerofill: true },
|
|
48
49
|
9630..9639 => { name: "Lån og Spar Bank Sverige" },
|
|
49
50
|
9640..9649 => { name: "Nordax Bank AB" },
|
|
50
51
|
9650..9659 => { name: "MedMera Bank" },
|
data/lib/banktools-se/account.rb
CHANGED
|
@@ -23,8 +23,9 @@ module BankTools
|
|
|
23
23
|
def errors
|
|
24
24
|
errors = []
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
errors << Errors::
|
|
26
|
+
# Validate the serial number as given, before any zero-filling.
|
|
27
|
+
errors << Errors::TOO_SHORT if raw_serial_number.length < min_length
|
|
28
|
+
errors << Errors::TOO_LONG if raw_serial_number.length > max_length
|
|
28
29
|
errors << Errors::INVALID_CHARACTERS if number.to_s.match(/[^\d -]/)
|
|
29
30
|
|
|
30
31
|
if luhn_for_serial?
|
|
@@ -63,17 +64,19 @@ module BankTools
|
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
def serial_number
|
|
66
|
-
number = digits.slice(clearing_number_length..-1) || ""
|
|
67
|
-
|
|
68
67
|
if zerofill?
|
|
69
|
-
|
|
68
|
+
raw_serial_number.rjust(Array(serial_number_length).last, "0")
|
|
70
69
|
else
|
|
71
|
-
|
|
70
|
+
raw_serial_number
|
|
72
71
|
end
|
|
73
72
|
end
|
|
74
73
|
|
|
75
74
|
private
|
|
76
75
|
|
|
76
|
+
def raw_serial_number
|
|
77
|
+
digits.slice(clearing_number_length..-1) || ""
|
|
78
|
+
end
|
|
79
|
+
|
|
77
80
|
def clearing_number_length
|
|
78
81
|
checksum_for_clearing? ? 5 : 4
|
|
79
82
|
end
|
data/lib/banktools-se/version.rb
CHANGED
data/spec/account_spec.rb
CHANGED
|
@@ -81,6 +81,14 @@ RSpec.describe BankTools::SE::Account do
|
|
|
81
81
|
expect(BankTools::SE::Account.new("9570-2-00000000").errors).not_to include(BankTools::SE::Errors::TOO_SHORT)
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
it "should include :too_short for Handelsbanken numbers shorter than 8 digits, even though they are zerofilled" do
|
|
85
|
+
expect(BankTools::SE::Account.new("6000-1234567").errors).to include(BankTools::SE::Errors::TOO_SHORT)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should include :too_long for Handelsbanken numbers longer than 9 digits" do
|
|
89
|
+
expect(BankTools::SE::Account.new("6000-1234567890").errors).to include(BankTools::SE::Errors::TOO_LONG)
|
|
90
|
+
end
|
|
91
|
+
|
|
84
92
|
it "should include :too_long for numbers longer than the bank allows" do
|
|
85
93
|
expect(BankTools::SE::Account.new("1100000000007").errors).to include(BankTools::SE::Errors::TOO_LONG)
|
|
86
94
|
end
|
|
@@ -139,6 +147,10 @@ RSpec.describe BankTools::SE::Account do
|
|
|
139
147
|
expect(BankTools::SE::Account.new("8000-2-0000000000").serial_number).to eq("0000000000")
|
|
140
148
|
end
|
|
141
149
|
|
|
150
|
+
it "should zerofill Handelsbanken serial numbers to 9 digits" do
|
|
151
|
+
expect(BankTools::SE::Account.new("6000-12345678").serial_number).to eq("012345678")
|
|
152
|
+
end
|
|
153
|
+
|
|
142
154
|
it "should be the empty string if there aren't enough numbers" do
|
|
143
155
|
expect(BankTools::SE::Account.new("12").serial_number).to eq("")
|
|
144
156
|
end
|
|
@@ -154,6 +166,11 @@ RSpec.describe BankTools::SE::Account do
|
|
|
154
166
|
expect(BankTools::SE::Account.new("8000-2-0000000000").normalize).to eq("8000-2-0000000000")
|
|
155
167
|
end
|
|
156
168
|
|
|
169
|
+
it "should zerofill Handelsbanken serial numbers to 9 digits" do
|
|
170
|
+
expect(BankTools::SE::Account.new("6000-12345678").normalize).to eq("6000-012345678")
|
|
171
|
+
expect(BankTools::SE::Account.new("6000-123456789").normalize).to eq("6000-123456789")
|
|
172
|
+
end
|
|
173
|
+
|
|
157
174
|
it "should not attempt to normalize invalid numbers" do
|
|
158
175
|
expect(BankTools::SE::Account.new(" 1-2-3 ").normalize).to eq(" 1-2-3 ")
|
|
159
176
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: banktools-se
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Henrik Nyh
|
|
@@ -45,7 +45,7 @@ licenses: []
|
|
|
45
45
|
metadata:
|
|
46
46
|
rubygems_mfa_required: 'true'
|
|
47
47
|
source_code_uri: https://github.com/barsoom/banktools-se
|
|
48
|
-
changelog_uri: https://github.com/barsoom/banktools-se/blob/v3.
|
|
48
|
+
changelog_uri: https://github.com/barsoom/banktools-se/blob/v3.4.0/CHANGELOG.md
|
|
49
49
|
rdoc_options: []
|
|
50
50
|
require_paths:
|
|
51
51
|
- lib
|
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
62
|
requirements: []
|
|
63
|
-
rubygems_version: 4.0.
|
|
63
|
+
rubygems_version: 4.0.22
|
|
64
64
|
specification_version: 4
|
|
65
65
|
summary: Validate and normalize Swedish bank account numbers, plusgiro and bankgiro.
|
|
66
66
|
test_files: []
|