bankgiro_inbetalningar 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rspec +0 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +64 -0
- data/Rakefile +2 -0
- data/bankgiro_inbetalningar.gemspec +19 -0
- data/lib/bankgiro_inbetalningar.rb +11 -0
- data/lib/bankgiro_inbetalningar/bgmax_line.rb +27 -0
- data/lib/bankgiro_inbetalningar/parser.rb +247 -0
- data/lib/bankgiro_inbetalningar/version.rb +3 -0
- data/spec/bankgiro_inbetalningar/bgmax_line_spec.rb +27 -0
- data/spec/bankgiro_inbetalningar/parser_spec.rb +92 -0
- data/spec/bankgiro_inbetalningar_spec.rb +17 -0
- data/spec/fixtures/BgMaxfil4.txt +69 -0
- data/spec/fixtures/BgMaxfil4_broken.txt +69 -0
- data/spec/fixtures/minimal.txt +5 -0
- data/spec/spec_helper.rb +6 -0
- metadata +88 -0
data/.gitignore
ADDED
data/.rspec
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Your Name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# BankgiroInbetalningar
|
2
|
+
|
3
|
+
This gem parses [Bankgirot's](http://bankgirot.se) payments received files
|
4
|
+
([BgMax](http://www.bgc.se/Default____5641.aspx)) and returns the payment
|
5
|
+
data in a relatively provider-agnostic format.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'bankgiro_inbetalningar'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bankgiro_inbetalningar
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Use the convenience method `BankgiroInbetalningar.parse` to parse a file:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
res = BankgiroInbetalningar.parse('BgMaxfil4.txt')
|
27
|
+
raise "oops" unless res.valid?
|
28
|
+
# You can process deposit by deposit...
|
29
|
+
res.deposits.each do |d|
|
30
|
+
puts "Received to BG #{d.bgno}:"
|
31
|
+
d.payments.each do |p|
|
32
|
+
puts "%10.2f %s" % [(p.cents / 100.0), p.currency]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# ...or payment by payment
|
37
|
+
res.payments.each do |p|
|
38
|
+
puts "%10.2f %s" % [(p.cents / 100.0), p.currency]
|
39
|
+
puts "From #{p.payer.name}, #{p.payer.city}" if p.payer
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
See the specs for more details. Note that all text is in UTF-8, as it should be,
|
44
|
+
and not in ISO-8859-1 as Bankgirot prefers. It is the 21st century.
|
45
|
+
|
46
|
+
## Todo / Missing features
|
47
|
+
|
48
|
+
`BankgiroInbetalningar` works well enough for our needs, so there are no plans for
|
49
|
+
further development. Pull requests are welcome.
|
50
|
+
|
51
|
+
The gem has only been tested with `BgMaxfil4.txt`, the sample file for
|
52
|
+
users that have requested extended OCR registration. I see no reason
|
53
|
+
why it wouldn't work with other settings, but YMMV.
|
54
|
+
|
55
|
+
Some attributes in the files are not reported since we didn't need them.
|
56
|
+
I'll be happy to add them if you don't want to do it yourself.
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/bankgiro_inbetalningar/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["David Vrensk"]
|
6
|
+
gem.email = ["david@spnab.com"]
|
7
|
+
gem.description = %q{Parse BgMax transaction files from Bankgirot and return a simple data structure}
|
8
|
+
gem.summary = %q{Bankgirot has changes its file format, making the +rbankgiro+ gem unusable for new clients.}
|
9
|
+
gem.homepage = "https://github.com/icehouse/bankgiro_inbetalningar"
|
10
|
+
|
11
|
+
gem.add_development_dependency "rspec", '~> 2.9.0'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "bankgiro_inbetalningar"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = BankgiroInbetalningar::VERSION
|
19
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "bankgiro_inbetalningar/version"
|
2
|
+
require "bankgiro_inbetalningar/bgmax_line"
|
3
|
+
require "bankgiro_inbetalningar/parser"
|
4
|
+
|
5
|
+
module BankgiroInbetalningar
|
6
|
+
def self.parse(filename)
|
7
|
+
parser = Parser.new(filename)
|
8
|
+
parser.run
|
9
|
+
parser.result
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module BankgiroInbetalningar
|
2
|
+
class BgmaxLine
|
3
|
+
class << self
|
4
|
+
attr_reader :parsers
|
5
|
+
def inherited(klass)
|
6
|
+
lead = klass.name[/\d+/]
|
7
|
+
(@parsers ||= {})[lead] = klass
|
8
|
+
end
|
9
|
+
|
10
|
+
def field(name, position, format)
|
11
|
+
define_method name do
|
12
|
+
value = " #{@line}"[position]
|
13
|
+
case format
|
14
|
+
when 'N:h0', 'N:-'
|
15
|
+
value.sub(/^0+/,'').to_i
|
16
|
+
else
|
17
|
+
value.strip
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(line)
|
24
|
+
@line = line
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module BankgiroInbetalningar
|
4
|
+
class Parser
|
5
|
+
attr_accessor :result
|
6
|
+
|
7
|
+
def initialize(filename)
|
8
|
+
@filename = filename
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
@result = Result.new
|
13
|
+
parse_lines
|
14
|
+
ensure
|
15
|
+
@stream.close if @stream
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_lines
|
19
|
+
while @line = next_line
|
20
|
+
parse_line
|
21
|
+
record_line
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def next_line
|
26
|
+
stream.eof? ? nil : stream.readline
|
27
|
+
end
|
28
|
+
|
29
|
+
def stream
|
30
|
+
@stream ||= File.open(@filename, 'r:ISO-8859-1:UTF-8')
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_line
|
34
|
+
if line_parser_class
|
35
|
+
line_parser = line_parser_class.new(@line)
|
36
|
+
line_parser.update(@result)
|
37
|
+
else
|
38
|
+
# skip line
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def line_parser_class
|
43
|
+
BgmaxLine.parsers[@line[0..1]]
|
44
|
+
end
|
45
|
+
|
46
|
+
def record_line
|
47
|
+
if result.deposit && result.payment && payment_line?
|
48
|
+
result.payment.raw << @line
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def payment_line?
|
53
|
+
@line[0] == '2'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Tk01 < BgmaxLine
|
58
|
+
field :layout, 3..22, 'A:vb'
|
59
|
+
field :version, 23..24, 'N:h0'
|
60
|
+
field :timestamp, 25..44, 'N:-'
|
61
|
+
field :testflag, 45, 'A:-'
|
62
|
+
|
63
|
+
def update(result)
|
64
|
+
result.timestamp = timestamp
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Tk05 < BgmaxLine
|
69
|
+
field :bgno, 3..12, 'N:h0'
|
70
|
+
field :currency, 23..25, 'A:b'
|
71
|
+
|
72
|
+
def update(result)
|
73
|
+
result.new_deposit
|
74
|
+
result.deposit.bgno = bgno
|
75
|
+
result.deposit.currency = currency
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Tk15 < BgmaxLine
|
80
|
+
field :deposit_account, 3..37, 'N:h0'
|
81
|
+
field :date, 38..45, 'N:-'
|
82
|
+
field :date_year, 38..41, 'N:-'
|
83
|
+
field :date_month, 42..43, 'N:h0'
|
84
|
+
field :date_day, 44..45, 'N:h0'
|
85
|
+
field :deposit_no, 46..50, 'N:h0'
|
86
|
+
field :cents, 51..68, 'N:h0'
|
87
|
+
|
88
|
+
def update(result)
|
89
|
+
deposit = result.deposit
|
90
|
+
deposit.date = Date.new(date_year, date_month, date_day)
|
91
|
+
deposit.payments.each { |p| p.date = deposit.date }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Tk20 < BgmaxLine
|
96
|
+
field :sender_bgno, 3..12, 'N:h0'
|
97
|
+
field :reference, 13..37, 'A:-'
|
98
|
+
field :cents, 38..55, 'N:h0'
|
99
|
+
field :reference_type, 56, 'N:-'
|
100
|
+
field :number, 58..69, 'A:-'
|
101
|
+
field :has_image, 70, 'N:-'
|
102
|
+
|
103
|
+
def update(result)
|
104
|
+
payment = result.new_payment
|
105
|
+
payment.cents = cents
|
106
|
+
payment.currency = result.deposit.currency
|
107
|
+
payment.references << reference if reference_type == 2
|
108
|
+
payment.sender_bgno = sender_bgno
|
109
|
+
payment.number = number
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class Tk22 < BgmaxLine
|
114
|
+
field :reference, 13..37, 'A:-'
|
115
|
+
field :cents, 38..55, 'N:h0'
|
116
|
+
field :reference_type, 56, 'N:-'
|
117
|
+
|
118
|
+
def update(result)
|
119
|
+
result.payment.references << reference if [2,5].include?(reference_type)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class Tk25 < BgmaxLine
|
124
|
+
field :text, 3..52, 'A:-'
|
125
|
+
def update(result)
|
126
|
+
payment = result.payment
|
127
|
+
payment.text = [payment.text, text].compact.join("\n")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class Tk26 < BgmaxLine
|
132
|
+
field :name, 3..37, 'A:vb'
|
133
|
+
field :extra_name, 38..72, 'A:vb'
|
134
|
+
|
135
|
+
def update(result)
|
136
|
+
payer = result.payment.payer!
|
137
|
+
payer.name = name
|
138
|
+
payer.extra_name = extra_name
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class Tk27 < BgmaxLine
|
143
|
+
field :street, 3..37, 'A:vb'
|
144
|
+
field :postal_code, 38..46, 'A:vb'
|
145
|
+
|
146
|
+
def update(result)
|
147
|
+
payer = result.payment.payer!
|
148
|
+
payer.street = street
|
149
|
+
payer.postal_code = postal_code
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
class Tk28 < BgmaxLine
|
154
|
+
field :city, 3..37, 'A:vb'
|
155
|
+
field :country, 38..72, 'A:vb'
|
156
|
+
field :country_code, 73..74, 'A:vb'
|
157
|
+
|
158
|
+
def update(result)
|
159
|
+
payer = result.payment.payer!
|
160
|
+
payer.city = city
|
161
|
+
payer.country = country if country != ''
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
class Tk29 < BgmaxLine
|
166
|
+
field :org_no, 3..14, 'N:h0'
|
167
|
+
|
168
|
+
def update(result)
|
169
|
+
payer = result.payment.payer!
|
170
|
+
payer.org_no = org_no
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class Tk70 < BgmaxLine
|
175
|
+
field :payments_count, 3..10, 'N:h0'
|
176
|
+
field :deposits_count, 27..34, 'N:h0'
|
177
|
+
|
178
|
+
def update(result)
|
179
|
+
result.valid = true
|
180
|
+
unless result.payments.count == payments_count
|
181
|
+
result.valid = false
|
182
|
+
result.errors << "Found #{result.payments.count} payments but expected #{payments_count}"
|
183
|
+
end
|
184
|
+
unless result.deposits.count == deposits_count
|
185
|
+
result.valid = false
|
186
|
+
result.errors << "Found #{result.deposits.count} deposits but expected #{deposits_count}"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
class Result
|
193
|
+
attr_accessor :timestamp, :deposits, :valid, :errors
|
194
|
+
|
195
|
+
def initialize
|
196
|
+
@deposits = []
|
197
|
+
@errors = []
|
198
|
+
end
|
199
|
+
|
200
|
+
def valid?
|
201
|
+
valid
|
202
|
+
end
|
203
|
+
|
204
|
+
def new_deposit
|
205
|
+
@deposits << Deposit.new
|
206
|
+
deposit
|
207
|
+
end
|
208
|
+
|
209
|
+
def deposit
|
210
|
+
@deposits.last
|
211
|
+
end
|
212
|
+
|
213
|
+
def new_payment
|
214
|
+
deposit.payments << Payment.new
|
215
|
+
payment
|
216
|
+
end
|
217
|
+
|
218
|
+
def payment
|
219
|
+
deposit.payments.last
|
220
|
+
end
|
221
|
+
|
222
|
+
def payments
|
223
|
+
deposits.map { |d| d.payments }.flatten
|
224
|
+
end
|
225
|
+
|
226
|
+
class Deposit
|
227
|
+
attr_accessor :bgno, :currency, :payments, :date
|
228
|
+
def initialize
|
229
|
+
@payments = []
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
class Payment
|
234
|
+
attr_accessor :cents, :references, :currency, :raw, :payer, :sender_bgno, :text, :date, :number
|
235
|
+
def initialize
|
236
|
+
@references = []
|
237
|
+
@raw = "".force_encoding('iso-8859-1')
|
238
|
+
end
|
239
|
+
|
240
|
+
def payer!
|
241
|
+
@payer ||= Payer.new
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
Payer = Struct.new(:name, :extra_name, :street, :postal_code, :city, :country, :org_no)
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
module BankgiroInbetalningar
|
4
|
+
class Tk00 < BgmaxLine
|
5
|
+
field :currency, 3..5, 'A:h'
|
6
|
+
field :cents, 6..11, 'N:h0'
|
7
|
+
field :flag, 12, 'N:-'
|
8
|
+
end
|
9
|
+
describe BgmaxLine do
|
10
|
+
it "knows its children" do
|
11
|
+
BgmaxLine.parsers['00'].should == Tk00
|
12
|
+
end
|
13
|
+
context "fields" do
|
14
|
+
subject { Tk00.new("00SEK0001234") }
|
15
|
+
|
16
|
+
it "can be strings" do
|
17
|
+
subject.currency.should == 'SEK'
|
18
|
+
end
|
19
|
+
it "can be a 0-padded number" do
|
20
|
+
subject.cents.should == 123
|
21
|
+
end
|
22
|
+
it 'can be a numeric flag' do
|
23
|
+
subject.flag.should == 4
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
4
|
+
module BankgiroInbetalningar
|
5
|
+
describe Parser do
|
6
|
+
context "parsing sample file 4" do
|
7
|
+
let(:parser) { Parser.new(fixture_path('BgMaxfil4.txt')) }
|
8
|
+
let(:result) { parser.run ; parser.result }
|
9
|
+
|
10
|
+
it "returns valid results" do
|
11
|
+
result.should be_valid
|
12
|
+
end
|
13
|
+
|
14
|
+
it "finds 4 deposits" do
|
15
|
+
result.deposits.count.should == 4
|
16
|
+
end
|
17
|
+
it "finds 9 payments" do
|
18
|
+
result.payments.count.should == 9
|
19
|
+
end
|
20
|
+
|
21
|
+
context "simplest OCR payment" do
|
22
|
+
let(:payment) { result.payments[5] }
|
23
|
+
it "has one reference" do
|
24
|
+
payment.references.should == ['535765']
|
25
|
+
payment.currency.should == 'SEK'
|
26
|
+
payment.cents.should == 500_00
|
27
|
+
payment.raw.should == "200000000000 535765000000000000050000230000000000230 \r\n"
|
28
|
+
end
|
29
|
+
it "has a date" do
|
30
|
+
payment.date.should == Date.civil(2004,5,25)
|
31
|
+
end
|
32
|
+
it "has a number" do
|
33
|
+
payment.number.should == "000000000023"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "simple OCR payment with address" do
|
38
|
+
let(:payment) { result.payments[1] }
|
39
|
+
let(:payer) { payment.payer }
|
40
|
+
it "has one reference" do
|
41
|
+
payment.references.should == ['524967']
|
42
|
+
payment.currency.should == 'SEK'
|
43
|
+
payment.cents.should == 1900_00
|
44
|
+
payment.sender_bgno.should == 97012333
|
45
|
+
end
|
46
|
+
it "has a payer (in UTF-8!)" do
|
47
|
+
payer.name.should == "Olles färg AB"
|
48
|
+
payer.street.should == 'Lillagatan 3'
|
49
|
+
payer.postal_code.should == '12345'
|
50
|
+
payer.city.should == "Storåker"
|
51
|
+
payer.country.should be_nil
|
52
|
+
# TODO: talk to BGC and see if they really meant this org_no to have 9 digits.
|
53
|
+
payer.org_no.should == 550000432
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "OCR payment with several references and text" do
|
58
|
+
let(:payment) { result.payments[0] }
|
59
|
+
it "has four references" do
|
60
|
+
payment.references.should =~ %w[665869 657775 665661 665760]
|
61
|
+
end
|
62
|
+
it "has text" do
|
63
|
+
payment.text.should == "Betalning med extra refnr 665869 657775 665661\n665760"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "OCR payment with two good references, one bad and one revert" do
|
68
|
+
let(:payment) { result.payments[6] }
|
69
|
+
it "has three references" do
|
70
|
+
payment.references.should =~ %w[7495575 695668 8988777]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
context "parsing a broken sample file 4" do
|
76
|
+
let(:parser) { Parser.new(fixture_path('BgMaxfil4_broken.txt')) }
|
77
|
+
let(:result) { parser.run ; parser.result }
|
78
|
+
|
79
|
+
it "returns invalid results" do
|
80
|
+
result.should_not be_valid
|
81
|
+
end
|
82
|
+
|
83
|
+
it "reports the payments count as being off" do
|
84
|
+
result.errors.should include("Found 9 payments but expected 8")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "reports the deposits count as being off" do
|
88
|
+
result.errors.should include("Found 4 deposits but expected 5")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe BankgiroInbetalningar do
|
4
|
+
context "parsing a minimal file" do
|
5
|
+
subject { BankgiroInbetalningar.parse(fixture_path('minimal.txt')) }
|
6
|
+
|
7
|
+
it "finds the timestamp" do
|
8
|
+
subject.timestamp.should == "2004 05 25 173035 010331".gsub(' ','').to_i
|
9
|
+
end
|
10
|
+
it "finds 1 deposit" do
|
11
|
+
subject.deposits.count.should == 1
|
12
|
+
end
|
13
|
+
it "finds 1 payment" do
|
14
|
+
subject.deposits.first.payments.count.should == 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
01BGMAX 0120040525173035010331P
|
2
|
+
050009912346 SEK
|
3
|
+
200003783511 000000000000180000020001200000180
|
4
|
+
220003783511 665760000000000000000000220001200000180
|
5
|
+
220003783511 665869000000000000000000220001200000180
|
6
|
+
220003783511 665661000000000000000000220001200000180
|
7
|
+
220003783511 657775000000000000000000220001200000180
|
8
|
+
25Betalning med extra refnr 665869 657775 665661
|
9
|
+
25665760
|
10
|
+
26Kalles Pl�t AB
|
11
|
+
27Storgatan 2 12345
|
12
|
+
28Stor�ker
|
13
|
+
29005500001234
|
14
|
+
200097012333 524967000000000000190000210000000000190
|
15
|
+
26Olles f�rg AB
|
16
|
+
27Lillagatan 3 12345
|
17
|
+
28Stor�ker
|
18
|
+
2900550000432
|
19
|
+
15000000000000000000058410000010098232004052500056000000000000370000SEK00000002
|
20
|
+
050009912346 SEK
|
21
|
+
200001234567 000000000000200000030000000000201
|
22
|
+
220001234567 573964000000000000170000230000000000201
|
23
|
+
220001234567 573865000000000000030000230000000000201
|
24
|
+
26Berits Garn
|
25
|
+
27Storgatan 10 12345
|
26
|
+
28Stor�ker
|
27
|
+
29005500002222
|
28
|
+
15000000000000000000058410000010098232004052500057000000000000200000SEK00000001
|
29
|
+
050009912346 SEK
|
30
|
+
200097012333 525865000000000000050000210000000000210
|
31
|
+
26Olles f�rg AB
|
32
|
+
27Lillagatan 3 12345
|
33
|
+
28Stor�ker
|
34
|
+
29005500004322
|
35
|
+
200001234567 525766000000000000050000210000000000220
|
36
|
+
26Berits Garn
|
37
|
+
27Storgatan 10 12345
|
38
|
+
28Stor�ker
|
39
|
+
29005500002222
|
40
|
+
200000000000 535765000000000000050000230000000000230
|
41
|
+
200003783511 000000000000140000030000000000301
|
42
|
+
220003783511 7495575000000000000100000230000000000301
|
43
|
+
220003783511 695668000000000000050000230000000000301
|
44
|
+
2200037835118988777 000000000000040000530000000000301
|
45
|
+
230003783511 74450000000000000050000230000000000301
|
46
|
+
26Kalles Pl�t AB
|
47
|
+
27Storgatan 2 12345
|
48
|
+
28Stor�ker
|
49
|
+
29005500001234
|
50
|
+
15000000000000000000058410000010098232004052500058000000000000290000SEK00000004
|
51
|
+
050009912346 EUR
|
52
|
+
2000970123338012577,8013575 000000000000300000320000000000180
|
53
|
+
220097012333 8012577000000000000000000220000000000180
|
54
|
+
220097012333 8013575000000000000000000220000000000180
|
55
|
+
220097012333 8014573000000000000000000220000000000180
|
56
|
+
25 Faktura8014573
|
57
|
+
26Olles f�rg AB
|
58
|
+
27Lillagatan 3 12345
|
59
|
+
28Stor�ker
|
60
|
+
29005500001234
|
61
|
+
200001234567 525766000000000000100000210000000000190
|
62
|
+
26Berits Garn
|
63
|
+
27Storgatan 10 12345
|
64
|
+
28Stor�ker
|
65
|
+
29005500002222
|
66
|
+
15000000000000000000058410000010098232004052500059000000000000400000EUR00000002
|
67
|
+
7000000009000000000000001300000004
|
68
|
+
|
69
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
01BGMAX 0120040525173035010331P
|
2
|
+
050009912346 SEK
|
3
|
+
200003783511 000000000000180000020001200000180
|
4
|
+
220003783511 665760000000000000000000220001200000180
|
5
|
+
220003783511 665869000000000000000000220001200000180
|
6
|
+
220003783511 665661000000000000000000220001200000180
|
7
|
+
220003783511 657775000000000000000000220001200000180
|
8
|
+
25Betalning med extra refnr 665869 657775 665661
|
9
|
+
25665760
|
10
|
+
26Kalles Pl�t AB
|
11
|
+
27Storgatan 2 12345
|
12
|
+
28Stor�ker
|
13
|
+
29005500001234
|
14
|
+
200097012333 524967000000000000190000210000000000190
|
15
|
+
26Olles f�rg AB
|
16
|
+
27Lillagatan 3 12345
|
17
|
+
28Stor�ker
|
18
|
+
2900550000432
|
19
|
+
15000000000000000000058410000010098232004052500056000000000000370000SEK00000002
|
20
|
+
050009912346 SEK
|
21
|
+
200001234567 000000000000200000030000000000201
|
22
|
+
220001234567 573964000000000000170000230000000000201
|
23
|
+
220001234567 573865000000000000030000230000000000201
|
24
|
+
26Berits Garn
|
25
|
+
27Storgatan 10 12345
|
26
|
+
28Stor�ker
|
27
|
+
29005500002222
|
28
|
+
15000000000000000000058410000010098232004052500057000000000000200000SEK00000001
|
29
|
+
050009912346 SEK
|
30
|
+
200097012333 525865000000000000050000210000000000210
|
31
|
+
26Olles f�rg AB
|
32
|
+
27Lillagatan 3 12345
|
33
|
+
28Stor�ker
|
34
|
+
29005500004322
|
35
|
+
200001234567 525766000000000000050000210000000000220
|
36
|
+
26Berits Garn
|
37
|
+
27Storgatan 10 12345
|
38
|
+
28Stor�ker
|
39
|
+
29005500002222
|
40
|
+
200000000000 535765000000000000050000230000000000230
|
41
|
+
200003783511 000000000000140000030000000000301
|
42
|
+
220003783511 7495575000000000000100000230000000000301
|
43
|
+
220003783511 695668000000000000050000230000000000301
|
44
|
+
2200037835118988777 000000000000040000530000000000301
|
45
|
+
230003783511 74450000000000000050000230000000000301
|
46
|
+
26Kalles Pl�t AB
|
47
|
+
27Storgatan 2 12345
|
48
|
+
28Stor�ker
|
49
|
+
29005500001234
|
50
|
+
15000000000000000000058410000010098232004052500058000000000000290000SEK00000004
|
51
|
+
050009912346 EUR
|
52
|
+
2000970123338012577,8013575 000000000000300000320000000000180
|
53
|
+
220097012333 8012577000000000000000000220000000000180
|
54
|
+
220097012333 8013575000000000000000000220000000000180
|
55
|
+
220097012333 8014573000000000000000000220000000000180
|
56
|
+
25 Faktura8014573
|
57
|
+
26Olles f�rg AB
|
58
|
+
27Lillagatan 3 12345
|
59
|
+
28Stor�ker
|
60
|
+
29005500001234
|
61
|
+
200001234567 525766000000000000100000210000000000190
|
62
|
+
26Berits Garn
|
63
|
+
27Storgatan 10 12345
|
64
|
+
28Stor�ker
|
65
|
+
29005500002222
|
66
|
+
15000000000000000000058410000010098232004052500059000000000000400000EUR00000002
|
67
|
+
7000000008000000000000001300000005
|
68
|
+
|
69
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bankgiro_inbetalningar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Vrensk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.9.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.9.0
|
30
|
+
description: Parse BgMax transaction files from Bankgirot and return a simple data
|
31
|
+
structure
|
32
|
+
email:
|
33
|
+
- david@spnab.com
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- .rspec
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bankgiro_inbetalningar.gemspec
|
45
|
+
- lib/bankgiro_inbetalningar.rb
|
46
|
+
- lib/bankgiro_inbetalningar/bgmax_line.rb
|
47
|
+
- lib/bankgiro_inbetalningar/parser.rb
|
48
|
+
- lib/bankgiro_inbetalningar/version.rb
|
49
|
+
- spec/bankgiro_inbetalningar/bgmax_line_spec.rb
|
50
|
+
- spec/bankgiro_inbetalningar/parser_spec.rb
|
51
|
+
- spec/bankgiro_inbetalningar_spec.rb
|
52
|
+
- spec/fixtures/BgMaxfil4.txt
|
53
|
+
- spec/fixtures/BgMaxfil4_broken.txt
|
54
|
+
- spec/fixtures/minimal.txt
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
homepage: https://github.com/icehouse/bankgiro_inbetalningar
|
57
|
+
licenses: []
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.8.24
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Bankgirot has changes its file format, making the +rbankgiro+ gem unusable
|
80
|
+
for new clients.
|
81
|
+
test_files:
|
82
|
+
- spec/bankgiro_inbetalningar/bgmax_line_spec.rb
|
83
|
+
- spec/bankgiro_inbetalningar/parser_spec.rb
|
84
|
+
- spec/bankgiro_inbetalningar_spec.rb
|
85
|
+
- spec/fixtures/BgMaxfil4.txt
|
86
|
+
- spec/fixtures/BgMaxfil4_broken.txt
|
87
|
+
- spec/fixtures/minimal.txt
|
88
|
+
- spec/spec_helper.rb
|