king_dtaus 1.0.2 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/DTAUS0.TXT +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +38 -0
- data/README.rdoc +87 -20
- data/Rakefile +5 -25
- data/VERSION +1 -1
- data/docs/dtazv.pdf +0 -0
- data/docs/dtazv_bank_bbk.pdf +0 -0
- data/example.output +7 -0
- data/king_dtaus.gemspec +31 -11
- data/lib/king_dta/account.rb +48 -15
- data/lib/king_dta/booking.rb +4 -4
- data/lib/king_dta/dta.rb +53 -0
- data/lib/king_dta/dtaus.rb +22 -68
- data/lib/king_dta/dtazv.rb +470 -0
- data/lib/king_dtaus.rb +7 -5
- data/spec/account_spec.rb +140 -13
- data/spec/booking_spec.rb +4 -3
- data/spec/dtaus_spec.rb +44 -23
- data/spec/dtazv_spec.rb +294 -0
- data/spec/dtazv_test.rb +105 -0
- data/spec/helper_spec.rb +3 -4
- data/spec/spec_helper.rb +80 -7
- metadata +91 -20
data/spec/account_spec.rb
CHANGED
@@ -1,32 +1,159 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
2
3
|
|
3
4
|
describe KingDta::Account do
|
4
5
|
|
5
6
|
before :each do
|
6
7
|
@ba = test_kto2 # BankAccount mocked as open struct
|
8
|
+
@dudes_konto = dudes_konto
|
7
9
|
end
|
8
10
|
|
9
11
|
it "should initialize a new account" do
|
10
|
-
lambda{ KingDta::Account.new(@ba.
|
12
|
+
lambda{ KingDta::Account.new(:account_number => @ba.account_number, :bank_number => @ba.bank_number, :client_name => @ba.client_name) }.should_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should initialize a new dtazv account" do
|
16
|
+
lambda{ KingDta::Account.new(
|
17
|
+
:account_number => @dudes_konto.account_number,
|
18
|
+
:bank_number => @dudes_konto.bank_number,
|
19
|
+
:client_name => @dudes_konto.client_name,
|
20
|
+
:client_number => @dudes_konto.client_number,
|
21
|
+
:bank_street => @dudes_konto.account_street,
|
22
|
+
:bank_city => @dudes_konto.account_city,
|
23
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
24
|
+
:bank_name => @dudes_konto.bank_name,
|
25
|
+
:client_street => @dudes_konto.client_street,
|
26
|
+
:client_city => @dudes_konto.client_city,
|
27
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
28
|
+
)}.should_not raise_error
|
11
29
|
end
|
12
30
|
|
13
31
|
it "should fail if bank account number is invalid" do
|
14
|
-
#
|
15
|
-
lambda{ KingDta::Account.new(
|
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')
|
32
|
+
# lambda{ KingDta::Account.new(0, @ba.bank_number, @ba.client_name) }.should raise_error(ArgumentError)
|
33
|
+
lambda{ KingDta::Account.new(:account_number => 123456789011123456789011123456789011123456789011123456789011123456789011, :bank_number => @ba.bank_number, :client_name => @ba.client_name) }.should raise_error(ArgumentError, 'Account number too long, max 35 allowed')
|
18
34
|
end
|
19
35
|
|
20
36
|
it "should fail if bank number is invalid" do
|
21
|
-
|
22
|
-
lambda{ KingDta::Account.new(@ba.
|
23
|
-
# max 8
|
24
|
-
lambda{ KingDta::Account.new(@ba.nr, 123456789, @ba.name) }.should raise_error(ArgumentError, 'Bank number too long, max 8 allowed')
|
37
|
+
lambda{ KingDta::Account.new(:account_number => @ba.account_number, :bank_number => 0, :client_name => @ba.client_name) }.should raise_error(ArgumentError)
|
38
|
+
lambda{ KingDta::Account.new(:account_number => @ba.account_number, :bank_number => 123456789101112, :client_name => @ba.client_name) }.should raise_error(ArgumentError, 'Bank number too long, max 11 allowed')
|
25
39
|
end
|
26
40
|
|
27
41
|
it "should fail if clent number is too long" do
|
28
|
-
|
29
|
-
lambda{ KingDta::Account.new(@ba.nr, @ba.blz, @ba.name, 12345678901) }.should raise_error(ArgumentError, 'Client number too long, max 10 allowed')
|
42
|
+
lambda{ KingDta::Account.new(:account_number => @ba.account_number, :bank_number => @ba.bank_number, :client_name => @ba.client_name, :client_number => 12345678901) }.should raise_error(ArgumentError, 'Client number too long, max 10 allowed')
|
30
43
|
end
|
31
|
-
|
44
|
+
|
45
|
+
it "should fail if street and/or Zip Code is too long" do
|
46
|
+
lambda{ KingDta::Account.new(
|
47
|
+
:account_number => @dudes_konto.account_number,
|
48
|
+
:bank_number => @dudes_konto.bank_number,
|
49
|
+
:client_name => @dudes_konto.client_name,
|
50
|
+
:client_number => @dudes_konto.client_number,
|
51
|
+
:bank_street => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
52
|
+
:bank_city => @dudes_konto.account_city,
|
53
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
54
|
+
:bank_name => @dudes_konto.bank_name,
|
55
|
+
:client_street => @dudes_konto.client_street,
|
56
|
+
:client_city => @dudes_konto.client_city,
|
57
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
58
|
+
)}.should raise_error(ArgumentError, 'Street and/or Zip Code too long, max 35 allowed')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should fail if city is too long" do
|
62
|
+
lambda{ KingDta::Account.new(
|
63
|
+
:account_number => @dudes_konto.account_number,
|
64
|
+
:bank_number => @dudes_konto.bank_number,
|
65
|
+
:client_name => @dudes_konto.client_name,
|
66
|
+
:client_number => @dudes_konto.client_number,
|
67
|
+
:bank_street => @dudes_konto.account_street,
|
68
|
+
:bank_city => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
69
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
70
|
+
:bank_name => @dudes_konto.account_bank_name,
|
71
|
+
:client_street => @dudes_konto.client_street,
|
72
|
+
:client_city => @dudes_konto.client_city,
|
73
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
74
|
+
)}.should raise_error(ArgumentError, 'City too long, max 35 allowed')
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should fail if bank name is too long" do
|
78
|
+
lambda{ KingDta::Account.new(
|
79
|
+
:account_number => @dudes_konto.account_number,
|
80
|
+
:bank_number => @dudes_konto.bank_number,
|
81
|
+
:client_name => @dudes_konto.client_name,
|
82
|
+
:client_number => @dudes_konto.client_number,
|
83
|
+
:bank_street => @dudes_konto.account_street,
|
84
|
+
:bank_city => @dudes_konto.account_city,
|
85
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
86
|
+
:bank_name => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
87
|
+
:client_street => @dudes_konto.client_street,
|
88
|
+
:client_city => @dudes_konto.client_city,
|
89
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
90
|
+
)}.should raise_error(ArgumentError, 'Bank Name too long, max 35 allowed')
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should fail if sender street and/or zipcode is too long" do
|
94
|
+
lambda{ KingDta::Account.new(
|
95
|
+
:account_number => @dudes_konto.account_number,
|
96
|
+
:bank_number => @dudes_konto.bank_number,
|
97
|
+
:client_name => @dudes_konto.client_name,
|
98
|
+
:client_number => @dudes_konto.client_number,
|
99
|
+
:bank_street => @dudes_konto.account_street,
|
100
|
+
:bank_city => @dudes_konto.account_city,
|
101
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
102
|
+
:bank_name => @dudes_konto.bank_name,
|
103
|
+
:client_street => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
104
|
+
:client_city => @dudes_konto.client_city,
|
105
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
106
|
+
)}.should raise_error(ArgumentError, 'Client Street and/or Zip Code too long, max 35 allowed')
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should fail if city is too long" do
|
110
|
+
lambda{ KingDta::Account.new(
|
111
|
+
:account_number => @dudes_konto.account_number,
|
112
|
+
:bank_number => @dudes_konto.bank_number,
|
113
|
+
:client_name => @dudes_konto.client_name,
|
114
|
+
:client_number => @dudes_konto.client_number,
|
115
|
+
:bank_street => @dudes_konto.account_street,
|
116
|
+
:bank_city => @dudes_konto.account_city,
|
117
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
118
|
+
:bank_name => @dudes_konto.bank_name,
|
119
|
+
:client_street => @dudes_konto.client_street,
|
120
|
+
:client_city => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
121
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
122
|
+
)}.should raise_error(ArgumentError, 'Client City too long, max 35 allowed')
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should return account street and zip" do
|
126
|
+
konto = KingDta::Account.new(
|
127
|
+
:account_number => @dudes_konto.account_number,
|
128
|
+
:bank_number => @dudes_konto.bank_number,
|
129
|
+
:client_name => @dudes_konto.client_name,
|
130
|
+
:client_number => @dudes_konto.client_number,
|
131
|
+
:bank_street => @dudes_konto.account_street,
|
132
|
+
:bank_city => @dudes_konto.account_city,
|
133
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
134
|
+
:bank_name => @dudes_konto.bank_name,
|
135
|
+
:client_street => @dudes_konto.client_street,
|
136
|
+
:client_city => @dudes_konto.client_city,
|
137
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
138
|
+
)
|
139
|
+
konto.zip_city.should == "51063 BANK KOELN"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should return sender street and zip" do
|
143
|
+
konto = KingDta::Account.new(
|
144
|
+
:account_number => @dudes_konto.account_number,
|
145
|
+
:bank_number => @dudes_konto.bank_number,
|
146
|
+
:client_name => @dudes_konto.client_name,
|
147
|
+
:client_number => @dudes_konto.client_number,
|
148
|
+
:bank_street => @dudes_konto.account_street,
|
149
|
+
:bank_city => @dudes_konto.account_city,
|
150
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
151
|
+
:bank_name => @dudes_konto.bank_name,
|
152
|
+
:client_street => @dudes_konto.client_street,
|
153
|
+
:client_city => @dudes_konto.client_city,
|
154
|
+
:client_zip_code => @dudes_konto.client_zip_code
|
155
|
+
)
|
156
|
+
konto.client_zip_city.should == "51063 MEINE KOELN"
|
157
|
+
end
|
158
|
+
|
32
159
|
end
|
data/spec/booking_spec.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
2
3
|
|
3
4
|
describe KingDta::Booking do
|
4
5
|
|
5
6
|
before :each do
|
6
7
|
kto1 = test_kto1
|
7
8
|
kto2 = test_kto2
|
8
|
-
@account = KingDta::Account.new( kto2.
|
9
|
+
@account = KingDta::Account.new(:account_number => kto2.account_number, :bank_number => kto2.bank_number, :client_name => kto2.client_name, :bank_name => kto2.bank_name )
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should have no rounding error for string" do
|
@@ -31,7 +32,7 @@ describe KingDta::Booking do
|
|
31
32
|
b.value.should == 100
|
32
33
|
b.should_not be_pos
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
it "should have no rounding error for float" do
|
36
37
|
booking = KingDta::Booking.new(@account, 159.73)
|
37
38
|
booking.value.should == 15973
|
data/spec/dtaus_spec.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
3
|
# All Test DTA output strings are validated with sFirm => lokal Sparkassen Software
|
4
4
|
describe KingDta::Dtaus do
|
5
5
|
|
6
6
|
before :each do
|
7
7
|
@dtaus = KingDta::Dtaus.new('LK', Date.today)
|
8
|
+
@dtaus_gk = KingDta::Dtaus.new('GK', Date.today)
|
8
9
|
@kto1 = test_kto1
|
9
10
|
@kto2 = test_kto2
|
10
|
-
@dtaus.account = KingDta::Account.new( @kto1.
|
11
|
-
@
|
12
|
-
|
13
|
-
220.25 )
|
11
|
+
@dtaus.account = KingDta::Account.new(:account_number => @kto1.account_number, :bank_number => @kto1.bank_number, :client_name => @kto1.client_name, :bank_name => @kto1.bank_name)
|
12
|
+
@dtaus_gk.account = KingDta::Account.new(:account_number => @kto1.account_number, :bank_number => @kto1.bank_number, :client_name => @kto1.client_name, :bank_name => @kto1.bank_name)
|
13
|
+
@booking = KingDta::Booking.new(KingDta::Account.new(:account_number => @kto2.account_number, :bank_number => @kto2.bank_number, :client_name => @kto2.client_name, :bank_name => @kto2.bank_name), 220.25 )
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should not init without values" do
|
17
17
|
lambda{ KingDta::Dtaus.new }.should raise_error(ArgumentError)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should init with valid values" do
|
21
21
|
lambda{ KingDta::Dtaus.new('LK', Date.today) }.should_not raise_error(ArgumentError)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should not init with an unknown type" do
|
25
25
|
lambda{ KingDta::Dtaus.new('UNKNOWN', "date") }.should raise_error(ArgumentError)
|
26
26
|
end
|
@@ -28,11 +28,11 @@ describe KingDta::Dtaus do
|
|
28
28
|
it "should not init with an invalid date" do
|
29
29
|
lambda{ KingDta::Dtaus.new('LK', "date") }.should raise_error(ArgumentError)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should deny invalid accounts" do
|
33
33
|
lambda{ @dtaus.account = "account" }.should raise_error(KingDta::Exception)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should not add a booking if closed" do
|
37
37
|
@dtaus.add(@booking)
|
38
38
|
@dtaus.create
|
@@ -41,10 +41,10 @@ describe KingDta::Dtaus do
|
|
41
41
|
|
42
42
|
it "should not add a booking if closed" do
|
43
43
|
@dtaus.add(@booking)
|
44
|
-
negative_booking = KingDta::Booking.new(KingDta::Account.new( @kto2.
|
44
|
+
negative_booking = KingDta::Booking.new(KingDta::Account.new(:account_number => @kto2.account_number, :bank_number => @kto2.bank_number, :client_name => @kto2.client_name, :bank_name => @kto2.bank_name ), -120.25 )
|
45
45
|
lambda{ @dtaus.add(negative_booking) }.should raise_error(KingDta::Exception)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
it "should not create if there are no bookings" do
|
49
49
|
lambda{ @dtaus.create}.should raise_error(KingDta::Exception)
|
50
50
|
end
|
@@ -55,8 +55,8 @@ describe KingDta::Dtaus do
|
|
55
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
57
|
#60-70 kontonummer mit nullen aufgefüllt - hier nicht da ktnr == 10 stellen
|
58
|
-
str[60...70].should == "#{test_kto1.
|
59
|
-
str.should include(test_kto1.
|
58
|
+
str[60...70].should == "#{test_kto1.account_number}"
|
59
|
+
str.should include(test_kto1.bank_number)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should create checksums" do
|
@@ -67,13 +67,25 @@ describe KingDta::Dtaus do
|
|
67
67
|
@dtaus.sum_values.should == 22025
|
68
68
|
end
|
69
69
|
|
70
|
+
it "should create c-sektion with default GK account_key" do
|
71
|
+
@booking.account_key = nil
|
72
|
+
@dtaus_gk.add(@booking)
|
73
|
+
@dtaus_gk.bookings.first.text = 'SalesKing Monatsbeitrag 08/10 Freelancer Version'
|
74
|
+
@dtaus_gk.add_c(@booking)
|
75
|
+
str = @dtaus_gk.dta_string
|
76
|
+
str.length.should == 256
|
77
|
+
str.should include("51000")
|
78
|
+
out = "0216C00000000370400440002787777000000000000051000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGSALESKING MONATSBEITRAG 08/1 010210 FREELANCER VERSION "
|
79
|
+
str.should == out
|
80
|
+
end
|
81
|
+
|
70
82
|
it "should create c-sektion with booking text at 19" do
|
71
83
|
@dtaus.add(@booking)
|
72
84
|
@dtaus.bookings.first.text = 'SalesKing Monatsbeitrag 08/10 Freelancer Version'
|
73
85
|
@dtaus.add_c(@booking)
|
74
86
|
str = @dtaus.dta_string
|
75
87
|
str.length.should == 256
|
76
|
-
str.should include(@kto2.
|
88
|
+
str.should include(@kto2.client_name.upcase)
|
77
89
|
out = "0216C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGSALESKING MONATSBEITRAG 08/1 010210 FREELANCER VERSION "
|
78
90
|
str.should == out
|
79
91
|
end
|
@@ -83,7 +95,7 @@ describe KingDta::Dtaus do
|
|
83
95
|
@dtaus.add_c(@booking)
|
84
96
|
str = @dtaus.dta_string
|
85
97
|
str.length.should == 256
|
86
|
-
str.should include(@kto2.
|
98
|
+
str.should include(@kto2.client_name.upcase)
|
87
99
|
out = "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "
|
88
100
|
str.should == out
|
89
101
|
end
|
@@ -93,8 +105,8 @@ describe KingDta::Dtaus do
|
|
93
105
|
@dtaus.add(@booking)
|
94
106
|
str = @dtaus.create
|
95
107
|
str.length.should == 512
|
96
|
-
str.should include(@kto1.
|
97
|
-
str.should include(@kto2.
|
108
|
+
str.should include(@kto1.client_name.upcase)
|
109
|
+
str.should include(@kto2.client_name.upcase)
|
98
110
|
str.should include(@dtaus.default_text.upcase)
|
99
111
|
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
100
112
|
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
@@ -107,7 +119,7 @@ describe KingDta::Dtaus do
|
|
107
119
|
@dtaus.bookings.first.text = 'Rgn R-3456-0102220 Monatsbeitrag 08/10 Freelancer Version Vielen Dank Ihre SalesKing GmbH'
|
108
120
|
str = @dtaus.create
|
109
121
|
str.length.should == 640
|
110
|
-
str.should include(@kto2.
|
122
|
+
str.should include(@kto2.client_name.upcase)
|
111
123
|
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
112
124
|
"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
125
|
"0128E 0000001000000000000000000000002787777000000000370400440000000022025 "
|
@@ -119,8 +131,8 @@ describe KingDta::Dtaus do
|
|
119
131
|
6.times { @dtaus.add(@booking) }
|
120
132
|
str = @dtaus.create
|
121
133
|
str.length.should == 1792
|
122
|
-
str.should include(@kto1.
|
123
|
-
str.should include(@kto2.
|
134
|
+
str.should include(@kto1.client_name.upcase)
|
135
|
+
str.should include(@kto2.client_name.upcase)
|
124
136
|
str.should include(@dtaus.default_text.upcase)
|
125
137
|
out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
126
138
|
"0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
@@ -133,10 +145,19 @@ describe KingDta::Dtaus do
|
|
133
145
|
str.should == out
|
134
146
|
end
|
135
147
|
|
136
|
-
|
148
|
+
it "should create file" do
|
137
149
|
@dtaus.default_text = 'Default Verwendungszweck'
|
138
150
|
6.times { @dtaus.add(@booking) }
|
139
|
-
file
|
151
|
+
# create test output file in spec dir
|
152
|
+
filename = File.join(File.dirname(__FILE__), 'test_output.dta')
|
153
|
+
@dtaus.create_file(filename)
|
154
|
+
str = ''
|
155
|
+
File.open(filename, 'r').each do |ln|
|
156
|
+
str << ln
|
157
|
+
end
|
158
|
+
str.length.should == 1792
|
159
|
+
#remove testfile
|
160
|
+
File.delete(filename)
|
140
161
|
end
|
141
162
|
|
142
163
|
end
|
data/spec/dtazv_spec.rb
ADDED
@@ -0,0 +1,294 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# All Test DTAZV output strings are validated with sFirm => lokal Sparkassen Software
|
5
|
+
|
6
|
+
describe KingDta::Dtazv do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
@dtazv = KingDta::Dtazv.new(Date.today)
|
10
|
+
@dudes_konto = dudes_konto
|
11
|
+
@dalai_lamas_account = dalai_lamas_account
|
12
|
+
|
13
|
+
@dtazv.account = KingDta::Account.new(
|
14
|
+
:account_number => @dudes_konto.account_number,
|
15
|
+
:bank_number => @dudes_konto.bank_number,
|
16
|
+
:client_name => @dudes_konto.client_name,
|
17
|
+
:client_number => @dudes_konto.client_number,
|
18
|
+
:bank_street => @dudes_konto.account_street,
|
19
|
+
:bank_city => @dudes_konto.account_city,
|
20
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
21
|
+
:bank_name => @dudes_konto.bank_name,
|
22
|
+
:client_street => @dudes_konto.client_street,
|
23
|
+
:client_city => @dudes_konto.client_city,
|
24
|
+
:client_zip_code => @dudes_konto.client_zip_code,
|
25
|
+
:bank_country_code => @dudes_konto.bank_country_code,
|
26
|
+
:client_country_code => @dudes_konto.client_country_code
|
27
|
+
)
|
28
|
+
|
29
|
+
@fidel_castros_booking = KingDta::Booking.new(KingDta::Account.new(
|
30
|
+
:account_number => @dalai_lamas_account.account_number,
|
31
|
+
:bank_number => @dalai_lamas_account.bank_number,
|
32
|
+
:client_name => @dalai_lamas_account.client_name,
|
33
|
+
:client_number => @dalai_lamas_account.client_number,
|
34
|
+
:bank_street => @dalai_lamas_account.account_street,
|
35
|
+
:bank_city => @dalai_lamas_account.account_city,
|
36
|
+
:bank_zip_code => @dalai_lamas_account.account_zip_code,
|
37
|
+
:bank_name => @dalai_lamas_account.bank_name,
|
38
|
+
:client_street => @dalai_lamas_account.client_street,
|
39
|
+
:client_city => @dalai_lamas_account.client_city,
|
40
|
+
:client_zip_code => @dalai_lamas_account.client_zip_code,
|
41
|
+
:bank_country_code => @dalai_lamas_account.bank_country_code,
|
42
|
+
:client_country_code => @dalai_lamas_account.client_country_code
|
43
|
+
), 220.25)
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should init without values" do
|
48
|
+
lambda{ KingDta::Dtazv.new }.should_not raise_error(ArgumentError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should init with valid values" do
|
52
|
+
lambda{ KingDta::Dtazv.new(Date.today) }.should_not raise_error(ArgumentError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not init with an invalid date" do
|
56
|
+
lambda{ KingDta::Dtazv.new("date") }.should raise_error(ArgumentError)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should deny invalid accounts" do
|
60
|
+
lambda{ @dtazv.account = "account" }.should raise_error(KingDta::Exception)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should create file" do
|
64
|
+
@dtazv.default_text = 'Default Verwendungszweck'
|
65
|
+
6.times { @dtazv.add(@fidel_castros_booking) }
|
66
|
+
# create test output file in spec dir
|
67
|
+
filename = File.join(File.dirname(__FILE__), 'test_output.dta')
|
68
|
+
@dtazv.create_file(filename)
|
69
|
+
str = ''
|
70
|
+
File.open(filename, 'r').each do |ln|
|
71
|
+
str << ln
|
72
|
+
end
|
73
|
+
str.length.should == 5120
|
74
|
+
#remove testfile
|
75
|
+
File.delete(filename)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not add a booking if closed" do
|
79
|
+
@dtazv.add(@fidel_castros_booking)
|
80
|
+
@dtazv.create
|
81
|
+
lambda{ @dtazv.add(@fidel_castros_booking) }.should raise_error(KingDta::Exception)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should not add a booking if closed" do
|
85
|
+
@dtazv.add(@fidel_castros_booking)
|
86
|
+
negative_booking = KingDta::Booking.new(KingDta::Account.new(
|
87
|
+
:account_number => @dalai_lamas_account.account_number,
|
88
|
+
:bank_number => @dalai_lamas_account.bank_number,
|
89
|
+
:client_name => @dalai_lamas_account.client_name,
|
90
|
+
:client_number => @dalai_lamas_account.client_number,
|
91
|
+
:bank_street => @dalai_lamas_account.account_street,
|
92
|
+
:bank_city => @dalai_lamas_account.account_city,
|
93
|
+
:bank_zip_code => @dalai_lamas_account.account_zip_code,
|
94
|
+
:bank_name => @dalai_lamas_account.bank_name,
|
95
|
+
:client_street => @dalai_lamas_account.client_street,
|
96
|
+
:client_city => @dalai_lamas_account.client_city,
|
97
|
+
:client_zip_code => @dalai_lamas_account.client_zip_code,
|
98
|
+
:bank_country_code => @dalai_lamas_account.bank_country_code,
|
99
|
+
:client_country_code => @dalai_lamas_account.client_country_code
|
100
|
+
), -220.25)
|
101
|
+
lambda{ @dtazv.add(negative_booking) }.should raise_error(KingDta::Exception)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should not create if there are no bookings" do
|
105
|
+
lambda{ @dtazv.create}.should raise_error(KingDta::Exception)
|
106
|
+
end
|
107
|
+
|
108
|
+
# TODO
|
109
|
+
# it "should create the whole dta string with a single booking" do
|
110
|
+
# @dtaus.default_text = 'Default verwendungszweck'
|
111
|
+
# @dtaus.add(@booking)
|
112
|
+
# str = @dtaus.create
|
113
|
+
# str.length.should == 512
|
114
|
+
# str.should include(@kto1.name.upcase)
|
115
|
+
# str.should include(@kto2.name.upcase)
|
116
|
+
# str.should include(@dtaus.default_text.upcase)
|
117
|
+
# out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
118
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
119
|
+
# "0128E 0000001000000000000000000000002787777000000000370400440000000022025 "
|
120
|
+
# str.should == out
|
121
|
+
# end
|
122
|
+
|
123
|
+
# TODO
|
124
|
+
# it "should create whole dta string with long booking text in extension" do
|
125
|
+
# @dtaus.add(@booking)
|
126
|
+
# @dtaus.bookings.first.text = 'Rgn R-3456-0102220 Monatsbeitrag 08/10 Freelancer Version Vielen Dank Ihre SalesKing GmbH'
|
127
|
+
# str = @dtaus.create
|
128
|
+
# str.length.should == 640
|
129
|
+
# str.should include(@kto2.name.upcase)
|
130
|
+
# out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
131
|
+
# "0274C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGRGN R-3456-0102220 MONATSBE1 0302ITRAG 08/10 FREELANCER VERS02ION VIELEN DANK IHRE SALESK 02ING GMBH "+
|
132
|
+
# "0128E 0000001000000000000000000000002787777000000000370400440000000022025 "
|
133
|
+
# str.should == out
|
134
|
+
# end
|
135
|
+
|
136
|
+
# TODO
|
137
|
+
# it "should create the whole dta string with a lot of bookings" do
|
138
|
+
# @dtaus.default_text = 'Default Verwendungszweck'
|
139
|
+
# 6.times { @dtaus.add(@booking) }
|
140
|
+
# str = @dtaus.create
|
141
|
+
# str.length.should == 1792
|
142
|
+
# str.should include(@kto1.name.upcase)
|
143
|
+
# str.should include(@kto2.name.upcase)
|
144
|
+
# str.should include(@dtaus.default_text.upcase)
|
145
|
+
# out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
|
146
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
147
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
148
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
149
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
150
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
151
|
+
# "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
|
152
|
+
# "0128E 0000006000000000000000000000016726662000000002222402640000000132150 "
|
153
|
+
# str.should == out
|
154
|
+
# end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "KingDta::DtazvSegments" do
|
159
|
+
|
160
|
+
before :each do
|
161
|
+
@date = Date.today
|
162
|
+
@dudes_dtazv_export = KingDta::Dtazv.new(@date)
|
163
|
+
@dudes_konto = dudes_konto
|
164
|
+
@dalai_lamas_account = dalai_lamas_account
|
165
|
+
@dudes_dtazv_export.account = KingDta::Account.new(
|
166
|
+
:account_number => @dudes_konto.account_number,
|
167
|
+
:bank_number => @dudes_konto.bank_number,
|
168
|
+
:client_name => @dudes_konto.client_name,
|
169
|
+
:bank_name => @dudes_konto.bank_name,
|
170
|
+
:client_number => @dudes_konto.client_number,
|
171
|
+
:bank_street => @dudes_konto.account_street,
|
172
|
+
:bank_city => @dudes_konto.account_city,
|
173
|
+
:bank_zip_code => @dudes_konto.account_zip_code,
|
174
|
+
:client_street => @dudes_konto.client_street,
|
175
|
+
:client_city => @dudes_konto.client_city,
|
176
|
+
:client_zip_code => @dudes_konto.client_zip_code,
|
177
|
+
:bank_country_code => @dudes_konto.bank_country_code,
|
178
|
+
:client_country_code => @dudes_konto.client_country_code
|
179
|
+
)
|
180
|
+
|
181
|
+
@fidel_castros_booking = KingDta::Booking.new(KingDta::Account.new(
|
182
|
+
:account_number => @dalai_lamas_account.account_number,
|
183
|
+
:bank_number => @dalai_lamas_account.bank_number,
|
184
|
+
:client_name => @dalai_lamas_account.client_name,
|
185
|
+
:bank_name => @dalai_lamas_account.bank_name,
|
186
|
+
:client_number => @dalai_lamas_account.client_number,
|
187
|
+
:bank_street => @dalai_lamas_account.account_street,
|
188
|
+
:bank_city => @dalai_lamas_account.account_city,
|
189
|
+
:bank_zip_code => @dalai_lamas_account.account_zip_code,
|
190
|
+
:client_street => @dalai_lamas_account.client_street,
|
191
|
+
:client_city => @dalai_lamas_account.client_city,
|
192
|
+
:client_zip_code => @dalai_lamas_account.client_zip_code,
|
193
|
+
:bank_country_code => @dalai_lamas_account.bank_country_code,
|
194
|
+
:client_country_code => @dalai_lamas_account.client_country_code
|
195
|
+
), 220.25)
|
196
|
+
|
197
|
+
@bookings = []
|
198
|
+
@bookings << @fidel_castros_booking
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
# P SEGMENT NOT IMPLEMENTED AND USED YET
|
203
|
+
# it "should return the proper P segment" do
|
204
|
+
# @dudes_dtazv_export.add_p.should == "0256P37040044 Commerzbank K\303\266ln 5th avenue 55323 los angeles11060801 "
|
205
|
+
# end
|
206
|
+
|
207
|
+
# it "should return the proper length of P segment" do
|
208
|
+
# @dudes_dtazv_export.add_p.size.should == 256
|
209
|
+
# end
|
210
|
+
|
211
|
+
it "should return the proper Q segment" do
|
212
|
+
@dudes_dtazv_export.add_q.should == "0256Q370502991326049634JAN KUS MEINE EINE STRASSE 2 51063 MEINE KOELN #{@date.strftime("%y%m%d")}01#{@date.strftime("%y%m%d")}N0000000000 "
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should return the proper length of P segment" do
|
216
|
+
@dudes_dtazv_export.add_q.size.should == 256
|
217
|
+
end
|
218
|
+
|
219
|
+
# it "should create header" do
|
220
|
+
# str = @dtaus.add_a
|
221
|
+
# str.length.should == 128
|
222
|
+
# out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"
|
223
|
+
# str.should == out
|
224
|
+
# #60-70 kontonummer mit nullen aufgefüllt - hier nicht da ktnr == 10 stellen
|
225
|
+
# str[60...70].should == "#{test_kto1.nr}"
|
226
|
+
# str.should include(test_kto1.blz)
|
227
|
+
# end
|
228
|
+
|
229
|
+
it "should return the proper T segment" do
|
230
|
+
@dudes_dtazv_export.add_t(@fidel_castros_booking).should == "0768T37050299EUR1326049634#{@date.strftime("%y%m%d")}00000000 0000000000MARKF1100 DE FIDEL CASTRO BUSH-AVENUE 55 445555 KUBA /GR1601101250000000012300695 EUR00000000000220250 00000000 0013 0 00"
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should return the proper length of T segment" do
|
234
|
+
@dudes_dtazv_export.add_t(@fidel_castros_booking).size.should == 768
|
235
|
+
end
|
236
|
+
|
237
|
+
# TODO
|
238
|
+
# it "should create c-sektion with booking text at 19" do
|
239
|
+
# @dtaus.add(@booking)
|
240
|
+
# @dtaus.bookings.first.text = 'SalesKing Monatsbeitrag 08/10 Freelancer Version'
|
241
|
+
# @dtaus.add_c(@booking)
|
242
|
+
# str = @dtaus.dta_string
|
243
|
+
# str.length.should == 256
|
244
|
+
# str.should include(@kto2.name.upcase)
|
245
|
+
# out = "0216C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGSALESKING MONATSBEITRAG 08/1 010210 FREELANCER VERSION "
|
246
|
+
# str.should == out
|
247
|
+
# end
|
248
|
+
|
249
|
+
# V SEGMENT NOT IMPLEMENTED AND USED YET
|
250
|
+
# it "should return the proper V segment" do
|
251
|
+
# @dudes_dtazv_export.add_t.should == "..........."
|
252
|
+
# end
|
253
|
+
|
254
|
+
# it "should return the proper length of V segment" do
|
255
|
+
# @dudes_dtazv_export.add_t.size.should == 256
|
256
|
+
# end
|
257
|
+
|
258
|
+
# W SEGMENT NOT IMPLEMENTED AND USED YET
|
259
|
+
# it "should return the proper W segment" do
|
260
|
+
# @dudes_dtazv_export.add_t.should == "..........."
|
261
|
+
# end
|
262
|
+
|
263
|
+
# it "should return the proper length of W segment" do
|
264
|
+
# @dudes_dtazv_export.add_t.size.should == 256
|
265
|
+
# end
|
266
|
+
|
267
|
+
it "should return the proper Y segment" do
|
268
|
+
@dudes_dtazv_export.add_y(@bookings).should == "0256Y000000000000000000000000000000000000000000000000000000000000000000000001 "
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should return the proper length of Y segment" do
|
272
|
+
@dudes_dtazv_export.add_y(@bookings).size.should == 256
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should return the proper Z segment" do
|
276
|
+
@dudes_dtazv_export.add_z(@bookings).should == "0256Z000000000000220000000000000001 "
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should return the proper length of Z segment" do
|
280
|
+
@dudes_dtazv_export.add_z(@bookings).size.should == 256
|
281
|
+
end
|
282
|
+
|
283
|
+
# TODO
|
284
|
+
# it "should create c-sektion with default booking text" do
|
285
|
+
# @dtaus.default_text = 'Default verwendungszweck'
|
286
|
+
# @dtaus.add_c(@booking)
|
287
|
+
# str = @dtaus.dta_string
|
288
|
+
# str.length.should == 256
|
289
|
+
# str.should include(@kto2.name.upcase)
|
290
|
+
# out = "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "
|
291
|
+
# str.should == out
|
292
|
+
# end
|
293
|
+
|
294
|
+
end
|