king_dtaus 2.0.1.pre → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +0 -1
- data/README.markdown +128 -0
- data/Rakefile +16 -16
- data/king_dtaus.gemspec +22 -61
- data/lib/king_dta/account.rb +47 -28
- data/lib/king_dta/dta.rb +10 -0
- data/lib/king_dta/dtaus.rb +126 -135
- data/lib/king_dta/dtazv.rb +186 -227
- data/lib/king_dta/helper.rb +3 -1
- data/lib/king_dta/version.rb +3 -0
- data/lib/king_dtaus.rb +1 -0
- data/spec/account_spec.rb +90 -154
- data/spec/booking_spec.rb +1 -3
- data/spec/dtaus_spec.rb +35 -12
- data/spec/dtazv_spec.rb +54 -155
- data/spec/spec_helper.rb +44 -66
- metadata +121 -111
- data/.rvmrc +0 -1
- data/Gemfile.lock +0 -38
- data/README.rdoc +0 -120
- data/VERSION +0 -1
- data/docs/dtazv.pdf +0 -0
- data/docs/dtazv_bank_bbk.pdf +0 -0
- data/example.output +0 -7
- data/spec/dtazv_test.rb +0 -105
data/.gitignore
ADDED
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,25 +1,25 @@
|
|
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
9
|
|
7
10
|
task :default => :spec
|
8
11
|
|
9
|
-
|
12
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
13
|
+
t.rcov = true
|
14
|
+
t.rcov_opts = %q[--exclude "spec"]
|
15
|
+
t.verbose = true
|
16
|
+
end
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
gem.homepage = "http://github.com/salesking/king_dtaus"
|
19
|
-
gem.authors = ["Georg Leciejewski", "Georg Ledermann"]
|
20
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
|
-
end
|
22
|
-
Jeweler::GemcutterTasks.new
|
23
|
-
rescue LoadError
|
24
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
desc 'Generate documentation'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'docs/rdoc'
|
21
|
+
rdoc.title = 'KingPdf'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
25
|
end
|
data/king_dtaus.gemspec
CHANGED
@@ -1,75 +1,36 @@
|
|
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 = ["Georg Leciejewski", "Georg Ledermann"]
|
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
17
|
s.extra_rdoc_files = [
|
16
|
-
"README.
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".rvmrc",
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"MIT-LICENSE",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"docs/dtazv.pdf",
|
27
|
-
"docs/dtazv_bank_bbk.pdf",
|
28
|
-
"example.output",
|
29
|
-
"king_dtaus.gemspec",
|
30
|
-
"lib/king_dta/account.rb",
|
31
|
-
"lib/king_dta/booking.rb",
|
32
|
-
"lib/king_dta/dta.rb",
|
33
|
-
"lib/king_dta/dtaus.rb",
|
34
|
-
"lib/king_dta/dtazv.rb",
|
35
|
-
"lib/king_dta/exception.rb",
|
36
|
-
"lib/king_dta/helper.rb",
|
37
|
-
"lib/king_dtaus.rb",
|
38
|
-
"spec/account_spec.rb",
|
39
|
-
"spec/booking_spec.rb",
|
40
|
-
"spec/dtaus_spec.rb",
|
41
|
-
"spec/dtazv_spec.rb",
|
42
|
-
"spec/dtazv_test.rb",
|
43
|
-
"spec/helper_spec.rb",
|
44
|
-
"spec/spec_helper.rb"
|
18
|
+
"README.markdown"
|
45
19
|
]
|
20
|
+
s.executables = nil
|
21
|
+
s.files = `git ls-files`.split("\n").reject{|i| i[/^docs\//] }
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
|
46
24
|
s.homepage = %q{http://github.com/salesking/king_dtaus}
|
47
25
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = %q{1.
|
49
|
-
s.summary = %q{Generate DTAUS strings and files}
|
26
|
+
s.rubygems_version = %q{1.6.2}
|
50
27
|
|
51
|
-
|
52
|
-
|
28
|
+
s.add_runtime_dependency 'i18n'
|
29
|
+
s.add_development_dependency 'rdoc'
|
30
|
+
s.add_development_dependency 'rspec'
|
31
|
+
s.add_development_dependency 'simplecov'
|
32
|
+
s.add_development_dependency 'mocha'
|
33
|
+
s.add_development_dependency 'rake', '>= 0.9.2'
|
53
34
|
|
54
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_runtime_dependency(%q<king_dtaus>, [">= 0"])
|
56
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
57
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
59
|
-
s.add_development_dependency(%q<mocha>, [">= 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
|
-
end
|
67
|
-
else
|
68
|
-
s.add_dependency(%q<king_dtaus>, [">= 0"])
|
69
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
70
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
71
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
72
|
-
s.add_dependency(%q<mocha>, [">= 0"])
|
73
|
-
end
|
74
35
|
end
|
75
36
|
|
data/lib/king_dta/account.rb
CHANGED
@@ -1,55 +1,74 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module KingDta
|
3
|
-
#
|
3
|
+
# Bank account and owner information
|
4
4
|
class Account
|
5
5
|
include KingDta::Helper
|
6
|
-
# dta~ jeweilige Feld in DTAUS-Norm
|
7
|
-
attr_accessor :account_number, :bank_number, :client_number, :bank_street, :bank_city, :bank_zip_code, :bank_name,
|
8
|
-
:client_name, :client_street, :client_city, :client_zip_code, :bank_country_code, :client_country_code
|
9
6
|
|
10
|
-
|
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
|
+
|
11
14
|
def initialize(args={})
|
12
15
|
|
13
16
|
@bank_street = convert_text(args.delete(:bank_street))
|
14
17
|
@bank_city = convert_text(args.delete(:bank_city))
|
15
18
|
@bank_name = convert_text(args.delete(:bank_name))
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
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))
|
19
22
|
|
20
23
|
args.each do |key,value|
|
21
24
|
self.send("#{key}=",value)
|
22
25
|
end
|
23
26
|
|
24
|
-
raise ArgumentError.new('
|
25
|
-
raise ArgumentError.new('
|
26
|
-
raise ArgumentError.new('
|
27
|
-
raise ArgumentError.new(
|
28
|
-
|
29
|
-
|
30
|
-
raise ArgumentError.new("
|
31
|
-
raise ArgumentError.new("Bank
|
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
|
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)
|
36
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
|
37
42
|
end
|
38
43
|
|
39
|
-
|
40
|
-
|
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
|
+
raise ArgumentError.new('Bank account number too long, max 10 allowed') if "#{number}".length > 10
|
50
|
+
raise ArgumentError.new('Bank account number cannot be 0') if number == 0
|
51
|
+
|
52
|
+
@bank_account_number = number.is_a?(String) ? number.gsub(/\s/,'').to_i : number
|
41
53
|
end
|
42
54
|
|
43
|
-
|
44
|
-
|
55
|
+
# Cast given bank number to integer. Strips spaces and leading zeros
|
56
|
+
# from the bank account number.
|
57
|
+
# DTA relies on integers for checksums and field values.
|
58
|
+
# @param [String|Integer] number
|
59
|
+
def bank_number=(number)
|
60
|
+
raise ArgumentError.new('Bank number too long, max 8 allowed') if "#{number}".length > 8
|
61
|
+
raise ArgumentError.new('Bank number cannot be 0') if number == 0
|
62
|
+
|
63
|
+
@bank_number = number.is_a?(String) ? number.gsub(/\s/,'').to_i : number
|
45
64
|
end
|
46
65
|
|
47
|
-
def
|
48
|
-
"#{@
|
66
|
+
def bank_zip_city
|
67
|
+
"#{@bank_zip} #{@bank_city}"
|
49
68
|
end
|
50
69
|
|
51
|
-
def
|
52
|
-
"#{@
|
70
|
+
def owner_zip_city
|
71
|
+
"#{@owner_zip_code} #{@owner_city}"
|
53
72
|
end
|
54
73
|
|
55
74
|
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
|