volksbanker 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 22e6e328e0bfa159540169e32d857c8fe5eb7f2c
4
+ data.tar.gz: 865a5875ad3f2a1f9fa324286acafba317a770e2
5
+ SHA512:
6
+ metadata.gz: b790e95f650e592e63afd56f6bf705223962affa556484f4040450ec12f6fbb484dcfd0f8670fe3a2658fafd03eb8af9c5cf25b31953a4abb46d7745f013ebce
7
+ data.tar.gz: 938d92781e35c6a69cc0ed0fca1db533d087acbe0f3559bffba5dbfe28dd41d7f63305c7b36b37b17dae2f9a4273a037b416dcf110fc14f474c47ccb6564fa4e
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ TODO.md
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/bin/vb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby-local-exec
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  lib_dir = File.join File.dirname(__FILE__), '..', 'lib'
4
4
  $LOAD_PATH.unshift lib_dir
@@ -7,13 +7,16 @@ module Volksbanker
7
7
  def self.run(volksbank_file)
8
8
  reader = VolksbankFileReader.new volksbank_file
9
9
  reader.each_line_item do |vli|
10
- unless vli.currency == 'EUR'
11
- $stderr.puts "Skipping non-EUR currency line item: #{vli.inspect}"
12
- next
13
- end
14
10
  ali = AmexLineItem.new vli.posting_date, vli.value, description_for(vli)
15
- CSV { |out| out << [ali.date, ali.amount, ali.description] }
11
+ case ali.description
12
+ when 'Anfangssaldo'; @opening_balance = pretty_amount(ali.amount, vli.currency)
13
+ when 'Endsaldo'; @closing_balance = pretty_amount(ali.amount, vli.currency)
14
+ else
15
+ CSV { |out| out << [ali.date, ali.amount, ali.description] }
16
+ end
16
17
  end
18
+ $stderr.puts "opening balance: #{@opening_balance}"
19
+ $stderr.puts "closing balance: #{@closing_balance}"
17
20
  end
18
21
 
19
22
  private
@@ -23,6 +26,10 @@ module Volksbanker
23
26
  desc += " (#{volksbank_line_item.recipient_or_payer})" unless volksbank_line_item.recipient_or_payer.nil?
24
27
  desc
25
28
  end
29
+
30
+ def self.pretty_amount(amount, currency)
31
+ "#{'%.2f' % amount} #{currency}"
32
+ end
26
33
  end
27
34
 
28
35
  end
@@ -1,3 +1,3 @@
1
1
  module Volksbanker
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -40,9 +40,10 @@ module Volksbanker
40
40
  next if header
41
41
 
42
42
  line.chomp!
43
- break if line.empty? # stop before footer
44
43
 
45
- yield VolksbankLineItem.new_from_csv line rescue $stderr.puts "Problem with #{line}: #{$!}"
44
+ unless line.empty?
45
+ yield VolksbankLineItem.new_from_csv line rescue $stderr.puts "Problem with #{line}: #{$!}"
46
+ end
46
47
  end
47
48
  end
48
49
 
@@ -16,8 +16,15 @@ class VolksbankLineItem
16
16
  @recipient_or_payer = recipient_or_payer
17
17
  @account_number = account_number
18
18
  @sort_code = sort_code
19
+
19
20
  @description = description
20
21
  @currency = currency
22
+ # The opening and closing balance lines switch the currency and description fields.
23
+ if %w[ Anfangssaldo Endsaldo ].include? currency
24
+ @description = currency
25
+ @currency = description
26
+ end
27
+
21
28
  amt = parse_number amount
22
29
  @value = credit?(credit_or_debit) ? amt : (amt * -1)
23
30
  end
@@ -29,7 +36,7 @@ class VolksbankLineItem
29
36
  private
30
37
 
31
38
  def parse_date(str)
32
- Date.strptime str, DATE_FORMAT
39
+ Date.strptime str, DATE_FORMAT if str
33
40
  end
34
41
 
35
42
  def parse_number(str)
data/test/cli_test.rb CHANGED
@@ -5,29 +5,20 @@ require 'volksbanker/cli'
5
5
  class CliTest < MiniTest::Unit::TestCase
6
6
 
7
7
  def test_happy_path
8
- expected_stdout = read_fixture 'result.csv'
9
- expected_stderr = ''
8
+ expected_stdout = read_fixture 'result.stdout.csv'
9
+ expected_stderr = read_fixture 'result.stderr.csv'
10
10
 
11
11
  assert_output expected_stdout, expected_stderr do
12
12
  Volksbanker::Cli.run fixture('transactions.csv')
13
13
  end
14
14
  end
15
15
 
16
- def test_skips_non_euro_line_items
17
- out, err = capture_io do
18
- Volksbanker::Cli.run fixture('transactions-with-non-euro.csv')
19
- end
20
-
21
- refute_match %r{30/07/2012}m, out
22
- assert_match /Skipping/, err
23
- end
24
-
25
16
  def test_handles_line_feed_shenanigans
26
17
  out, err = capture_io do
27
18
  Volksbanker::Cli.run fixture('newlines.csv')
28
19
  end
29
20
 
30
- assert_equal '', err
21
+ assert_equal read_fixture('newlines.stderr.csv'), err
31
22
  end
32
23
 
33
24
  end
@@ -0,0 +1,2 @@
1
+ opening balance: 1234.56 EUR
2
+ closing balance: 3456.67 EUR
@@ -0,0 +1,2 @@
1
+ opening balance: 0.00 EUR
2
+ closing balance: 2729.50 EUR
File without changes
metadata CHANGED
@@ -1,40 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volksbanker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
4
+ version: 1.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andy Stewart
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
- requirement: &2164669360 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.9.2
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *2164669360
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.2
25
27
  description: Prepares Volksbank's electronic statements for upload to Freeagent.
26
28
  email:
27
29
  - boss@airbladesoftware.com
28
30
  executables:
31
+ - rake
29
32
  - vb
30
33
  extensions: []
31
34
  extra_rdoc_files: []
32
35
  files:
33
- - .gitignore
36
+ - ".gitignore"
34
37
  - CHANGELOG.md
35
38
  - Gemfile
36
39
  - README.md
37
40
  - Rakefile
41
+ - bin/rake
38
42
  - bin/vb
39
43
  - lib/volksbanker.rb
40
44
  - lib/volksbanker/amex_line_item.rb
@@ -44,45 +48,40 @@ files:
44
48
  - lib/volksbanker/volksbank_line_item.rb
45
49
  - test/cli_test.rb
46
50
  - test/fixtures/newlines.csv
47
- - test/fixtures/result.csv
48
- - test/fixtures/transactions-with-non-euro.csv
51
+ - test/fixtures/newlines.stderr.csv
52
+ - test/fixtures/result.stderr.csv
53
+ - test/fixtures/result.stdout.csv
49
54
  - test/fixtures/transactions.csv
50
55
  - test/test_helper.rb
51
56
  - volksbanker.gemspec
52
57
  homepage: ''
53
58
  licenses: []
59
+ metadata: {}
54
60
  post_install_message:
55
61
  rdoc_options: []
56
62
  require_paths:
57
63
  - lib
58
64
  required_ruby_version: !ruby/object:Gem::Requirement
59
- none: false
60
65
  requirements:
61
- - - ! '>='
66
+ - - ">="
62
67
  - !ruby/object:Gem::Version
63
68
  version: '0'
64
- segments:
65
- - 0
66
- hash: -982126049656369425
67
69
  required_rubygems_version: !ruby/object:Gem::Requirement
68
- none: false
69
70
  requirements:
70
- - - ! '>='
71
+ - - ">="
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
- segments:
74
- - 0
75
- hash: -982126049656369425
76
74
  requirements: []
77
75
  rubyforge_project: volksbanker
78
- rubygems_version: 1.8.11
76
+ rubygems_version: 2.2.2
79
77
  signing_key:
80
- specification_version: 3
78
+ specification_version: 4
81
79
  summary: Prepares Volksbank's electronic statements for upload to Freeagent.
82
80
  test_files:
83
81
  - test/cli_test.rb
84
82
  - test/fixtures/newlines.csv
85
- - test/fixtures/result.csv
86
- - test/fixtures/transactions-with-non-euro.csv
83
+ - test/fixtures/newlines.stderr.csv
84
+ - test/fixtures/result.stderr.csv
85
+ - test/fixtures/result.stdout.csv
87
86
  - test/fixtures/transactions.csv
88
87
  - test/test_helper.rb
@@ -1,32 +0,0 @@
1
- "Volksbank Rhein-Wehra eG"
2
-
3
- "Umsatzanzeige"
4
-
5
- "BLZ:";"68490000";;"Datum:";"13.08.2012"
6
- "Konto:";"12345678";;"Uhrzeit:";"11:54:07"
7
- "Abfrage von:";"Joe Bloggs";;"Kontoinhaber:";"Foo GmbH"
8
-
9
- "Zeitraum:";"4 Wochen";"von:";;"bis:";
10
- "Betrag in EUR:";;"von:";" ";"bis:";" "
11
- "Sortiert nach:";"Buchungstag";"absteigend"
12
-
13
- "Buchungstag";"Valuta";"Auftraggeber/Zahlungsempf�nger";"Empf�nger/Zahlungspflichtiger";"Konto-Nr.";"BLZ";"Vorgang/Verwendungszweck";"W�hrung";"Umsatz";" "
14
- "08.08.2012";"08.08.2012";;"PREIS VR-BANKCARD";"1234500000";"12340000";"Bankcard-Geb�hr
15
- FOLGE-NR. 0 VERFALL 12.15
16
- PREIS BEZAHLT BIS 12.2012";"EUR";"7,50";"S"
17
- "08.08.2012";"08.08.2012";"Foo GmbH";"Jane Doe";"1234567890";"12345678";"Verg�tung
18
- INVOICE 7004";"EUR";"170,00";"H"
19
- "07.08.2012";"07.08.2012";"BarApp";"Sarah Smith";"123456789";"12345678";"Verg�tung
20
- INVOICE 7003
21
- Acme GmbH, JULY 2012";"EUR";"170,00";"H"
22
- "03.08.2012";"03.08.2012";"Foo GmbH";"Some Firm GmbH";"1234567";"12345678";"Verg�tung
23
- INVOICE 7002";"EUR";"2.023,00";"H"
24
- "31.07.2012";"31.07.2012";"Foo GmbH";"James Brown";"1234567890";"12345678";"Verg�tung
25
- RGNR. 2271";"EUR";"68,00";"H"
26
- "30.07.2012";"30.07.2012";"Foo GmbH";"Example.com";"123456789";"12345678";"Verg�tung
27
- INVOICE 7002";"GBP";"136,00";"H"
28
- "17.07.2012";"17.07.2012";"Foo GmbH";"Blah Inc GmbH";"1234567890";"12345678";"Verg�tung
29
- INVOICE 2264";"EUR";"170,00";"H"
30
-
31
- "17.07.2012";;;;;;"EUR";"Anfangssaldo";"0,00";"H"
32
- "08.08.2012";;;;;;"EUR";"Endsaldo";"2.729,50";"H"