king_dtaus 2.0.0.pre → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile +5 -1
- data/README.markdown +128 -0
- data/Rakefile +7 -2
- data/VERSION +1 -1
- data/king_dtaus.gemspec +12 -13
- data/lib/king_dta/account.rb +30 -30
- data/lib/king_dta/dta.rb +10 -0
- data/lib/king_dta/dtaus.rb +125 -134
- data/lib/king_dta/dtazv.rb +183 -221
- data/lib/king_dta/helper.rb +3 -1
- data/lib/king_dtaus.rb +1 -0
- data/spec/account_spec.rb +65 -117
- data/spec/booking_spec.rb +1 -3
- data/spec/dtaus_spec.rb +35 -12
- data/spec/dtazv_spec.rb +77 -176
- data/spec/spec_helper.rb +43 -66
- metadata +48 -31
- data/.rvmrc +0 -1
- data/DTAUS0.TXT +0 -1
- data/Gemfile.lock +0 -38
- data/README.rdoc +0 -119
- data/spec/dtazv_test.rb +0 -105
- /data/{example.output → docs/example.output} +0 -0
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# DTAUS & DTAZV always comes together
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/salesking/king_dtaus.png)](http://travis-ci.org/salesking/king_dtaus)
|
4
|
+
|
5
|
+
DTAUS & DTAZV are formats for German bank transfers and is short for
|
6
|
+
"Datenträgeraustausch". The format itself totally sucks because it was
|
7
|
+
established in the last century, to be used on floppy disks. Still almost
|
8
|
+
all German banks use it (they only seem innovative at robbing), and it is
|
9
|
+
therefore supported in common banking programs too.
|
10
|
+
|
11
|
+
This gem saves you all the trouble when generating DTAUS- or DTAZV-text.
|
12
|
+
|
13
|
+
We love building payment applications.
|
14
|
+
|
15
|
+
## Install
|
16
|
+
|
17
|
+
gem install king_dtaus
|
18
|
+
|
19
|
+
## Features
|
20
|
+
|
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"
|
40
|
+
|
41
|
+
## TODOs
|
42
|
+
|
43
|
+
* some more edge-case tests needed, we need your feedback here!
|
44
|
+
|
45
|
+
## Resources
|
46
|
+
|
47
|
+
* SalesKing: http://salesking.eu
|
48
|
+
* DTAZV-Viewer: http://www.meta-evolutions.de/pages/artikel-20070630-dtazv-datei-betrachter.html
|
49
|
+
* DTA/DTAZV PHP Pear: http://pear.php.net/package/Payment_DTA
|
50
|
+
* Windata ZV-Tools: http://www.windata.de/Site/2Produkte2/ZVTools.aspx
|
51
|
+
* The Swift Codes: http://www.theswiftcodes.com/
|
52
|
+
* StarMoney: http://www.starmoney.de/index.php?id=starmoneybusiness_testen
|
53
|
+
|
54
|
+
## Examples
|
55
|
+
|
56
|
+
Here are some examples how to create a DTA- or DTAZV-File. Also check out the spec/dtazv_test.rb to have a running example of an export.
|
57
|
+
|
58
|
+
### DTA
|
59
|
+
|
60
|
+
# create a new dtaus object
|
61
|
+
dta = KingDta::Dtaus.new('LK')
|
62
|
+
|
63
|
+
# set sender account
|
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")
|
69
|
+
|
70
|
+
# following should be done in a loop to add multiple bookings
|
71
|
+
# create receiving account
|
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")
|
77
|
+
# create booking
|
78
|
+
booking = KingDta::Booking.new(receiver, 100.00 )
|
79
|
+
|
80
|
+
# set booking text if you want to
|
81
|
+
booking.text = "Thanks for your purchase"
|
82
|
+
|
83
|
+
# add booking
|
84
|
+
dta.add( booking )
|
85
|
+
# end loop
|
86
|
+
|
87
|
+
# create datausstring and do with it whatever fits your workflow
|
88
|
+
my_str = dta.create
|
89
|
+
|
90
|
+
### DTAZV
|
91
|
+
|
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"
|
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
|
115
|
+
|
116
|
+
also make sure to read the code and the specs
|
117
|
+
|
118
|
+
## Credits
|
119
|
+
|
120
|
+
Bugfixes and enhancements by
|
121
|
+
|
122
|
+
* Georg Ledermann - https://github.com/ledermann
|
123
|
+
* Kim Rudolph - https://github.com/krudolph
|
124
|
+
* Thorsten Böttger - https://github.com/alto
|
125
|
+
* Jan Kus - https://github.com/koos
|
126
|
+
* used https://rubygems.org/gems/DTAUS as a starting point
|
127
|
+
|
128
|
+
Copyright (c) 2009-2011 Georg Leciejewski (SalesKing), Jan Kus (Railslove), released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require 'rdoc/task'
|
3
2
|
require 'rspec/core/rake_task'
|
4
3
|
|
5
4
|
desc "Run specs"
|
@@ -7,6 +6,12 @@ RSpec::Core::RakeTask.new
|
|
7
6
|
|
8
7
|
task :default => :spec
|
9
8
|
|
9
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
10
|
+
t.rcov = true
|
11
|
+
t.rcov_opts = %q[--exclude "spec"]
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
10
15
|
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
11
16
|
|
12
17
|
begin
|
@@ -17,7 +22,7 @@ begin
|
|
17
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.}
|
18
23
|
gem.email = "gl@salesking.eu"
|
19
24
|
gem.homepage = "http://github.com/salesking/king_dtaus"
|
20
|
-
gem.authors = ["Georg Leciejewski", "Georg Ledermann"]
|
25
|
+
gem.authors = ["Georg Leciejewski", "Georg Ledermann", "Jan Kus"]
|
21
26
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
22
27
|
end
|
23
28
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0
|
1
|
+
2.0.0
|
data/king_dtaus.gemspec
CHANGED
@@ -5,28 +5,26 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{king_dtaus}
|
8
|
-
s.version = "2.0.0
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
11
|
-
s.authors = ["Georg Leciejewski", "Georg Ledermann"]
|
12
|
-
s.date = %q{2011-
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Georg Leciejewski", "Georg Ledermann", "Jan Kus"]
|
12
|
+
s.date = %q{2011-11-15}
|
13
13
|
s.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.}
|
14
14
|
s.email = %q{gl@salesking.eu}
|
15
15
|
s.extra_rdoc_files = [
|
16
|
-
"README.
|
16
|
+
"README.markdown"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
"DTAUS0.TXT",
|
19
|
+
".travis.yml",
|
21
20
|
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
21
|
"MIT-LICENSE",
|
24
|
-
"README.
|
22
|
+
"README.markdown",
|
25
23
|
"Rakefile",
|
26
24
|
"VERSION",
|
27
25
|
"docs/dtazv.pdf",
|
28
26
|
"docs/dtazv_bank_bbk.pdf",
|
29
|
-
"example.output",
|
27
|
+
"docs/example.output",
|
30
28
|
"king_dtaus.gemspec",
|
31
29
|
"lib/king_dta/account.rb",
|
32
30
|
"lib/king_dta/booking.rb",
|
@@ -40,17 +38,15 @@ Gem::Specification.new do |s|
|
|
40
38
|
"spec/booking_spec.rb",
|
41
39
|
"spec/dtaus_spec.rb",
|
42
40
|
"spec/dtazv_spec.rb",
|
43
|
-
"spec/dtazv_test.rb",
|
44
41
|
"spec/helper_spec.rb",
|
45
42
|
"spec/spec_helper.rb"
|
46
43
|
]
|
47
44
|
s.homepage = %q{http://github.com/salesking/king_dtaus}
|
48
45
|
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = %q{1.
|
46
|
+
s.rubygems_version = %q{1.6.2}
|
50
47
|
s.summary = %q{Generate DTAUS strings and files}
|
51
48
|
|
52
49
|
if s.respond_to? :specification_version then
|
53
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
50
|
s.specification_version = 3
|
55
51
|
|
56
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -59,12 +55,14 @@ Gem::Specification.new do |s|
|
|
59
55
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
60
56
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
61
57
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<i18n>, [">= 0"])
|
62
59
|
else
|
63
60
|
s.add_dependency(%q<king_dtaus>, [">= 0"])
|
64
61
|
s.add_dependency(%q<rspec>, [">= 0"])
|
65
62
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
66
63
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
67
64
|
s.add_dependency(%q<mocha>, [">= 0"])
|
65
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
68
66
|
end
|
69
67
|
else
|
70
68
|
s.add_dependency(%q<king_dtaus>, [">= 0"])
|
@@ -72,6 +70,7 @@ Gem::Specification.new do |s|
|
|
72
70
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
73
71
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
74
72
|
s.add_dependency(%q<mocha>, [">= 0"])
|
73
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
data/lib/king_dta/account.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module KingDta
|
3
|
-
#
|
3
|
+
# A bank account with name of the account owner,
|
4
|
+
# Kontodaten verwalten mit Name des Inhabers und Bank, Bankleitzahl und Kontonummer.
|
4
5
|
class Account
|
5
6
|
include KingDta::Helper
|
6
|
-
|
7
|
-
attr_accessor :
|
8
|
-
:
|
7
|
+
|
8
|
+
attr_accessor :bank_account_number, :bank_number, :bank_street, :bank_city,
|
9
|
+
:bank_zip, :bank_name, :bank_country_code, :bank_iban,
|
10
|
+
:bank_bic,
|
11
|
+
:owner_name, :owner_number, :owner_street, :owner_city,
|
12
|
+
:owner_zip_code, :owner_country_code
|
9
13
|
|
10
14
|
# TODO test
|
11
15
|
def initialize(args={})
|
@@ -13,44 +17,40 @@ module KingDta
|
|
13
17
|
@bank_street = convert_text(args.delete(:bank_street))
|
14
18
|
@bank_city = convert_text(args.delete(:bank_city))
|
15
19
|
@bank_name = convert_text(args.delete(:bank_name))
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
20
|
+
@owner_name = convert_text(args.delete(:owner_name))
|
21
|
+
@owner_street = convert_text(args.delete(:owner_street))
|
22
|
+
@owner_city = convert_text(args.delete(:owner_city))
|
19
23
|
|
20
24
|
args.each do |key,value|
|
21
25
|
self.send("#{key}=",value)
|
22
26
|
end
|
23
27
|
|
24
|
-
raise ArgumentError.new('
|
25
|
-
raise ArgumentError.new(
|
26
|
-
raise ArgumentError.new(
|
27
|
-
raise ArgumentError.new("
|
28
|
-
raise ArgumentError.new("Bank number cannot be 0") if @bank_number && @bank_number == 0
|
29
|
-
raise ArgumentError.new("Street and/or Zip Code too long, max 35 allowed") if @bank_street && @bank_zip_code && "#{@bank_street} #{@bank_zip_code}".length > 35
|
30
|
-
raise ArgumentError.new("City too long, max 35 allowed") if @bank_city && @bank_city.length > 35
|
31
|
-
raise ArgumentError.new("Bank Name too long, max 35 allowed") if @bank_name && @bank_name.length > 35
|
32
|
-
raise ArgumentError.new("Client Street and/or Zip Code too long, max 35 allowed") if @client_street && @client_zip_code && "#{@client_street} #{@client_zip_code}".length > 35
|
33
|
-
raise ArgumentError.new("Client City too long, max 35 allowed") if @client_city && @client_city.length > 35
|
34
|
-
raise ArgumentError.new("Bank Country code too long, max 2 allowed") if @bank_country_code && @bank_country_code.length > 2
|
35
|
-
raise ArgumentError.new("Client Country code too long, max 2 allowed") if @client_country_code && @client_country_code.length > 2
|
28
|
+
raise ArgumentError.new('Owner number too long, max 10 allowed') if @owner_number && "#{@owner_number}".length > 10
|
29
|
+
raise ArgumentError.new("Owner street too long, max 35 allowed") if @owner_street && @owner_street.length > 35
|
30
|
+
raise ArgumentError.new("Owner city too long, max 35 allowed") if @owner_city && @owner_city.length > 35
|
31
|
+
raise ArgumentError.new("Owner country code too long, max 2 allowed") if @owner_country_code && @owner_country_code.length > 2
|
36
32
|
|
37
|
-
|
33
|
+
raise ArgumentError.new('Bank account number too long, max 10 allowed') if @bank_account_number && "#{@bank_account_number}".length > 10
|
34
|
+
raise ArgumentError.new("Bank account number cannot be 0") if @bank_account_number && @bank_account_number == 0
|
35
|
+
raise ArgumentError.new("Bank iban wrong length: #{@bank_iban.length}, must be between 15-34") if @bank_iban && !@bank_iban.length.between?(15,34)
|
36
|
+
raise ArgumentError.new("Bank bic wrong length: #{@bank_bic.length} must be between 8-11") if @bank_bic && !@bank_bic.length.between?(8,11)
|
37
|
+
raise ArgumentError.new('Bank number too long, max 8 allowed') if @bank_number && "#{@bank_number}".length > 8
|
38
|
+
raise ArgumentError.new("Bank number cannot be 0") if @bank_number && @bank_number == 0
|
39
|
+
raise ArgumentError.new("Bank street too long, max 35 allowed") if @bank_street && @bank_street.length > 35
|
40
|
+
raise ArgumentError.new("Bank city too long, max 35 allowed") if @bank_city && @bank_city.length > 35
|
41
|
+
raise ArgumentError.new("Bank name too long, max 35 allowed") if @bank_name && @bank_name.length > 35
|
42
|
+
raise ArgumentError.new("Bank country code too long, max 2 allowed") if @bank_country_code && @bank_country_code.length > 2
|
38
43
|
|
39
|
-
|
40
|
-
def client_firstname
|
41
|
-
@client_name.split(' ')[0]
|
42
|
-
end
|
44
|
+
@owner_country_code = @bank_iban[0..1 ] if @bank_iban && !@owner_country_code
|
43
45
|
|
44
|
-
def client_surname
|
45
|
-
@client_name.split(' ')[1]
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
"#{@
|
48
|
+
def bank_zip_city
|
49
|
+
"#{@bank_zip} #{@bank_city}"
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
53
|
-
"#{@
|
52
|
+
def owner_zip_city
|
53
|
+
"#{@owner_zip_code} #{@owner_city}"
|
54
54
|
end
|
55
55
|
|
56
56
|
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
|