statementor 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ /.project
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/README ADDED
@@ -0,0 +1,19 @@
1
+ = statementor
2
+
3
+ == Installation
4
+
5
+ $ gem install statementor
6
+
7
+ == Dependencies
8
+
9
+ * rspec
10
+ * money
11
+
12
+ == Usage example
13
+
14
+ require 'statementor'
15
+
16
+ seb_statement = Statementor::Statement.new('seb.csv', :sev)
17
+ seb_statement.transactions.each do |transaction|
18
+ p transaction
19
+ end
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ require 'statementor/statement'
2
+ require 'statementor/transaction'
3
+ require 'statementor/seb_transaction'
4
+
5
+ module Statementor
6
+ SUPPORTED_BANKS = [:seb, :swed]
7
+ class NoTransactions < StandardError ; end
8
+ class UnsupportedBank < StandardError ; end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Statementor
2
+ class SebTransaction < Transaction
3
+ def initialize(raw_data)
4
+ super
5
+ @counterparty_name = @counterparty_name.force_encoding('iso-8859-1').encode('utf-8')
6
+ @description = @description.force_encoding('iso-8859-1').encode('utf-8')
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ require 'csv'
2
+
3
+ module Statementor
4
+ class Statement
5
+ attr_reader :transactions
6
+ def initialize(file, bank)
7
+ raise UnsupportedBank unless SUPPORTED_BANKS.include?(bank)
8
+ @file = file
9
+ @bank = bank
10
+ @transactions = []
11
+ parse
12
+ end
13
+
14
+ def parse
15
+ CSV.foreach(@file, :col_sep => ';', :headers => true, :encoding => 'ascii-8bit') do |row|
16
+ @transactions << (@bank == :seb ? SebTransaction.new(row) : Transaction.new(row))
17
+ end
18
+ raise NoTransactions if @transactions.empty?
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,68 @@
1
+ require 'money'
2
+
3
+ module Statementor
4
+ class Transaction
5
+ # Archiving ID
6
+ attr_reader :id
7
+
8
+ # Debit/Credit (D/C)
9
+ attr_reader :kind
10
+
11
+ # Date
12
+ attr_reader :date
13
+
14
+ # Amount
15
+ attr_reader :amount
16
+
17
+ # Client account
18
+ attr_reader :account
19
+
20
+ # Beneficiary’s/remitter's account
21
+ attr_reader :counterparty_account
22
+
23
+ # Beneficiary’s/remitter's name
24
+ attr_reader :counterparty_name
25
+
26
+ # Code of beneficiary’s/remitter’s bank
27
+ attr_reader :counterparty_bank_code
28
+
29
+ # Document number
30
+ attr_reader :doc_no
31
+
32
+ # Reference number
33
+ attr_reader :ref_no
34
+
35
+ # Description
36
+ attr_reader :description
37
+
38
+ # Commission fee
39
+ attr_reader :commission_fee
40
+
41
+ # Remitter’s Reg. or ID code
42
+ attr_reader :remitter_id_code
43
+
44
+ def initialize(raw_data)
45
+ @id = raw_data[10]
46
+ @kind = raw_data[7]
47
+ @date = Date::parse(raw_data[2])
48
+ @amount = "#{raw_data[8]} #{raw_data[13]}".to_money.abs
49
+ @account = raw_data[0]
50
+ @counterparty_account = raw_data[3]
51
+ @counterparty_name = raw_data[4]
52
+ @counterparty_bank_code = raw_data[5]
53
+ @doc_no = raw_data[1]
54
+ @ref_no = raw_data[9]
55
+ @description = raw_data[11]
56
+ @commission_fee = raw_data[12]
57
+ @remitter_id_code = raw_data[14]
58
+ end
59
+
60
+ def debit?
61
+ kind == 'D'
62
+ end
63
+
64
+ def credit?
65
+ kind == 'C'
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,3 @@
1
+ describe 'Statementor' do
2
+
3
+ end
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'statementor'
3
+ s.version = '0.0.4'
4
+ s.author = 'Artur Beljajev'
5
+ s.email = 'artur@intech.ee'
6
+ s.homepage = 'http://github.com/intechltd/statementor'
7
+ s.summary = 'Estonian SEB and Swedbank CSV statement parser'
8
+
9
+ s.rubyforge_project = 'statementor'
10
+
11
+ s.add_dependency 'money', '>= 4'
12
+ s.add_development_dependency 'rspec', '>= 2'
13
+
14
+ s.required_ruby_version = '>= 1.9.0'
15
+ s.require_paths = ["lib"]
16
+ s.files = `git ls-files`.split("\n")
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statementor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-12 00:00:00.000000000 Z
12
+ date: 2011-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: money
16
- requirement: &22858020 !ruby/object:Gem::Requirement
16
+ requirement: &23163300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *22858020
24
+ version_requirements: *23163300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &22857348 !ruby/object:Gem::Requirement
27
+ requirement: &23162964 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,13 +32,24 @@ dependencies:
32
32
  version: '2'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *22857348
35
+ version_requirements: *23162964
36
36
  description:
37
37
  email: artur@intech.ee
38
38
  executables: []
39
39
  extensions: []
40
40
  extra_rdoc_files: []
41
- files: []
41
+ files:
42
+ - .gitignore
43
+ - .project
44
+ - Gemfile
45
+ - README
46
+ - Rakefile
47
+ - lib/statementor.rb
48
+ - lib/statementor/seb_transaction.rb
49
+ - lib/statementor/statement.rb
50
+ - lib/statementor/transaction.rb
51
+ - spec/statementor_spec.rb
52
+ - statementor.gemspec
42
53
  homepage: http://github.com/intechltd/statementor
43
54
  licenses: []
44
55
  post_install_message:
@@ -62,5 +73,5 @@ rubyforge_project: statementor
62
73
  rubygems_version: 1.8.11
63
74
  signing_key:
64
75
  specification_version: 3
65
- summary: SEB and Swedbank CSV statement parser
76
+ summary: Estonian SEB and Swedbank CSV statement parser
66
77
  test_files: []