king_dtaus 2.0.2.pre → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/Gemfile +1 -6
- data/README.markdown +59 -59
- data/Rakefile +11 -24
- data/king_dtaus.gemspec +22 -65
- data/lib/king_dta/account.rb +53 -27
- data/lib/king_dta/dta.rb +10 -0
- data/lib/king_dta/dtaus.rb +121 -130
- data/lib/king_dta/dtazv.rb +185 -226
- data/lib/king_dta/version.rb +3 -0
- data/spec/account_spec.rb +72 -21
- data/spec/dtaus_spec.rb +35 -12
- data/spec/dtazv_spec.rb +9 -12
- data/spec/spec_helper.rb +37 -36
- metadata +115 -119
- data/VERSION +0 -1
- data/docs/dtazv.pdf +0 -0
- data/docs/dtazv_bank_bbk.pdf +0 -0
- data/docs/example.output +0 -7
- data/spec/dtazv_test.rb +0 -105
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -10,7 +10,7 @@ therefore supported in common banking programs too.
|
|
10
10
|
|
11
11
|
This gem saves you all the trouble when generating DTAUS- or DTAZV-text.
|
12
12
|
|
13
|
-
We love building payment applications
|
13
|
+
We love building payment applications.
|
14
14
|
|
15
15
|
## Install
|
16
16
|
|
@@ -18,25 +18,38 @@ We love building payment applications
|
|
18
18
|
|
19
19
|
## Features
|
20
20
|
|
21
|
-
* Create DTAUS debit
|
22
|
-
* Create DTAUS credit
|
23
|
-
* Create DTAZV debit
|
24
|
-
*
|
21
|
+
* Create DTAUS debit transfer (Lastschrift)
|
22
|
+
* Create DTAUS credit transfer (Gutschrift)
|
23
|
+
* Create DTAZV debit transfer
|
24
|
+
* 100% test coverage to ensure software quality
|
25
|
+
* works with ruby 1.8 & 1.9.2
|
26
|
+
|
27
|
+
## Version Info
|
28
|
+
|
29
|
+
Version 2 has breaking changes!
|
30
|
+
|
31
|
+
* account attributes now passed in as hash
|
32
|
+
* renamed account.client_xy => owner_xy
|
33
|
+
* renamed account.account_number => bank_account_number
|
34
|
+
* added iban/bic to account
|
35
|
+
* DTAZV added
|
36
|
+
|
37
|
+
If you want to stay with v1 just pin it in your Gemfile:
|
38
|
+
|
39
|
+
gem "king_dtaus", "<2"
|
25
40
|
|
26
41
|
## TODOs
|
27
42
|
|
28
|
-
*
|
29
|
-
* some more edge-case tests needed
|
43
|
+
* some more edge-case tests needed, we need your feedback here!
|
30
44
|
|
31
45
|
## Resources
|
32
46
|
|
47
|
+
* SalesKing: http://salesking.eu
|
33
48
|
* DTAZV-Viewer: http://www.meta-evolutions.de/pages/artikel-20070630-dtazv-datei-betrachter.html
|
34
49
|
* DTA/DTAZV PHP Pear: http://pear.php.net/package/Payment_DTA
|
35
|
-
* Ruby Kernel Module: http://www.ruby-doc.org/core/classes/Kernel.html
|
36
50
|
* Windata ZV-Tools: http://www.windata.de/Site/2Produkte2/ZVTools.aspx
|
37
51
|
* The Swift Codes: http://www.theswiftcodes.com/
|
38
52
|
* StarMoney: http://www.starmoney.de/index.php?id=starmoneybusiness_testen
|
39
|
-
* SalesKing: http://salesking.eu
|
40
53
|
|
41
54
|
## Examples
|
42
55
|
|
@@ -48,14 +61,21 @@ Here are some examples how to create a DTA- or DTAZV-File. Also check out the sp
|
|
48
61
|
dta = KingDta::Dtaus.new('LK')
|
49
62
|
|
50
63
|
# set sender account
|
51
|
-
dta.account = KingDta::Account.new(
|
64
|
+
dta.account = KingDta::Account.new(
|
65
|
+
:bank_account_number => "123456789",
|
66
|
+
:bank_number => "69069096",
|
67
|
+
:owner_name => "Return to Sender",
|
68
|
+
:bank_name => "Money Burner Bank")
|
52
69
|
|
53
|
-
#
|
70
|
+
# following should be done in a loop to add multiple bookings
|
54
71
|
# create receiving account
|
55
|
-
|
56
|
-
|
72
|
+
receiver = KingDta::Account.new(
|
73
|
+
:bank_account_number => "987456123",
|
74
|
+
:bank_number => "99099096",
|
75
|
+
:owner_name => "Gimme More Lt.",
|
76
|
+
:bank_name => "Banking Bandits")
|
57
77
|
# create booking
|
58
|
-
booking = KingDta::Booking.new(
|
78
|
+
booking = KingDta::Booking.new(receiver, 100.00 )
|
59
79
|
|
60
80
|
# set booking text if you want to
|
61
81
|
booking.text = "Thanks for your purchase"
|
@@ -69,48 +89,31 @@ Here are some examples how to create a DTA- or DTAZV-File. Also check out the sp
|
|
69
89
|
|
70
90
|
### DTAZV
|
71
91
|
|
72
|
-
@
|
73
|
-
|
74
|
-
|
75
|
-
@
|
76
|
-
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:bank_country_code => @dudes_konto.bank_country_code,
|
89
|
-
:client_country_code => @dudes_konto.client_country_code
|
92
|
+
@dtazv = KingDta::Dtazv.new()
|
93
|
+
|
94
|
+
# sender account
|
95
|
+
@dtazv.account = KingDta::Account.new(
|
96
|
+
:bank_account_number => "123456789",
|
97
|
+
:bank_number => "40050100",
|
98
|
+
:bank_name => "Greedy Fuckers Bank",
|
99
|
+
:owner_name => "Sender name"
|
100
|
+
)
|
101
|
+
|
102
|
+
# receiver account
|
103
|
+
receiver = KingDta::Account.new(
|
104
|
+
:bank_account_number => "987654321",
|
105
|
+
:bank_iban => "PLsome-long-Iban",
|
106
|
+
:bank_bic => "BicCode",
|
107
|
+
:owner_name => "receivers name"
|
90
108
|
)
|
109
|
+
# add bookings, probably in a loop
|
110
|
+
booking = KingDta::Booking.new(receiver, 220.25)
|
111
|
+
@dtazv.add(booking)
|
112
|
+
|
113
|
+
# get output as string
|
114
|
+
@dtazv.create
|
91
115
|
|
92
|
-
|
93
|
-
:account_number => @dalai_lamas_account.account_number,
|
94
|
-
:bank_number => @dalai_lamas_account.bank_number,
|
95
|
-
:client_name => @dalai_lamas_account.client_name,
|
96
|
-
:client_number => @dalai_lamas_account.bank_name,
|
97
|
-
:bank_street => @dalai_lamas_account.account_street,
|
98
|
-
:bank_city => @dalai_lamas_account.account_city,
|
99
|
-
:bank_zip_code => @dalai_lamas_account.account_zip_code,
|
100
|
-
:bank_name => @dalai_lamas_account.bank_name,
|
101
|
-
:client_street => @dalai_lamas_account.client_street,
|
102
|
-
:client_city => @dalai_lamas_account.client_city,
|
103
|
-
:client_zip_code => @dalai_lamas_account.client_zip_code,
|
104
|
-
:bank_country_code => @dalai_lamas_account.bank_country_code,
|
105
|
-
:client_country_code => @dalai_lamas_account.client_country_code
|
106
|
-
), 220.25)
|
107
|
-
|
108
|
-
@dudes_dtazv_export.add(@dalai_lamas_booking)
|
109
|
-
@dudes_dtazv_export.create_file
|
110
|
-
|
111
|
-
# Output is DTAZV0.TXT
|
112
|
-
|
113
|
-
also make sure to read the specs
|
116
|
+
also make sure to read the code and the specs
|
114
117
|
|
115
118
|
## Credits
|
116
119
|
|
@@ -120,9 +123,6 @@ Bugfixes and enhancements by
|
|
120
123
|
* Kim Rudolph - https://github.com/krudolph
|
121
124
|
* Thorsten Böttger - https://github.com/alto
|
122
125
|
* Jan Kus - https://github.com/koos
|
126
|
+
* used https://rubygems.org/gems/DTAUS as a starting point
|
123
127
|
|
124
|
-
|
125
|
-
It was disected, turned into a real class structure, bugs were fixed and
|
126
|
-
of course a full test suite ensures its functionality.
|
127
|
-
|
128
|
-
Copyright (c) 2009-2011 Georg Leciejewski (SalesKing), Jan Kus (Railslove), released under the MIT license
|
128
|
+
Copyright (c) 2009-2011 Georg Leciejewski (SalesKing), Jan Kus (Railslove), released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,31 +1,18 @@
|
|
1
1
|
require 'rake'
|
2
|
+
require 'rspec'
|
2
3
|
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'bundler/gem_helper'
|
6
|
+
Bundler::GemHelper.install_tasks
|
4
7
|
desc "Run specs"
|
5
8
|
RSpec::Core::RakeTask.new
|
6
|
-
|
7
9
|
task :default => :spec
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
begin
|
18
|
-
require 'jeweler'
|
19
|
-
Jeweler::Tasks.new do |gem|
|
20
|
-
gem.name = "king_dtaus"
|
21
|
-
gem.summary = %Q{Generate DTAUS strings and files}
|
22
|
-
gem.description = %Q{DTAUS is a text-based format, to create bank transfers for german banks. This gem helps with the creation of those transfer files.}
|
23
|
-
gem.email = "gl@salesking.eu"
|
24
|
-
gem.homepage = "http://github.com/salesking/king_dtaus"
|
25
|
-
gem.authors = ["Georg Leciejewski", "Georg Ledermann", "Jan Kus"]
|
26
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
27
|
-
end
|
28
|
-
Jeweler::GemcutterTasks.new
|
29
|
-
rescue LoadError
|
30
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
11
|
+
desc 'Generate documentation'
|
12
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
13
|
+
rdoc.rdoc_dir = 'docs/rdoc'
|
14
|
+
rdoc.title = 'KingPdf'
|
15
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
16
|
+
rdoc.rdoc_files.include('README')
|
17
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
18
|
end
|
data/king_dtaus.gemspec
CHANGED
@@ -1,77 +1,34 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'king_dta/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = %q{king_dtaus}
|
8
|
-
s.version =
|
7
|
+
s.version = KingDta::VERSION
|
9
8
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
13
|
-
s.
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
10
|
+
s.authors = ['Georg Leciejewski', 'Georg Ledermann', 'Jan Kus']
|
11
|
+
s.date = %q{2011-11-15}
|
12
|
+
s.summary = %q{Generate DTA/DTAUS and DTAZV bank transfer files .. the easy way}
|
13
|
+
s.description = %q{DTA/DTAUS and DTAZV are text-based formats to create bank transfers for german banks.
|
14
|
+
This gem creates DTA/DATAUS files for inner german credit and debit(Gutschrift/Lastschrift) transfers.
|
15
|
+
It is also capable of creating DTAZV credit-files for transfers from Germany to European SEPA region.}
|
14
16
|
s.email = %q{gl@salesking.eu}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
|
17
|
-
]
|
18
|
-
s.files
|
19
|
-
|
20
|
-
"Gemfile",
|
21
|
-
"MIT-LICENSE",
|
22
|
-
"README.markdown",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"docs/dtazv.pdf",
|
26
|
-
"docs/dtazv_bank_bbk.pdf",
|
27
|
-
"docs/example.output",
|
28
|
-
"king_dtaus.gemspec",
|
29
|
-
"lib/king_dta/account.rb",
|
30
|
-
"lib/king_dta/booking.rb",
|
31
|
-
"lib/king_dta/dta.rb",
|
32
|
-
"lib/king_dta/dtaus.rb",
|
33
|
-
"lib/king_dta/dtazv.rb",
|
34
|
-
"lib/king_dta/exception.rb",
|
35
|
-
"lib/king_dta/helper.rb",
|
36
|
-
"lib/king_dtaus.rb",
|
37
|
-
"spec/account_spec.rb",
|
38
|
-
"spec/booking_spec.rb",
|
39
|
-
"spec/dtaus_spec.rb",
|
40
|
-
"spec/dtazv_spec.rb",
|
41
|
-
"spec/dtazv_test.rb",
|
42
|
-
"spec/helper_spec.rb",
|
43
|
-
"spec/spec_helper.rb"
|
44
|
-
]
|
17
|
+
s.extra_rdoc_files = ['README.markdown']
|
18
|
+
s.executables = nil
|
19
|
+
s.files = `git ls-files`.split("\n").reject{|i| i[/^docs\//] }
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
|
45
22
|
s.homepage = %q{http://github.com/salesking/king_dtaus}
|
46
|
-
s.require_paths = [
|
23
|
+
s.require_paths = ['lib']
|
47
24
|
s.rubygems_version = %q{1.6.2}
|
48
|
-
s.summary = %q{Generate DTAUS strings and files}
|
49
25
|
|
50
|
-
|
51
|
-
|
26
|
+
s.add_runtime_dependency 'i18n'
|
27
|
+
s.add_development_dependency 'rdoc'
|
28
|
+
s.add_development_dependency 'rspec'
|
29
|
+
s.add_development_dependency 'simplecov'
|
30
|
+
s.add_development_dependency 'mocha'
|
31
|
+
s.add_development_dependency 'rake', '>= 0.9.2'
|
52
32
|
|
53
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
-
s.add_runtime_dependency(%q<king_dtaus>, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
56
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
57
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<mocha>, [">= 0"])
|
59
|
-
s.add_development_dependency(%q<i18n>, [">= 0"])
|
60
|
-
else
|
61
|
-
s.add_dependency(%q<king_dtaus>, [">= 0"])
|
62
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
64
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
65
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
66
|
-
s.add_dependency(%q<i18n>, [">= 0"])
|
67
|
-
end
|
68
|
-
else
|
69
|
-
s.add_dependency(%q<king_dtaus>, [">= 0"])
|
70
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
71
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
72
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
73
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
74
|
-
s.add_dependency(%q<i18n>, [">= 0"])
|
75
|
-
end
|
76
33
|
end
|
77
34
|
|
data/lib/king_dta/account.rb
CHANGED
@@ -1,50 +1,76 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module KingDta
|
3
|
-
#
|
4
|
-
# Kontodaten verwalten mit Name des Inhabers und Bank, Bankleitzahl und Kontonummer.
|
3
|
+
# Bank account and owner information
|
5
4
|
class Account
|
6
5
|
include KingDta::Helper
|
7
|
-
|
8
|
-
attr_accessor :account_number, :bank_number, :bank_street, :bank_city,
|
9
|
-
:bank_zip_code, :bank_name, :bank_country_code,
|
10
|
-
:client_name, :client_number, :client_street, :client_city,
|
11
|
-
:client_zip_code, :client_country_code
|
12
6
|
|
13
|
-
|
7
|
+
attr_accessor :bank_street, :bank_city,
|
8
|
+
:bank_zip, :bank_name, :bank_country_code, :bank_iban,
|
9
|
+
:bank_bic,
|
10
|
+
:owner_name, :owner_number, :owner_street, :owner_city,
|
11
|
+
:owner_zip_code, :owner_country_code
|
12
|
+
attr_reader :bank_account_number, :bank_number
|
13
|
+
|
14
14
|
def initialize(args={})
|
15
15
|
|
16
16
|
@bank_street = convert_text(args.delete(:bank_street))
|
17
17
|
@bank_city = convert_text(args.delete(:bank_city))
|
18
18
|
@bank_name = convert_text(args.delete(:bank_name))
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
19
|
+
@owner_name = convert_text(args.delete(:owner_name))
|
20
|
+
@owner_street = convert_text(args.delete(:owner_street))
|
21
|
+
@owner_city = convert_text(args.delete(:owner_city))
|
22
22
|
|
23
23
|
args.each do |key,value|
|
24
24
|
self.send("#{key}=",value)
|
25
25
|
end
|
26
26
|
|
27
|
-
raise ArgumentError.new('
|
28
|
-
raise ArgumentError.new('
|
29
|
-
raise ArgumentError.new('
|
30
|
-
raise ArgumentError.new(
|
31
|
-
|
32
|
-
|
33
|
-
raise ArgumentError.new("Bank
|
34
|
-
raise ArgumentError.new("Bank
|
35
|
-
|
36
|
-
raise ArgumentError.new(
|
37
|
-
raise ArgumentError.new(
|
38
|
-
raise ArgumentError.new(
|
27
|
+
raise ArgumentError.new('Owner number too long, max 10 allowed') if @owner_number && "#{@owner_number}".length > 10
|
28
|
+
raise ArgumentError.new('Owner street too long, max 35 allowed') if @owner_street && @owner_street.length > 35
|
29
|
+
raise ArgumentError.new('Owner city too long, max 35 allowed') if @owner_city && @owner_city.length > 35
|
30
|
+
raise ArgumentError.new('Owner country code too long, max 2 allowed') if @owner_country_code && @owner_country_code.length > 2
|
31
|
+
|
32
|
+
|
33
|
+
raise ArgumentError.new("Bank iban wrong length: #{@bank_iban.length}, must be between 15-34") if @bank_iban && !@bank_iban.length.between?(15,34)
|
34
|
+
raise ArgumentError.new("Bank bic wrong length: #{@bank_bic.length} must be between 8-11") if @bank_bic && !@bank_bic.length.between?(8,11)
|
35
|
+
|
36
|
+
raise ArgumentError.new('Bank street too long, max 35 allowed') if @bank_street && @bank_street.length > 35
|
37
|
+
raise ArgumentError.new('Bank city too long, max 35 allowed') if @bank_city && @bank_city.length > 35
|
38
|
+
raise ArgumentError.new('Bank name too long, max 35 allowed') if @bank_name && @bank_name.length > 35
|
39
|
+
raise ArgumentError.new('Bank country code too long, max 2 allowed') if @bank_country_code && @bank_country_code.length > 2
|
40
|
+
|
41
|
+
@owner_country_code = @bank_iban[0..1 ] if @bank_iban && !@owner_country_code
|
42
|
+
end
|
43
|
+
|
44
|
+
# Cast given account number to integer. Strips spaces and leading zeros
|
45
|
+
# from the bank account number.
|
46
|
+
# DTA relies on integers for checksums and field values.
|
47
|
+
# @param [String|Integer] number
|
48
|
+
def bank_account_number=(number)
|
49
|
+
nr_str = "#{number}".gsub(/\s/,'')
|
50
|
+
raise ArgumentError.new('Bank account number too long, max 10 allowed') if nr_str.length > 10
|
51
|
+
raise ArgumentError.new('Bank account number cannot be 0') if nr_str == '0'
|
52
|
+
|
53
|
+
@bank_account_number = nr_str.to_i
|
54
|
+
end
|
55
|
+
|
56
|
+
# Cast given bank number to integer. Strips spaces and leading zeros
|
57
|
+
# from the bank account number.
|
58
|
+
# DTA relies on integers for checksums and field values.
|
59
|
+
# @param [String|Integer] number
|
60
|
+
def bank_number=(number)
|
61
|
+
nr_str = "#{number}".gsub(/\s/,'')
|
62
|
+
raise ArgumentError.new('Bank number too long, max 8 allowed') if nr_str.length > 8
|
63
|
+
raise ArgumentError.new('Bank number cannot be 0') if nr_str == '0'
|
39
64
|
|
65
|
+
@bank_number = nr_str.to_i
|
40
66
|
end
|
41
67
|
|
42
|
-
def
|
43
|
-
"#{@
|
68
|
+
def bank_zip_city
|
69
|
+
"#{@bank_zip} #{@bank_city}"
|
44
70
|
end
|
45
71
|
|
46
|
-
def
|
47
|
-
"#{@
|
72
|
+
def owner_zip_city
|
73
|
+
"#{@owner_zip_code} #{@owner_city}"
|
48
74
|
end
|
49
75
|
|
50
76
|
end
|
data/lib/king_dta/dta.rb
CHANGED
@@ -4,6 +4,16 @@ module KingDta
|
|
4
4
|
include KingDta::Helper
|
5
5
|
attr_reader :default_text
|
6
6
|
|
7
|
+
# Create a new dta string.
|
8
|
+
# === Parameter #
|
9
|
+
# typ<Date>:: date when the the transfer is to be created
|
10
|
+
def initialize(date=Date.today )
|
11
|
+
raise ArgumentError.new("Wrong date format. Make it a Time or Date object with yyyy-mm-dd") unless date.respond_to?(:strftime)
|
12
|
+
@date = date
|
13
|
+
@value_pos = true #values are positive by default changed by first booking
|
14
|
+
@closed = false
|
15
|
+
@default_text = ''
|
16
|
+
end
|
7
17
|
# Set the sending account(you own)
|
8
18
|
# === Parameter
|
9
19
|
# account<Account>:: the sending account, must be an instance of class
|