total_in 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +9 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +22 -0
  8. data/README.md +21 -0
  9. data/Rakefile +1 -0
  10. data/lib/total_in/attribute_methods.rb +62 -0
  11. data/lib/total_in/contexts.rb +54 -0
  12. data/lib/total_in/document.rb +114 -0
  13. data/lib/total_in/line_handlers.rb +35 -0
  14. data/lib/total_in/line_parser.rb +42 -0
  15. data/lib/total_in/line_parsers.rb +80 -0
  16. data/lib/total_in/line_processors.rb +138 -0
  17. data/lib/total_in/parser.rb +48 -0
  18. data/lib/total_in/string_helpers.rb +10 -0
  19. data/lib/total_in/typecaster.rb +18 -0
  20. data/lib/total_in/version.rb +3 -0
  21. data/lib/total_in.rb +8 -0
  22. data/spec/fixtures/total_in_full.txt +61 -0
  23. data/spec/full_file_parse_spec.rb +501 -0
  24. data/spec/spec_helper.rb +20 -0
  25. data/spec/support/shared_examples_for_values_line_parsers.rb +15 -0
  26. data/spec/total_in/line_parsers/account_end_spec.rb +23 -0
  27. data/spec/total_in/line_parsers/account_start_spec.rb +24 -0
  28. data/spec/total_in/line_parsers/addresses_spec.rb +10 -0
  29. data/spec/total_in/line_parsers/deduction_start_spec.rb +50 -0
  30. data/spec/total_in/line_parsers/document_end_spec.rb +15 -0
  31. data/spec/total_in/line_parsers/document_start_spec.rb +32 -0
  32. data/spec/total_in/line_parsers/international_spec.rb +32 -0
  33. data/spec/total_in/line_parsers/locality_spec.rb +23 -0
  34. data/spec/total_in/line_parsers/messages_spec.rb +10 -0
  35. data/spec/total_in/line_parsers/names_spec.rb +11 -0
  36. data/spec/total_in/line_parsers/payment_start_spec.rb +45 -0
  37. data/spec/total_in/line_parsers/reference_numbers_spec.rb +11 -0
  38. data/spec/total_in/line_parsers/sender_account_spec.rb +23 -0
  39. data/spec/total_in/line_processors/account_end_spec.rb +35 -0
  40. data/spec/total_in/line_processors/account_start_spec.rb +50 -0
  41. data/spec/total_in/line_processors/addresses_spec.rb +44 -0
  42. data/spec/total_in/line_processors/deduction_start_spec.rb +54 -0
  43. data/spec/total_in/line_processors/document_end_spec.rb +32 -0
  44. data/spec/total_in/line_processors/document_start_spec.rb +29 -0
  45. data/spec/total_in/line_processors/international_spec.rb +46 -0
  46. data/spec/total_in/line_processors/locality_spec.rb +46 -0
  47. data/spec/total_in/line_processors/messages_spec.rb +25 -0
  48. data/spec/total_in/line_processors/names_spec.rb +45 -0
  49. data/spec/total_in/line_processors/payment_start_spec.rb +53 -0
  50. data/spec/total_in/line_processors/reference_numbers_spec.rb +24 -0
  51. data/spec/total_in/line_processors/sender_account_spec.rb +46 -0
  52. data/spec/total_in_spec.rb +13 -0
  53. data/total-in.gemspec +25 -0
  54. metadata +169 -0
@@ -0,0 +1,18 @@
1
+ require "time"
2
+
3
+ module TotalIn
4
+ module Typecaster
5
+ def self.cast value, type
6
+ casters.fetch(type).call(value) unless value == ""
7
+ end
8
+
9
+ def self.casters
10
+ {
11
+ integer: ->(value) { value.to_i },
12
+ time: ->(value) { Time.parse(value) },
13
+ date: ->(value) { Date.parse(value) },
14
+ string: ->(value) { value unless value.match(/\A0+\Z/) }
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module TotalIn
2
+ VERSION = "0.5.0"
3
+ end
data/lib/total_in.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "total_in/version"
2
+ require "total_in/parser"
3
+
4
+ module TotalIn
5
+ def self.parse text
6
+ Parser.new(text).result
7
+ end
8
+ end
@@ -0,0 +1,61 @@
1
+ 00TI222222 2011102504133012345601TL1TOTALIN
2
+ 1010181 SEK20111024
3
+ 2038952344444 00000000030255022222333334444451
4
+ 3038952345678 38952145778
5
+ 40FAKTURANR:38952344444 INTERN REF: 9780858
6
+ 40FAKTURANR:38952345678 38952145778ABC
7
+ 601234567 19999999999
8
+ 61TESTBOLAGET AB
9
+ 62GATAN 12
10
+ 6312345 TESTSTAD
11
+ 200000000000000000000000000 00000000042973522222333334444455
12
+ 40TACK FÖR LÅNET
13
+ 50FÖRETAGET AB FRISKVÅRDAVD.
14
+ 6099999999
15
+ 61FÖRETAGET AB
16
+ 62GATAN 7
17
+ 6388888 TESTORTEN
18
+ 200000000000000000000000000 0000000002109002222233333444446734523455
19
+ 40BETALNING FÖR VARA 123
20
+ 50TESTFABRIKEN AB
21
+ 51GATAN 22
22
+ 5211111 TESTVIKEN
23
+ 6098765433 29999999999
24
+ 61NORDEA BANK AB
25
+ 6310571 STOCKHOLM
26
+ 200000000000000000000000000 00000000014836522222333334444472
27
+ 601222211 19999999999
28
+ 2038952345555 00000000088000022222333334444423
29
+ 40FAKT 38952345555,FAKTURANR
30
+ 602232567 19999999999
31
+ 70000000000000000 000000000100000EUR000000088000
32
+ 25987654123 00000000005255022222333334444457
33
+ 40FAKTURA NR: 987654123 ABC KUNDNR: 123
34
+ 40ÅTERBETALNING
35
+ 601234567 19999999999
36
+ 61TESTBOLAGET AB
37
+ 62GATAN 12
38
+ 6312345 TESTSTAD
39
+ 90000000060000000000191900020111024001
40
+ 109690017 SEK20111024
41
+ 200000000000000000000000000 00000000092343411111222223333344
42
+ 40BETALNING AVSEENDE KÖP 110902
43
+ 601234567 19999999999
44
+ 61TESTBOLAGET AB
45
+ 62GATAN 12
46
+ 6312345 TESTSTAD
47
+ 2038952678900 00000000001050022222333334444477
48
+ 50TESTFÖRETAG ENHET 2.A
49
+ 6054321 19999999999
50
+ 61TESTFÖRETAG
51
+ 62TESTV 55
52
+ 6312345 TESTSTAD
53
+ 2038952678888 00000000002050022222333334444422
54
+ 3038952345999
55
+ 40FAKTNR=38952348888 OCH FAKTNR=38952345999
56
+ 6098765555 19999999999
57
+ 61TESTER AB
58
+ 62VÄGEN 1
59
+ 6388888 TESTORTEN
60
+ 90000000030000000000095443420111024001
61
+ 99000000000000061
@@ -0,0 +1,501 @@
1
+ require "total_in"
2
+
3
+ RSpec.describe TotalIn do
4
+ describe "parse" do
5
+ before :all do
6
+ @document = TotalIn.parse File.read File.join(__dir__, "fixtures/total_in_full.txt")
7
+ end
8
+
9
+ let :document do
10
+ @document
11
+ end
12
+
13
+ it "find the document meta data" do
14
+ expect(document.id).to eq "TI222222"
15
+ expect(document.created_at.strftime("%Y-%m-%d %H:%M:%S")).to eq "2011-10-25 12:34:56"
16
+ expect(document.delivery_number).to eq 1
17
+ expect(document.file_type).to eq "TL1"
18
+ expect(document.name).to eq "TOTALIN"
19
+ expect(document.number_of_lines).to eq 61
20
+ end
21
+
22
+ it "finds two accounts" do
23
+ expect(document.accounts.size).to eq 2
24
+ end
25
+
26
+ describe "first account" do
27
+ let :account do
28
+ document.accounts.first
29
+ end
30
+
31
+ it "stores the posting date" do
32
+ expect(account.date.to_s).to eq "2011-10-24"
33
+ end
34
+
35
+ it "knows the number of transactions" do
36
+ expect(account.number_of_transactions).to eq 6
37
+ end
38
+
39
+ it "has the total amount" do
40
+ expect(account.amount).to eq 1919000
41
+ end
42
+
43
+ it "has the statement reference" do
44
+ expect(account.statement_reference).to eq "20111024001"
45
+ end
46
+
47
+ describe "payments" do
48
+ it "finds all the payments" do
49
+ expect(account.payments.size).to eq 5
50
+ end
51
+
52
+ describe "first payment" do
53
+ let :payment do
54
+ account.payments[0]
55
+ end
56
+
57
+ it "parses the serial number" do
58
+ expect(payment.serial_number).to eq 22222333334444451
59
+ end
60
+
61
+ it "do not have a receiving_bankgiro_number" do
62
+ expect(payment.receiving_bankgiro_number).to be nil
63
+ end
64
+
65
+ it "extracts the amount in cents" do
66
+ expect(payment.amount).to eq(302550)
67
+ end
68
+
69
+ it "finds all reference numbers" do
70
+ expect(payment.reference_numbers).to eq [
71
+ "38952344444",
72
+ "38952345678",
73
+ "38952145778"
74
+ ]
75
+ end
76
+
77
+ it "parses all the messages" do
78
+ expected_message = [
79
+ "FAKTURANR:38952344444",
80
+ "INTERN REF: 9780858",
81
+ "FAKTURANR:38952345678",
82
+ "38952145778ABC"
83
+ ].join("\n")
84
+
85
+ expect(payment.message).to eq expected_message
86
+ end
87
+
88
+ describe "#sender_account" do
89
+ let :sender_account do
90
+ payment.sender_account
91
+ end
92
+
93
+ it "parses the sender account" do
94
+ expect(sender_account.account_number).to eq "1234567"
95
+ expect(sender_account.origin_code).to eq 1
96
+ expect(sender_account.company_organization_number).to eq "9999999999"
97
+ expect(sender_account.name).to eq "TESTBOLAGET AB"
98
+ expect(sender_account.address).to eq "GATAN 12"
99
+ expect(sender_account.postal_code).to eq "12345"
100
+ expect(sender_account.city).to eq "TESTSTAD"
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "second payment" do
106
+ let :payment do
107
+ account.payments[1]
108
+ end
109
+
110
+ it "does not have any reference numbers" do
111
+ expect(payment.reference_numbers).to eq []
112
+ end
113
+
114
+ it "parses the serial number" do
115
+ expect(payment.serial_number).to eq 22222333334444455
116
+ end
117
+
118
+ it "parses the amount in cents" do
119
+ expect(payment.amount).to eq 429735
120
+ end
121
+
122
+ it "do not have a receiving_bankgiro_number" do
123
+ expect(payment.receiving_bankgiro_number).to be nil
124
+ end
125
+
126
+ it "parses the message" do
127
+ expect(payment.message).to eq "TACK FÖR LÅNET"
128
+ end
129
+
130
+ it "has a sender" do
131
+ sender = payment.sender
132
+ expect(sender.name).to eq "FÖRETAGET AB FRISKVÅRDAVD."
133
+ end
134
+
135
+ it "parses the sender account" do
136
+ sender_account = payment.sender_account
137
+
138
+ expect(sender_account.account_number).to eq "99999999"
139
+ expect(sender_account.origin_code).to be nil
140
+ expect(sender_account.company_organization_number).to be nil
141
+ expect(sender_account.name).to eq "FÖRETAGET AB"
142
+ expect(sender_account.address).to eq "GATAN 7"
143
+ expect(sender_account.postal_code).to eq "88888"
144
+ expect(sender_account.city).to eq "TESTORTEN"
145
+ end
146
+ end
147
+
148
+ describe "third payment" do
149
+ let :payment do
150
+ account.payments[2]
151
+ end
152
+
153
+ it "does not have any reference numbers" do
154
+ expect(payment.reference_numbers).to eq []
155
+ end
156
+
157
+ it "parses the serial number" do
158
+ expect(payment.serial_number).to eq 22222333334444467
159
+ end
160
+
161
+ it "parses the amount in cents" do
162
+ expect(payment.amount).to eq 210900
163
+ end
164
+
165
+ it "do not have a receiving_bankgiro_number" do
166
+ expect(payment.receiving_bankgiro_number).to eq "34523455"
167
+ end
168
+
169
+ it "parses the message" do
170
+ expect(payment.message).to eq "BETALNING FÖR VARA 123"
171
+ end
172
+
173
+ it "has a sender" do
174
+ sender = payment.sender
175
+ expect(sender.name).to eq "TESTFABRIKEN AB"
176
+ expect(sender.address).to eq "GATAN 22"
177
+ expect(sender.postal_code).to eq "11111"
178
+ expect(sender.city).to eq "TESTVIKEN"
179
+ end
180
+
181
+ it "parses the sender account" do
182
+ sender_account = payment.sender_account
183
+
184
+ expect(sender_account.account_number).to eq "98765433"
185
+ expect(sender_account.origin_code).to eq 2
186
+ expect(sender_account.company_organization_number).to eq "9999999999"
187
+ expect(sender_account.name).to eq "NORDEA BANK AB"
188
+ expect(sender_account.address).to be nil
189
+ expect(sender_account.postal_code).to eq "10571"
190
+ expect(sender_account.city).to eq "STOCKHOLM"
191
+ end
192
+ end
193
+
194
+ describe "fourth payment" do
195
+ let :payment do
196
+ account.payments[3]
197
+ end
198
+
199
+ it "does not have any reference numbers" do
200
+ expect(payment.reference_numbers).to eq []
201
+ end
202
+
203
+ it "parses the serial number" do
204
+ expect(payment.serial_number).to eq 22222333334444472
205
+ end
206
+
207
+ it "parses the amount in cents" do
208
+ expect(payment.amount).to eq 148365
209
+ end
210
+
211
+ it "do not have a receiving_bankgiro_number" do
212
+ expect(payment.receiving_bankgiro_number).to be nil
213
+ end
214
+
215
+ it "parses the message" do
216
+ expect(payment.message).to be nil
217
+ end
218
+
219
+ it "has no sender" do
220
+ expect(payment.sender).to be nil
221
+ end
222
+
223
+ it "parses the sender account" do
224
+ sender_account = payment.sender_account
225
+
226
+ expect(sender_account.account_number).to eq "1222211"
227
+ expect(sender_account.origin_code).to eq 1
228
+ expect(sender_account.company_organization_number).to eq "9999999999"
229
+ expect(sender_account.name).to be nil
230
+ expect(sender_account.address).to be nil
231
+ expect(sender_account.postal_code).to be nil
232
+ expect(sender_account.city).to be nil
233
+ end
234
+ end
235
+
236
+ describe "fifth payment" do
237
+ let :payment do
238
+ account.payments[4]
239
+ end
240
+
241
+ it "does not have any reference numbers" do
242
+ expect(payment.reference_numbers).to eq ["38952345555"]
243
+ end
244
+
245
+ it "parses the serial number" do
246
+ expect(payment.serial_number).to eq 22222333334444423
247
+ end
248
+
249
+ it "parses the amount in cents" do
250
+ expect(payment.amount).to eq 880000
251
+ end
252
+
253
+ it "do not have a receiving_bankgiro_number" do
254
+ expect(payment.receiving_bankgiro_number).to be nil
255
+ end
256
+
257
+ it "parses the message" do
258
+ expect(payment.message).to eq "FAKT 38952345555,FAKTURANR"
259
+ end
260
+
261
+ it "has no sender" do
262
+ expect(payment.sender).to be nil
263
+ end
264
+
265
+ it "parses the sender account" do
266
+ sender_account = payment.sender_account
267
+
268
+ expect(sender_account.account_number).to eq "2232567"
269
+ expect(sender_account.origin_code).to eq 1
270
+ expect(sender_account.company_organization_number).to eq "9999999999"
271
+ expect(sender_account.name).to be nil
272
+ expect(sender_account.address).to be nil
273
+ expect(sender_account.postal_code).to be nil
274
+ expect(sender_account.city).to be nil
275
+ end
276
+
277
+ it "is an international payment" do
278
+ expect(payment.international?).to be true
279
+ expect(payment.international.cost).to eq 0
280
+ expect(payment.international.cost_currency).to be nil
281
+ expect(payment.international.amount).to eq 100000
282
+ expect(payment.international.amount_currency).to eq "EUR"
283
+ expect(payment.international.exchange_rate).to eq 88000
284
+ end
285
+ end
286
+ end
287
+
288
+ describe "deductions" do
289
+ it "finds one deduction" do
290
+ expect(account.deductions.size).to eq 1
291
+ end
292
+
293
+ let :deduction do
294
+ account.deductions.first
295
+ end
296
+
297
+ it "parses the amount" do
298
+ expect(deduction.amount).to eq 52550
299
+ end
300
+
301
+ it "has no receiving bankgiro number" do
302
+ expect(deduction.receiving_bankgiro_number).to be nil
303
+ end
304
+
305
+ it "has no code" do
306
+ expect(deduction.code).to be nil
307
+ end
308
+
309
+ it "has one reference number" do
310
+ expect(deduction.reference_numbers).to eq ["987654123"]
311
+ end
312
+
313
+ it "finds all messages" do
314
+ expected_message = [
315
+ "FAKTURA NR: 987654123 ABC",
316
+ "KUNDNR: 123",
317
+ "ÅTERBETALNING"
318
+ ].join "\n"
319
+
320
+ expect(deduction.message).to eq expected_message
321
+ end
322
+
323
+ it "parses the sender account" do
324
+ sender_account = deduction.sender_account
325
+
326
+ expect(sender_account.account_number).to eq "1234567"
327
+ expect(sender_account.origin_code).to eq 1
328
+ expect(sender_account.company_organization_number).to eq "9999999999"
329
+ expect(sender_account.name).to eq "TESTBOLAGET AB"
330
+ expect(sender_account.address).to eq "GATAN 12"
331
+ expect(sender_account.postal_code).to eq "12345"
332
+ expect(sender_account.city).to eq "TESTSTAD"
333
+ end
334
+ end
335
+ end
336
+
337
+ describe "second account" do
338
+ let :account do
339
+ document.accounts.last
340
+ end
341
+
342
+ it "knows the number of transactions" do
343
+ expect(account.number_of_transactions).to eq 3
344
+ end
345
+
346
+ it "stores the posting date" do
347
+ expect(account.date.to_s).to eq "2011-10-24"
348
+ end
349
+
350
+ it "has the total amount" do
351
+ expect(account.amount).to eq 954434
352
+ end
353
+
354
+ it "has the statement reference" do
355
+ expect(account.statement_reference).to eq "20111024001"
356
+ end
357
+
358
+ describe "payments" do
359
+ it "finds all the payments" do
360
+ expect(account.payments.size).to eq 3
361
+ end
362
+
363
+ describe "first payment" do
364
+ let :payment do
365
+ account.payments[0]
366
+ end
367
+
368
+ it "parses the serial number" do
369
+ expect(payment.serial_number).to eq 11111222223333344
370
+ end
371
+
372
+ it "do not have a receiving_bankgiro_number" do
373
+ expect(payment.receiving_bankgiro_number).to be nil
374
+ end
375
+
376
+ it "extracts the amount in cents" do
377
+ expect(payment.amount).to eq(923434)
378
+ end
379
+
380
+ it "has no reference numbers" do
381
+ expect(payment.reference_numbers).to eq []
382
+ end
383
+
384
+ it "parses all the messages" do
385
+ expect(payment.message).to eq "BETALNING AVSEENDE KÖP 110902"
386
+ end
387
+
388
+ describe "#sender_account" do
389
+ let :sender_account do
390
+ payment.sender_account
391
+ end
392
+
393
+ it "parses the sender account" do
394
+ expect(sender_account.account_number).to eq "1234567"
395
+ expect(sender_account.origin_code).to eq 1
396
+ expect(sender_account.company_organization_number).to eq "9999999999"
397
+ expect(sender_account.name).to eq "TESTBOLAGET AB"
398
+ expect(sender_account.address).to eq "GATAN 12"
399
+ expect(sender_account.postal_code).to eq "12345"
400
+ expect(sender_account.city).to eq "TESTSTAD"
401
+ end
402
+ end
403
+ end
404
+
405
+ describe "second payment" do
406
+ let :payment do
407
+ account.payments[1]
408
+ end
409
+
410
+ it "does not have any reference numbers" do
411
+ expect(payment.reference_numbers).to eq [
412
+ "38952678900",
413
+ ]
414
+ end
415
+
416
+ it "parses the serial number" do
417
+ expect(payment.serial_number).to eq 22222333334444477
418
+ end
419
+
420
+ it "parses the amount in cents" do
421
+ expect(payment.amount).to eq 10500
422
+ end
423
+
424
+ it "do not have a receiving_bankgiro_number" do
425
+ expect(payment.receiving_bankgiro_number).to be nil
426
+ end
427
+
428
+ it "has no message" do
429
+ expect(payment.message).to be nil
430
+ end
431
+
432
+ it "has a sender" do
433
+ sender = payment.sender
434
+ expect(sender.name).to eq "TESTFÖRETAG ENHET 2.A"
435
+ end
436
+
437
+ it "parses the sender account" do
438
+ sender_account = payment.sender_account
439
+
440
+ expect(sender_account.account_number).to eq "54321"
441
+ expect(sender_account.origin_code).to eq 1
442
+ expect(sender_account.company_organization_number).to eq "9999999999"
443
+ expect(sender_account.name).to eq "TESTFÖRETAG"
444
+ expect(sender_account.address).to eq "TESTV 55"
445
+ expect(sender_account.postal_code).to eq "12345"
446
+ expect(sender_account.city).to eq "TESTSTAD"
447
+ end
448
+ end
449
+
450
+ describe "third payment" do
451
+ let :payment do
452
+ account.payments[2]
453
+ end
454
+
455
+ it "does not have any reference numbers" do
456
+ expect(payment.reference_numbers).to eq [
457
+ "38952678888",
458
+ "38952345999"
459
+ ]
460
+ end
461
+
462
+ it "parses the serial number" do
463
+ expect(payment.serial_number).to eq 22222333334444422
464
+ end
465
+
466
+ it "parses the amount in cents" do
467
+ expect(payment.amount).to eq 20500
468
+ end
469
+
470
+ it "do not have a receiving_bankgiro_number" do
471
+ expect(payment.receiving_bankgiro_number).to be nil
472
+ end
473
+
474
+ it "parses the message" do
475
+ expect(payment.message).to eq "FAKTNR=38952348888 OCH\nFAKTNR=38952345999"
476
+ end
477
+
478
+ it "has no sender" do
479
+ expect(payment.sender).to be nil
480
+ end
481
+
482
+ it "parses the sender account" do
483
+ sender_account = payment.sender_account
484
+
485
+ expect(sender_account.account_number).to eq "98765555"
486
+ expect(sender_account.origin_code).to eq 1
487
+ expect(sender_account.company_organization_number).to eq "9999999999"
488
+ expect(sender_account.name).to eq "TESTER AB"
489
+ expect(sender_account.address).to eq "VÄGEN 1"
490
+ expect(sender_account.postal_code).to eq "88888"
491
+ expect(sender_account.city).to eq "TESTORTEN"
492
+ end
493
+ end
494
+ end
495
+
496
+ it "has no deductions" do
497
+ expect(account.deductions.size).to eq 0
498
+ end
499
+ end
500
+ end
501
+ end
@@ -0,0 +1,20 @@
1
+ if ENV["CI"]
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
6
+ RSpec.configure do |config|
7
+ config.order = :random
8
+ Kernel.srand config.seed
9
+
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.syntax = :expect
12
+ end
13
+
14
+ config.mock_with :rspec do |mocks|
15
+ mocks.syntax = :expect
16
+ mocks.verify_partial_doubles = true
17
+ end
18
+ end
19
+
20
+ Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
@@ -0,0 +1,15 @@
1
+ RSpec.shared_examples "a values line parser" do
2
+ describe "#values" do
3
+ it "finds first value" do
4
+ line = described_class.new " 847c7f90402aa750a7e257ed149f10834cy "
5
+
6
+ expect(line.values).to eq ["847c7f90402aa750a7e257ed149f10834cy"]
7
+ end
8
+
9
+ it "finds both values" do
10
+ line = described_class.new " 847c7f90402aa750a7e257ed149f10834cyf410cae4e8d1a5574y20c78702907a47f39 "
11
+
12
+ expect(line.values).to eq ["847c7f90402aa750a7e257ed149f10834cy", "f410cae4e8d1a5574y20c78702907a47f39"]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ require "total_in/line_parsers"
2
+
3
+ module TotalIn
4
+ module LineParsers
5
+ RSpec.describe AccountEnd do
6
+ let :account_end do
7
+ AccountEnd.new "90000000260000000000191900020111024001"
8
+ end
9
+
10
+ it "parses the number of tranactions" do
11
+ expect(account_end.number_of_transactions).to eq 26
12
+ end
13
+
14
+ it "parses the amount" do
15
+ expect(account_end.amount).to eq 1919000
16
+ end
17
+
18
+ it "parses the statement reference" do
19
+ expect(account_end.statement_reference).to eq "20111024001"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require "total_in/line_parsers"
2
+
3
+ module TotalIn
4
+ module LineParsers
5
+ RSpec.describe AccountStart do
6
+ let :account_start do
7
+ AccountStart.new "1010181 SEK20111024"
8
+ end
9
+
10
+ it "parses the account number" do
11
+ expect(account_start.account_number).to eq "10181"
12
+ end
13
+
14
+ it "parses the currency" do
15
+ expect(account_start.currency).to eq "SEK"
16
+ end
17
+
18
+ it "parses the posting date" do
19
+ expect(account_start.date).to be_a Date
20
+ expect(account_start.date.to_s).to eq "2011-10-24"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ require "support/shared_examples_for_values_line_parsers"
2
+ require "total_in/line_parsers"
3
+
4
+ module TotalIn
5
+ module LineParsers
6
+ RSpec.describe Addresses do
7
+ it_behaves_like "a values line parser"
8
+ end
9
+ end
10
+ end