king_dtaus 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/king_dtaus.gemspec +2 -2
- data/lib/king_dta/account.rb +12 -10
- data/lib/king_dta/dtaus.rb +27 -25
- data/spec/account_spec.rb +15 -4
- data/spec/dtaus_spec.rb +16 -16
- data/spec/spec_helper.rb +1 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/king_dtaus.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{king_dtaus}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Georg Leciejewski", "Georg Ledermann"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-10}
|
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 = [
|
data/lib/king_dta/account.rb
CHANGED
@@ -4,18 +4,20 @@ module KingDta
|
|
4
4
|
class Account
|
5
5
|
include KingDta::Helper
|
6
6
|
# dta~ jeweilige Feld in DTAUS-Norm
|
7
|
-
attr_reader :bank_account_number, :bank_number, :owner, :
|
7
|
+
attr_reader :bank_account_number, :bank_number, :owner, :client_number
|
8
8
|
|
9
|
-
def initialize( ban, bank_number, owner,
|
10
|
-
|
11
|
-
@
|
9
|
+
def initialize( ban, bank_number, owner, client_number="" )
|
10
|
+
|
11
|
+
@bank_account_number = ban.kind_of?( Integer ) ? ban : ban.gsub(/\s/, '').to_i
|
12
|
+
@bank_number = bank_number.kind_of?( Integer ) ? bank_number : bank_number.gsub(/\s/, '').to_i
|
13
|
+
@client_number = client_number.kind_of?( Integer ) ? client_number : client_number.gsub(/\s/, '').to_i
|
12
14
|
@owner= convert_text( owner )
|
13
|
-
|
14
|
-
|
15
|
-
raise
|
16
|
-
raise
|
17
|
-
raise
|
18
|
-
|
15
|
+
|
16
|
+
raise ArgumentError.new('Bank account number too long, max 10 allowed') if "#{@bank_account_number}".length > 10
|
17
|
+
raise ArgumentError.new('Bank number too long, max 8 allowed') if "#{@bank_number}".length > 8
|
18
|
+
raise ArgumentError.new('Client number too long, max 10 allowed') if "#{@client_number}".length > 10
|
19
|
+
raise ArgumentError.new("Bank account number cannot be 0") if @bank_account_number == 0
|
20
|
+
raise ArgumentError.new("Bank number cannot be 0") if @bank_number == 0
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
data/lib/king_dta/dtaus.rb
CHANGED
@@ -10,7 +10,7 @@ module KingDta
|
|
10
10
|
attr_reader :sum_bank_account_numbers, :sum_bank_numbers, :sum_values, :default_text
|
11
11
|
|
12
12
|
# Create a new dtaus file/string.
|
13
|
-
#
|
13
|
+
# === Parameter
|
14
14
|
# typ<String>:: valid strings are 'LK' (Lastschrift Kunde) and 'GK' (Gutschrift Kunde)
|
15
15
|
# typ<Date>:: date when the the transfer is to be created
|
16
16
|
def initialize( typ, date=Date.today )
|
@@ -110,11 +110,11 @@ module KingDta
|
|
110
110
|
# 7 50 6 Zeichen aktuelles Datum im Format DDMMJJ
|
111
111
|
# 8 56 4 Zeichen CST, " " (Blanks)
|
112
112
|
# 9 60 10 Zeichen Kontonummer des Auftraggebers
|
113
|
-
# 10
|
113
|
+
# 10 70 10 Zeichen Optionale Referenznummer
|
114
114
|
# 11a 80 15 Zeichen Reserviert, 15 Blanks
|
115
115
|
# 11b 95 8 Zeichen Ausführungsdatum im Format DDMMJJJJ. Nicht jünger als Erstellungsdatum (A7), jedoch höchstens 15 Kalendertage später. Sonst Blanks.
|
116
116
|
# 11c 103 24 Zeichen Reserviert, 24 Blanks
|
117
|
-
# 12
|
117
|
+
# 12 127 1 Zeichen Währungskennzeichen
|
118
118
|
# " " = DM
|
119
119
|
# "1" = Euro
|
120
120
|
# Insgesamt 128 Zeichen
|
@@ -163,33 +163,35 @@ module KingDta
|
|
163
163
|
# Die im Textschlüssel mit J bezeichnete Stelle, wird bei Übernahme in eine Zahlung automatisch mit der jeweils aktuellen Jahresendziffer (7, wenn 97) ersetzt.
|
164
164
|
# 8 49 1 Zeichen Reserviert, " " (Blank)
|
165
165
|
# 9 50 11 Zeichen Betrag in DM
|
166
|
-
# 10
|
167
|
-
# 11
|
168
|
-
# 12
|
169
|
-
# 13
|
166
|
+
# 10 61 8 Zeichen Bankleitzahl des Auftraggebers
|
167
|
+
# 11 69 10 Zeichen Kontonummer des Auftraggebers
|
168
|
+
# 12 79 11 Zeichen Betrag in Euro einschließlich Nachkommastellen, nur belegt, wenn Euro als Währung angegeben wurde (A12, C17a), sonst Nullen
|
169
|
+
# 13 90 3 Zeichen Reserviert, 3 Blanks
|
170
170
|
# 14a 93 27 Zeichen Name des Kunden
|
171
171
|
# 14b 120 8 Zeichen Reserviert, 8 Blanks
|
172
172
|
# Insgesamt 128 Zeichen
|
173
173
|
#
|
174
|
-
# 15
|
175
|
-
# 16
|
174
|
+
# 15 128 27 Zeichen Name des Auftraggebers
|
175
|
+
# 16 155 27 Zeichen Verwendungszweck
|
176
176
|
# 17a 182 1 Zeichen Währungskennzeichen
|
177
177
|
# " " = DM
|
178
178
|
# "1" = Euro
|
179
179
|
# 17b 183 2 Zeichen Reserviert, 2 Blanks
|
180
|
-
# 18
|
181
|
-
# 19
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
# 20
|
186
|
-
# 21
|
187
|
-
# 22
|
188
|
-
# 23
|
180
|
+
# 18 185 2 Zeichen Anzahl der Erweiterungsdatensätze, "00" bis "15"
|
181
|
+
# 19 187 2 Zeichen Typ (1. Erweiterungsdatensatz)
|
182
|
+
# "01" Name des Kunden
|
183
|
+
# "02" Verwendungszweck
|
184
|
+
# "03" Name des Auftraggebers
|
185
|
+
# 20 189 27 Zeichen Beschreibung gemäß Typ
|
186
|
+
# 21 216 2 Zeichen wie C19, oder Blanks (2. Erweiterungsdatensatz)
|
187
|
+
# 22 218 27 Zeichen wie C20, oder Blanks
|
188
|
+
# 23 245 11 Zeichen 11 Blanks
|
189
189
|
# Insgesamt 256 Zeichen, kann wiederholt werden (max 3 mal)
|
190
|
-
#
|
190
|
+
#
|
191
|
+
# === Parameter
|
191
192
|
# booking<Object>::Booking object to be written to c-sektion
|
192
|
-
#
|
193
|
+
#
|
194
|
+
# === Returns
|
193
195
|
# <String>:: The current dta_string
|
194
196
|
def add_c( booking )
|
195
197
|
zahlungsart = if @typ == 'LK'
|
@@ -207,7 +209,7 @@ module KingDta
|
|
207
209
|
data1 += '%08i' % 0 #freigestellt
|
208
210
|
data1 += '%08i' % booking.account.bank_number
|
209
211
|
data1 += '%010i' % booking.account.bank_account_number
|
210
|
-
data1 += '0%011i0' % booking.account.
|
212
|
+
data1 += '0%011i0' % booking.account.client_number #interne Kundennummer
|
211
213
|
data1 += zahlungsart
|
212
214
|
data1 += ' ' #bankintern
|
213
215
|
data1 += '0' * 11 #Reserve
|
@@ -238,7 +240,7 @@ module KingDta
|
|
238
240
|
data2 += ' ' * 2
|
239
241
|
# Gesamte Satzlänge ermitteln ( data1(+4) + data2 + Erweiterungen )
|
240
242
|
data1 = "%04i#{data1}" % ( data1.size + 4 + data2.size+ 2 + exts.size * 29 )
|
241
|
-
raise "DTAUS: Längenfehler C/1 #{data1.size}, #{booking.account.
|
243
|
+
raise "DTAUS: Längenfehler C/1 #{data1.size} nicht 128, #{booking.account.owner}" unless data1.size == 128
|
242
244
|
dta_string << data1
|
243
245
|
#Anzahl Erweiterungen anfügen
|
244
246
|
data2 += '%02i' % exts.size #Anzahl Erweiterungsteile
|
@@ -249,7 +251,7 @@ module KingDta
|
|
249
251
|
exts[0..1].each{|e| data2 += "%2.2s%-27.27s" % format_ext(e[0], e[1]) }
|
250
252
|
data2 += ' ' * 11
|
251
253
|
# add the final piece of the second C section
|
252
|
-
raise "DTAUS: Längenfehler C/2 #{data2.size}, #{booking.account.
|
254
|
+
raise "DTAUS: Längenfehler C/2 #{data2.size} nicht 128, #{booking.account.owner}" unless data2.size == 128
|
253
255
|
dta_string << data2
|
254
256
|
#Erstellen der Texterweiterungen à vier Stück
|
255
257
|
add_ext( exts[2..5] )
|
@@ -259,7 +261,7 @@ module KingDta
|
|
259
261
|
end #dataC
|
260
262
|
|
261
263
|
# Format an extension so it can be used in string substitution
|
262
|
-
#
|
264
|
+
# === Returns
|
263
265
|
# Array[String, String]::[Extesnsion type(01 02 03), 'text content ..']
|
264
266
|
def format_ext(type, content)
|
265
267
|
ext = ( type == '00' ) ? [' ', ' '] : [ type, convert_text(content) ]
|
@@ -269,7 +271,7 @@ module KingDta
|
|
269
271
|
# Add a section-C extension, always containing the section type followed by
|
270
272
|
# 4 segments with 27 chars and an ending seperator of 12 blanks
|
271
273
|
# Only adds the segement if something is in there
|
272
|
-
#
|
274
|
+
# === Parameter
|
273
275
|
# <Array[Array[String,String]]>:: two dim. ary containing: [extension type(01 02 03),string content]
|
274
276
|
def add_ext( ext)
|
275
277
|
raise "Nur #{ext.size} Erweiterungstexte, 4 benötigt" if ext.size != 4
|
data/spec/account_spec.rb
CHANGED
@@ -3,19 +3,30 @@ require "#{File.dirname(__FILE__)}/spec_helper"
|
|
3
3
|
describe KingDta::Account do
|
4
4
|
|
5
5
|
before :each do
|
6
|
-
@
|
6
|
+
@ba = test_kto2 # BankAccount mocked as open struct
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should initialize a new account" do
|
10
|
-
lambda{ KingDta::Account.new(@
|
10
|
+
lambda{ KingDta::Account.new(@ba.nr, @ba.blz, @ba.name) }.should_not raise_error
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should fail if bank account number is invalid" do
|
14
|
-
|
14
|
+
# not 0
|
15
|
+
lambda{ KingDta::Account.new(0, @ba.blz, @ba.name) }.should raise_error(ArgumentError)
|
16
|
+
# max 10
|
17
|
+
lambda{ KingDta::Account.new(123456789011, @ba.blz, @ba.name) }.should raise_error(ArgumentError, 'Bank account number too long, max 10 allowed')
|
15
18
|
end
|
16
19
|
|
17
20
|
it "should fail if bank number is invalid" do
|
18
|
-
|
21
|
+
# not 0
|
22
|
+
lambda{ KingDta::Account.new(@ba.nr, 0, @ba.name) }.should raise_error(ArgumentError)
|
23
|
+
# max 8
|
24
|
+
lambda{ KingDta::Account.new(@ba.nr, 123456789, @ba.name) }.should raise_error(ArgumentError, 'Bank number too long, max 8 allowed')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should fail if clent number is too long" do
|
28
|
+
# max 10
|
29
|
+
lambda{ KingDta::Account.new(@ba.nr, @ba.blz, @ba.name, 12345678901) }.should raise_error(ArgumentError, 'Client number too long, max 10 allowed')
|
19
30
|
end
|
20
31
|
|
21
32
|
end
|
data/spec/dtaus_spec.rb
CHANGED
@@ -52,10 +52,10 @@ describe KingDta::Dtaus do
|
|
52
52
|
it "should create header" do
|
53
53
|
str = @dtaus.add_a
|
54
54
|
str.length.should == 128
|
55
|
-
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")}
|
55
|
+
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"
|
56
56
|
str.should == out
|
57
|
-
#60-70 kontonummer mit nullen aufgefüllt
|
58
|
-
str[60...70].should == "
|
57
|
+
#60-70 kontonummer mit nullen aufgefüllt - hier nicht da ktnr == 10 stellen
|
58
|
+
str[60...70].should == "#{test_kto1.nr}"
|
59
59
|
str.should include(test_kto1.blz)
|
60
60
|
end
|
61
61
|
|
@@ -74,7 +74,7 @@ describe KingDta::Dtaus do
|
|
74
74
|
str = @dtaus.dta_string
|
75
75
|
str.length.should == 256
|
76
76
|
str.should include(@kto2.name.upcase)
|
77
|
-
out = "0216C00000000370400440002787777000000000000005000
|
77
|
+
out = "0216C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGSALESKING MONATSBEITRAG 08/1 010210 FREELANCER VERSION "
|
78
78
|
str.should == out
|
79
79
|
end
|
80
80
|
|
@@ -84,7 +84,7 @@ describe KingDta::Dtaus do
|
|
84
84
|
str = @dtaus.dta_string
|
85
85
|
str.length.should == 256
|
86
86
|
str.should include(@kto2.name.upcase)
|
87
|
-
out = "0187C00000000370400440002787777000000000000005000
|
87
|
+
out = "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "
|
88
88
|
str.should == out
|
89
89
|
end
|
90
90
|
|
@@ -96,8 +96,8 @@ describe KingDta::Dtaus do
|
|
96
96
|
str.should include(@kto1.name.upcase)
|
97
97
|
str.should include(@kto2.name.upcase)
|
98
98
|
str.should include(@dtaus.default_text.upcase)
|
99
|
-
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")}
|
100
|
-
"0187C00000000370400440002787777000000000000005000
|
99
|
+
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
100
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
101
101
|
"0128E 0000001000000000000000000000002787777000000000370400440000000022025 "
|
102
102
|
str.should == out
|
103
103
|
end
|
@@ -108,8 +108,8 @@ describe KingDta::Dtaus do
|
|
108
108
|
str = @dtaus.create
|
109
109
|
str.length.should == 640
|
110
110
|
str.should include(@kto2.name.upcase)
|
111
|
-
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")}
|
112
|
-
"0274C00000000370400440002787777000000000000005000
|
111
|
+
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
112
|
+
"0274C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGRGN R-3456-0102220 MONATSBE1 0302ITRAG 08/10 FREELANCER VERS02ION VIELEN DANK IHRE SALESK 02ING GMBH "+
|
113
113
|
"0128E 0000001000000000000000000000002787777000000000370400440000000022025 "
|
114
114
|
str.should == out
|
115
115
|
end
|
@@ -122,13 +122,13 @@ describe KingDta::Dtaus do
|
|
122
122
|
str.should include(@kto1.name.upcase)
|
123
123
|
str.should include(@kto2.name.upcase)
|
124
124
|
str.should include(@dtaus.default_text.upcase)
|
125
|
-
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")}
|
126
|
-
"0187C00000000370400440002787777000000000000005000
|
127
|
-
"0187C00000000370400440002787777000000000000005000
|
128
|
-
"0187C00000000370400440002787777000000000000005000
|
129
|
-
"0187C00000000370400440002787777000000000000005000
|
130
|
-
"0187C00000000370400440002787777000000000000005000
|
131
|
-
"0187C00000000370400440002787777000000000000005000
|
125
|
+
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
126
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
127
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
128
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
129
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
130
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
131
|
+
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
132
132
|
"0128E 0000006000000000000000000000016726662000000002222402640000000132150 "
|
133
133
|
str.should == out
|
134
134
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -22,7 +22,7 @@ require "#{File.dirname(__FILE__)}/../lib/king_dtaus"
|
|
22
22
|
# bankplz:0815
|
23
23
|
# bankort:Felsblock
|
24
24
|
def test_kto1
|
25
|
-
opts = { :nr => '
|
25
|
+
opts = { :nr => '7828970037', :blz => '37040044', :name =>'Gimme your Money AG',
|
26
26
|
:bank => 'Commerzbank Köln', :zweck => 'Monatsbeitrag' }
|
27
27
|
TestKonto.new(opts)
|
28
28
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: king_dtaus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Georg Leciejewski
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-02-
|
19
|
+
date: 2011-02-10 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|