banktools-se 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +28 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/README.markdown +62 -59
- data/banktools-se.gemspec +0 -1
- data/lib/banktools-se/account/clearing_number.rb +15 -2
- data/lib/banktools-se/version.rb +1 -1
- metadata +4 -4
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f07fdb509f30138a506f6f6417ff304ed85500d08898e96c16d431b4f8c3ec3
|
4
|
+
data.tar.gz: 4582e2ed894b372b164d0634663a454aa36a7fc12fddaa65c3a322658daeca40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85df98a4cf73147671d52a66af1eb8af728e9610857b9a58a1f078642d33fe0386c973e375d964b47022aae44683f4e62b0313d4352a77434c827007bd83ff23
|
7
|
+
data.tar.gz: 46620b5b9b5f9f4af077bb93862669acbb4ae026ebccfd9cc462caf0711f4b67e14f01ce8ef4a36587c6964c3935530af637a851c7011f20c166300451861d2a
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby-version: ["3.0", "2.7", "2.6", "2.5"]
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
|
+
uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
- name: Install dependencies
|
25
|
+
run: bundle install
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rake
|
28
|
+
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 3.1.0
|
4
|
+
|
5
|
+
- Add more banks to the range in `BankTools::SE::Account::ClearingNumber`. See [#7]. Thanks, Milen Dimitrov!
|
6
|
+
|
3
7
|
## 3.0.1
|
4
8
|
|
5
9
|
- Fix deprecation error: "NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01."
|
@@ -11,3 +15,5 @@
|
|
11
15
|
## 2.6.3 and earlier
|
12
16
|
|
13
17
|
- Please see commit history.
|
18
|
+
|
19
|
+
[#7]: https://github.com/barsoom/banktools-se/pull/7
|
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Swedish bank tools
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Ruby CI](https://github.com/barsoom/banktools-se/actions/workflows/ci.yml/badge.svg)](https://github.com/barsoom/banktools-se/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
Ruby gem to validate, normalize/prettify and to some extent interpret
|
6
6
|
|
@@ -17,87 +17,90 @@ Inspired by [iulianu/iban-tools](https://github.com/iulianu/iban-tools). Please
|
|
17
17
|
|
18
18
|
## Usage
|
19
19
|
|
20
|
-
|
20
|
+
```ruby
|
21
|
+
# Bankgiro
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
valid_account = BankTools::SE::Bankgiro.new(" 5402968 1 ")
|
24
|
+
valid_account.valid? # => true
|
25
|
+
valid_account.errors # => []
|
26
|
+
valid_account.normalize # => "5402-9681"
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
bad_account = BankTools::SE::Bankgiro.new(" 1X ")
|
29
|
+
bad_account.valid? # => false
|
30
|
+
bad_account.errors # => [ :too_short, :invalid_characters, :bad_checksum ]
|
31
|
+
bad_account.normalize # => " 1 "
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# 90-konto
|
34
|
+
fundraising_account = BankTools::SE::Bankgiro.new("902-0033")
|
35
|
+
fundraising_account.fundraising? # => true
|
35
36
|
|
36
|
-
|
37
|
+
# OCR
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
BankTools::SE::OCR.from_number("123") # => "1230"
|
40
|
+
BankTools::SE::OCR.from_number("123", length_digit: true) # => "12351"
|
41
|
+
BankTools::SE::OCR.from_number("123", length_digit: true, pad: "0") # => "123067"
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
BankTools::SE::OCR.to_number("1230") # => "123"
|
44
|
+
BankTools::SE::OCR.to_number("123067", length_digit: true, pad: "0") # => "123"
|
45
|
+
BankTools::SE::OCR.to_number("1230", length_digit: true, pad: "0") # Raises exception because there's no length digit or padding.
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
# This feature is intended to try to find all OCR numbers in a noisy bank statement string.
|
48
|
+
# By design it may find too many numbers (e.g. valid substrings of other numbers), so you should check results against actual outstanding invoices.
|
49
|
+
# By default, it excludes OCRs shorter than 4 digits and longer than 18 digits, but this limit can be specified per below.
|
50
|
+
BankTools::SE::OCR.find_all_in_string("OCR1230 and ref4564 and 7890") # => [ "1230", "4564", … ]
|
51
|
+
BankTools::SE::OCR.find_all_in_string("1230 and 123067", length_digit: true, pad: "0") # => [ "123067" ]
|
52
|
+
BankTools::SE::OCR.find_all_in_string("00 and 18 and 1230", min_length: 2, max_length: 3) # => [ "00", "018", "18" ]
|
52
53
|
|
53
|
-
|
54
|
+
# Plusgiro
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
valid_account = BankTools::SE::Plusgiro.new("2865434")
|
57
|
+
valid_account.valid? # => true
|
58
|
+
valid_account.errors # => []
|
59
|
+
valid_account.normalize # => "28 65 53-4"
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
bad_account = BankTools::SE::Plusgiro.new(" 1X ")
|
62
|
+
bad_account.valid? # => false
|
63
|
+
bad_account.errors # => [ :too_short, :invalid_characters, :bad_checksum ]
|
64
|
+
bad_account.normalize # => " 1 "
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
# 90-konto
|
67
|
+
fundraising_account = BankTools::SE::Plusgiro.new("90 20 03-3")
|
68
|
+
fundraising_account.fundraising? # => true
|
68
69
|
|
69
70
|
|
70
|
-
|
71
|
+
# Bank account
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
valid_account = BankTools::SE::Account.new("11000000000")
|
74
|
+
valid_account.valid? # => true
|
75
|
+
valid_account.errors # => []
|
76
|
+
valid_account.normalize # => "1100-0000000"
|
77
|
+
valid_account.bank # => "Nordea"
|
78
|
+
valid_account.clearing_number # => "1100"
|
79
|
+
valid_account.serial_number # => "0000000"
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
bad_account = BankTools::SE::Account.new(" 0000-0000000X ")
|
82
|
+
bad_account.valid? # => false
|
83
|
+
bad_account.errors # => [ :invalid_characters, :unknown_clearing_number ]
|
84
|
+
bad_account.bank # => nil
|
85
|
+
bad_account.normalize # => " 0000-0000000X "
|
85
86
|
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
BankTools::SE::Errors::TOO_SHORT # => :too_short
|
90
|
-
BankTools::SE::Errors::TOO_LONG # => :too_long
|
91
|
-
BankTools::SE::Errors::INVALID_CHARACTERS # => :invalid_characters
|
92
|
-
BankTools::SE::Errors::BAD_CHECKSUM # => :bad_checksum
|
93
|
-
BankTools::SE::Errors::UNKNOWN_CLEARING_NUMBER # => :unknown_clearing_number
|
88
|
+
# Error codes
|
94
89
|
|
90
|
+
BankTools::SE::Errors::TOO_SHORT # => :too_short
|
91
|
+
BankTools::SE::Errors::TOO_LONG # => :too_long
|
92
|
+
BankTools::SE::Errors::INVALID_CHARACTERS # => :invalid_characters
|
93
|
+
BankTools::SE::Errors::BAD_CHECKSUM # => :bad_checksum
|
94
|
+
BankTools::SE::Errors::UNKNOWN_CLEARING_NUMBER # => :unknown_clearing_number
|
95
|
+
```
|
95
96
|
|
96
97
|
## Installation
|
97
98
|
|
98
99
|
Add this line to your application's Gemfile:
|
99
100
|
|
100
|
-
|
101
|
+
```ruby
|
102
|
+
gem 'banktools-se'
|
103
|
+
```
|
101
104
|
|
102
105
|
And then execute:
|
103
106
|
|
data/banktools-se.gemspec
CHANGED
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
15
|
s.require_paths = ["lib"]
|
17
16
|
|
18
17
|
s.add_development_dependency "rake"
|
@@ -11,11 +11,11 @@ module BankTools
|
|
11
11
|
2300..2399 => { name: "Ålandsbanken" },
|
12
12
|
2400..2499 => { name: "Danske Bank" },
|
13
13
|
3000..3299 => { name: "Nordea" },
|
14
|
-
3300..3300 => { name: "Nordea", serial_number_length: 10, luhn_for_serial: true },
|
14
|
+
3300..3300 => { name: "Nordea", serial_number_length: 10, luhn_for_serial: true }, # Personkonto.
|
15
15
|
3301..3399 => { name: "Nordea" },
|
16
16
|
3400..3409 => { name: "Länsförsäkringar Bank" },
|
17
17
|
3410..3781 => { name: "Nordea" },
|
18
|
-
3782..3782 => { name: "Nordea", serial_number_length: 10, luhn_for_serial: true },
|
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
|
6000..6999 => { name: "Handelsbanken", serial_number_length: 8..9 },
|
@@ -45,6 +45,19 @@ module BankTools
|
|
45
45
|
9500..9549 => { name: "Nordea/Plusgirot", serial_number_length: 1..10 },
|
46
46
|
9550..9569 => { name: "Avanza Bank" },
|
47
47
|
9570..9579 => { name: "Sparbanken Syd", serial_number_length: 10, zerofill: true },
|
48
|
+
9630..9639 => { name: "Lån og Spar Bank Sverige" },
|
49
|
+
9640..9649 => { name: "Nordax Bank AB" },
|
50
|
+
9650..9659 => { name: "MedMera Bank" },
|
51
|
+
9660..9669 => { name: "Svea Bank" },
|
52
|
+
9670..9679 => { name: "JAK Medlemsbank" },
|
53
|
+
9680..9689 => { name: "Bluestep Finance" },
|
54
|
+
9690..9699 => { name: "Folkia" },
|
55
|
+
9700..9709 => { name: "Ekobanken" },
|
56
|
+
9720..9729 => { name: "Netfonds Bank (ub)" },
|
57
|
+
9750..9759 => { name: "Northmill Bank" },
|
58
|
+
9770..9779 => { name: "FTCS" },
|
59
|
+
9780..9789 => { name: "Klarna Bank" },
|
60
|
+
9955..9955 => { name: "Kommuninvest" },
|
48
61
|
9960..9969 => { name: "Nordea/Plusgirot", serial_number_length: 1..10 },
|
49
62
|
}
|
50
63
|
end
|
data/lib/banktools-se/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banktools-se
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -73,8 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/workflows/ci.yml"
|
76
77
|
- ".gitignore"
|
77
|
-
- ".travis.yml"
|
78
78
|
- CHANGELOG.md
|
79
79
|
- Gemfile
|
80
80
|
- README.markdown
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.2.25
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Validate and normalize Swedish bank account numbers, plusgiro and bankgiro.
|
data/.travis.yml
DELETED