banktools-se 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +4 -0
- data/README.markdown +2 -1
- data/banktools-se.gemspec +1 -0
- data/lib/banktools-se/account.rb +9 -4
- data/lib/banktools-se/version.rb +1 -1
- data/spec/account_spec.rb +13 -2
- data/spec/bankgiro_spec.rb +2 -2
- data/spec/plusgiro_spec.rb +2 -2
- metadata +39 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b0b808f0833e1ba8e7768e6e320d431a6aaa4f93
|
4
|
+
data.tar.gz: 4e1f2304d9c70caa71e7c7268c367a02fe1bebbe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6560518065f0eb8f9c1e5cc9926e2ce8fa5fd3d811f14a6a1a6d26db11f8654bf25307819686beae722bf869dddee2865db31f64c7d0a480f10c56961684513
|
7
|
+
data.tar.gz: 3657fde6ea4c9a9232041ffd94f2f6c13af3d56de15fb9fd99b2d6aa91de9e4a639b6ec7ead22e738c9a9b3bc76729f71b92b696f559179318cc4947d51c83cc
|
data/.travis.yml
ADDED
data/README.markdown
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Swedish bank tools
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/barsoom/banktools-se.png)](http://travis-ci.org/barsoom/banktools-se)
|
4
|
+
|
3
5
|
Ruby gem to validate, normalize/prettify and to some extent interpret
|
4
6
|
|
5
7
|
* Swedish bank account numbers
|
@@ -90,7 +92,6 @@ to install it.
|
|
90
92
|
|
91
93
|
Possible improvements to make:
|
92
94
|
|
93
|
-
* Handle [Sparbanken zerofill](http://www.danskebank.se/sv-se/eBanking-content/text-pages/Pages/Bankliste2.aspx).
|
94
95
|
* Luhn validation based on [BGC docs](http://www.bgc.se/upload/Gemensamt/Trycksaker/Manualer/BG910.pdf).
|
95
96
|
|
96
97
|
|
data/banktools-se.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
+
s.add_development_dependency "rake"
|
20
21
|
s.add_development_dependency "rspec"
|
21
22
|
s.add_development_dependency "guard"
|
22
23
|
s.add_development_dependency "guard-rspec"
|
data/lib/banktools-se/account.rb
CHANGED
@@ -25,7 +25,7 @@ module BankTools
|
|
25
25
|
6000..6999 => { :name => "Handelsbanken", :serial_number_length => 9 },
|
26
26
|
7000..7999 => { :name => "Swedbank" },
|
27
27
|
# Can be fewer chars but must be zero-filled, so let's call it 10.
|
28
|
-
8000..8999 => { :name => "Swedbank", :serial_number_length => 10, :checksum_for_clearing => true },
|
28
|
+
8000..8999 => { :name => "Swedbank", :serial_number_length => 10, :checksum_for_clearing => true, :zerofill => true },
|
29
29
|
9020..9029 => { :name => "Länsförsäkringar Bank" },
|
30
30
|
9040..9049 => { :name => "Citibank" },
|
31
31
|
9060..9069 => { :name => "Länsförsäkringar Bank" },
|
@@ -42,13 +42,13 @@ module BankTools
|
|
42
42
|
9260..9269 => { :name => "Den Norske Bank" },
|
43
43
|
9270..9279 => { :name => "ICA Banken" },
|
44
44
|
9280..9289 => { :name => "Resurs Bank" },
|
45
|
-
9300..9349 => { :name => "Sparbanken Öresund", :serial_number_length => 10 },
|
45
|
+
9300..9349 => { :name => "Sparbanken Öresund", :serial_number_length => 10, :zerofill => true },
|
46
46
|
9400..9449 => { :name => "Forex Bank" },
|
47
47
|
9460..9469 => { :name => "GE Money Bank" },
|
48
48
|
9470..9479 => { :name => "Fortis Bank" },
|
49
49
|
9500..9549 => { :name => "Nordea/Plusgirot", :serial_number_length => 1..10 },
|
50
50
|
9550..9569 => { :name => "Avanza Bank" },
|
51
|
-
9570..9579 => { :name => "Sparbanken Syd", :serial_number_length => 10 },
|
51
|
+
9570..9579 => { :name => "Sparbanken Syd", :serial_number_length => 10, :zerofill => true},
|
52
52
|
9960..9969 => { :name => "Nordea/Plusgirot", :serial_number_length => 1..10 },
|
53
53
|
}
|
54
54
|
|
@@ -98,7 +98,8 @@ module BankTools
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def serial_number
|
101
|
-
digits.slice(clearing_number_length..-1) || ""
|
101
|
+
number = digits.slice(clearing_number_length..-1) || ""
|
102
|
+
zerofill? ? "%.#{bank_data[:serial_number_length]}d" % number : number
|
102
103
|
end
|
103
104
|
|
104
105
|
private
|
@@ -144,6 +145,10 @@ module BankTools
|
|
144
145
|
number.to_s.gsub(/\D/, '')
|
145
146
|
end
|
146
147
|
|
148
|
+
def zerofill?
|
149
|
+
!!bank_data[:zerofill]
|
150
|
+
end
|
151
|
+
|
147
152
|
end
|
148
153
|
end
|
149
154
|
end
|
data/lib/banktools-se/version.rb
CHANGED
data/spec/account_spec.rb
CHANGED
@@ -13,13 +13,13 @@ describe BankTools::SE::Account do
|
|
13
13
|
|
14
14
|
it "should be true with no errors" do
|
15
15
|
account = BankTools::SE::Account.new("foo")
|
16
|
-
account.stub
|
16
|
+
account.stub(:errors).and_return([])
|
17
17
|
account.should be_valid
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should be false with errors" do
|
21
21
|
account = BankTools::SE::Account.new("foo")
|
22
|
-
account.stub
|
22
|
+
account.stub(:errors).and_return([:error])
|
23
23
|
account.should_not be_valid
|
24
24
|
end
|
25
25
|
|
@@ -78,6 +78,12 @@ describe BankTools::SE::Account do
|
|
78
78
|
BankTools::SE::Account.new("11007").errors.should include(BankTools::SE::Errors::TOO_SHORT)
|
79
79
|
end
|
80
80
|
|
81
|
+
it "should not include :too_short for Swedbank/Sparbanker numbers that can be zerofilled" do
|
82
|
+
BankTools::SE::Account.new("8000-2-00000000").errors.should_not include(BankTools::SE::Errors::TOO_SHORT)
|
83
|
+
BankTools::SE::Account.new("9300-2-00000000").errors.should_not include(BankTools::SE::Errors::TOO_SHORT)
|
84
|
+
BankTools::SE::Account.new("9570-2-00000000").errors.should_not include(BankTools::SE::Errors::TOO_SHORT)
|
85
|
+
end
|
86
|
+
|
81
87
|
it "should include :too_long for numbers longer than the bank allows" do
|
82
88
|
BankTools::SE::Account.new("1100000000007").errors.should include(BankTools::SE::Errors::TOO_LONG)
|
83
89
|
end
|
@@ -161,6 +167,11 @@ describe BankTools::SE::Account do
|
|
161
167
|
account = BankTools::SE::Account.new(" 1-2-3 ").normalize.should == " 1-2-3 "
|
162
168
|
end
|
163
169
|
|
170
|
+
it "should prepend zeroes to the serial number if necessary" do
|
171
|
+
BankTools::SE::Account.new("8000-2-80000003").normalize.should == "8000-2-0080000003"
|
172
|
+
BankTools::SE::Account.new("8000-2-8000000003").normalize.should == "8000-2-8000000003"
|
173
|
+
end
|
174
|
+
|
164
175
|
end
|
165
176
|
|
166
177
|
end
|
data/spec/bankgiro_spec.rb
CHANGED
@@ -11,13 +11,13 @@ describe BankTools::SE::Bankgiro do
|
|
11
11
|
|
12
12
|
it "should be true with no errors" do
|
13
13
|
account = BankTools::SE::Bankgiro.new("foo")
|
14
|
-
account.stub
|
14
|
+
account.stub(:errors).and_return([])
|
15
15
|
account.should be_valid
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be false with errors" do
|
19
19
|
account = BankTools::SE::Bankgiro.new("foo")
|
20
|
-
account.stub
|
20
|
+
account.stub(:errors).and_return([:error])
|
21
21
|
account.should_not be_valid
|
22
22
|
end
|
23
23
|
|
data/spec/plusgiro_spec.rb
CHANGED
@@ -11,13 +11,13 @@ describe BankTools::SE::Plusgiro do
|
|
11
11
|
|
12
12
|
it "should be true with no errors" do
|
13
13
|
account = BankTools::SE::Plusgiro.new("foo")
|
14
|
-
account.stub
|
14
|
+
account.stub(:errors).and_return([])
|
15
15
|
account.should be_valid
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be false with errors" do
|
19
19
|
account = BankTools::SE::Plusgiro.new("foo")
|
20
|
-
account.stub
|
20
|
+
account.stub(:errors).and_return([:error])
|
21
21
|
account.should_not be_valid
|
22
22
|
end
|
23
23
|
|
metadata
CHANGED
@@ -1,49 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banktools-se
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Henrik Nyh
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
18
30
|
requirements:
|
19
31
|
- - ! '>='
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '0'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
25
41
|
- !ruby/object:Gem::Dependency
|
26
42
|
name: guard
|
27
|
-
requirement:
|
28
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
29
44
|
requirements:
|
30
45
|
- - ! '>='
|
31
46
|
- !ruby/object:Gem::Version
|
32
47
|
version: '0'
|
33
48
|
type: :development
|
34
49
|
prerelease: false
|
35
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
36
55
|
- !ruby/object:Gem::Dependency
|
37
56
|
name: guard-rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
40
58
|
requirements:
|
41
59
|
- - ! '>='
|
42
60
|
- !ruby/object:Gem::Version
|
43
61
|
version: '0'
|
44
62
|
type: :development
|
45
63
|
prerelease: false
|
46
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
47
69
|
description:
|
48
70
|
email:
|
49
71
|
- henrik@barsoom.se
|
@@ -52,6 +74,7 @@ extensions: []
|
|
52
74
|
extra_rdoc_files: []
|
53
75
|
files:
|
54
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
55
78
|
- Gemfile
|
56
79
|
- Guardfile
|
57
80
|
- README.markdown
|
@@ -71,27 +94,26 @@ files:
|
|
71
94
|
- spec/utils_spec.rb
|
72
95
|
homepage: ''
|
73
96
|
licenses: []
|
97
|
+
metadata: {}
|
74
98
|
post_install_message:
|
75
99
|
rdoc_options: []
|
76
100
|
require_paths:
|
77
101
|
- lib
|
78
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
103
|
requirements:
|
81
104
|
- - ! '>='
|
82
105
|
- !ruby/object:Gem::Version
|
83
106
|
version: '0'
|
84
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
108
|
requirements:
|
87
109
|
- - ! '>='
|
88
110
|
- !ruby/object:Gem::Version
|
89
111
|
version: '0'
|
90
112
|
requirements: []
|
91
113
|
rubyforge_project: banktools-se
|
92
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.0.3
|
93
115
|
signing_key:
|
94
|
-
specification_version:
|
116
|
+
specification_version: 4
|
95
117
|
summary: Validate and normalize Swedish bank account numbers, plusgiro and bankgiro.
|
96
118
|
test_files:
|
97
119
|
- spec/account_spec.rb
|
@@ -99,3 +121,4 @@ test_files:
|
|
99
121
|
- spec/plusgiro_spec.rb
|
100
122
|
- spec/spec_helper.rb
|
101
123
|
- spec/utils_spec.rb
|
124
|
+
has_rdoc:
|