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/spec/account_spec.rb CHANGED
@@ -5,155 +5,103 @@ describe KingDta::Account do
5
5
 
6
6
  before :each do
7
7
  @ba = test_kto2 # BankAccount mocked as open struct
8
- @dudes_konto = dudes_konto
9
8
  end
10
9
 
11
10
  it "should initialize a new account" do
12
- lambda{ KingDta::Account.new(:account_number => @ba.account_number, :bank_number => @ba.bank_number, :client_name => @ba.client_name) }.should_not raise_error
11
+ lambda{
12
+ KingDta::Account.new(:bank_account_number => @ba.bank_account_number,
13
+ :bank_number => @ba.bank_number,
14
+ :owner_name => @ba.owner_name)
15
+ }.should_not raise_error
13
16
  end
14
17
 
15
18
  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
19
+ lambda{
20
+ KingDta::Account.new(sender_opts)
21
+ }.should_not raise_error
29
22
  end
30
23
 
31
24
  it "should fail if bank account number is invalid" do
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')
25
+ lambda{
26
+ KingDta::Account.new(:bank_account_number => 123456789011123456789011123456789011,
27
+ :bank_number => @ba.bank_number,
28
+ :owner_name => @ba.owner_name)
29
+
30
+ }.should raise_error(ArgumentError, 'Bank account number too long, max 10 allowed')
34
31
  end
35
32
 
36
33
  it "should fail if bank number is invalid" do
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')
34
+ lambda{
35
+ KingDta::Account.new( :bank_account_number => @ba.bank_account_number,
36
+ :bank_number => 0,
37
+ :owner_name => @ba.owner_name)
38
+ }.should raise_error(ArgumentError)
39
+
40
+ lambda{
41
+ KingDta::Account.new( :bank_account_number => @ba.bank_account_number,
42
+ :bank_number => 123456789101112,
43
+ :owner_name => @ba.owner_name)
44
+ }.should raise_error(ArgumentError, 'Bank number too long, max 8 allowed')
39
45
  end
40
46
 
41
- it "should fail if clent number is too long" do
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')
47
+ it "should fail if owner number is too long" do
48
+ lambda{
49
+ KingDta::Account.new( :bank_account_number => @ba.bank_account_number,
50
+ :bank_number => @ba.bank_number,
51
+ :owner_name => @ba.owner_name,
52
+ :owner_number => 12345678901)
53
+ }.should raise_error(ArgumentError, 'Owner number too long, max 10 allowed')
43
54
  end
44
55
 
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')
56
+ it "should fail if street and/or Zip Code is too long" do
57
+ opts = sender_opts.merge( :bank_street => "Lorem ipsum dolor sit amet, consectetur")
58
+ lambda{
59
+ KingDta::Account.new(opts)
60
+ }.should raise_error(ArgumentError, 'Bank street too long, max 35 allowed')
59
61
  end
60
62
 
61
63
  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')
64
+ opts = sender_opts.merge( :bank_city => "Lorem ipsum dolor sit amet, consecte")
65
+ lambda{
66
+ KingDta::Account.new opts
67
+ }.should raise_error(ArgumentError, 'Bank city too long, max 35 allowed')
75
68
  end
76
69
 
77
70
  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')
71
+ opts = sender_opts.merge( :bank_name => "Lorem ipsum dolor sit amet, consecte")
72
+ lambda{
73
+ KingDta::Account.new opts
74
+ }.should raise_error(ArgumentError, 'Bank name too long, max 35 allowed')
91
75
  end
92
76
 
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')
77
+ it "should fail if client street is too long" do
78
+ opts = sender_opts.merge( :owner_street => "Lorem ipsum dolor sit amet, consecte")
79
+ lambda{
80
+ KingDta::Account.new opts
81
+ }.should raise_error(ArgumentError, 'Owner street too long, max 35 allowed')
107
82
  end
108
83
 
109
84
  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')
85
+ opts = sender_opts.merge( :owner_city => "Lorem ipsum dolor sit amet, consecte")
86
+ lambda{
87
+ KingDta::Account.new opts
88
+ }.should raise_error(ArgumentError, 'Owner city too long, max 35 allowed')
123
89
  end
124
90
 
125
91
  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"
92
+ acnt = KingDta::Account.new( sender_opts )
93
+ acnt.bank_zip_city.should == "51063 BANK KOELN"
140
94
  end
141
95
 
142
96
  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"
97
+ acnt = KingDta::Account.new( sender_opts )
98
+ acnt.owner_zip_city.should == "51063 MEINE KOELN"
157
99
  end
158
100
 
159
- end
101
+ it "should set owner country code from iban" do
102
+ opts = receiver_opts
103
+ opts[:owner_country_code] = nil
104
+ acnt = KingDta::Account.new( opts )
105
+ acnt.owner_country_code.should == "PL"
106
+ end
107
+ end
data/spec/booking_spec.rb CHANGED
@@ -4,9 +4,7 @@ require 'spec_helper'
4
4
  describe KingDta::Booking do
5
5
 
6
6
  before :each do
7
- kto1 = test_kto1
8
- kto2 = test_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 )
7
+ @account = KingDta::Account.new(receiver_opts)
10
8
  end
11
9
 
12
10
  it "should have no rounding error for string" do
data/spec/dtaus_spec.rb CHANGED
@@ -8,9 +8,9 @@ describe KingDta::Dtaus do
8
8
  @dtaus_gk = KingDta::Dtaus.new('GK', Date.today)
9
9
  @kto1 = test_kto1
10
10
  @kto2 = test_kto2
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 )
11
+ @dtaus.account = KingDta::Account.new(:bank_account_number => @kto1.bank_account_number, :bank_number => @kto1.bank_number, :owner_name => @kto1.owner_name, :bank_name => @kto1.bank_name)
12
+ @dtaus_gk.account = KingDta::Account.new(:bank_account_number => @kto1.bank_account_number, :bank_number => @kto1.bank_number, :owner_name => @kto1.owner_name, :bank_name => @kto1.bank_name)
13
+ @booking = KingDta::Booking.new(KingDta::Account.new(:bank_account_number => @kto2.bank_account_number, :bank_number => @kto2.bank_number, :owner_name => @kto2.owner_name, :bank_name => @kto2.bank_name), 220.25 )
14
14
  end
15
15
 
16
16
  it "should not init without values" do
@@ -41,7 +41,7 @@ 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(:account_number => @kto2.account_number, :bank_number => @kto2.bank_number, :client_name => @kto2.client_name, :bank_name => @kto2.bank_name ), -120.25 )
44
+ negative_booking = KingDta::Booking.new(KingDta::Account.new(:bank_account_number => @kto2.bank_account_number, :bank_number => @kto2.bank_number, :owner_name => @kto2.owner_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
 
@@ -55,7 +55,7 @@ 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.account_number}"
58
+ str[60...70].should == "#{test_kto1.bank_account_number}"
59
59
  str.should include(test_kto1.bank_number)
60
60
  end
61
61
 
@@ -85,17 +85,31 @@ describe KingDta::Dtaus do
85
85
  @dtaus.add_c(@booking)
86
86
  str = @dtaus.dta_string
87
87
  str.length.should == 256
88
- str.should include(@kto2.client_name.upcase)
88
+ str.should include(@kto2.owner_name.upcase)
89
89
  out = "0216C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGSALESKING MONATSBEITRAG 08/1 010210 FREELANCER VERSION "
90
90
  str.should == out
91
91
  end
92
92
 
93
+ it "should create c-sektion with long account owner name in extension" do
94
+ @dtaus.account = KingDta::Account.new(:bank_account_number => @kto1.bank_account_number, :bank_number => @kto1.bank_number,
95
+ :owner_name => 'A very long name exeeding 27 characters even longer 54 chars', :bank_name => @kto1.bank_name)
96
+
97
+ @dtaus.add(@booking)
98
+ @dtaus.bookings.first.text = 'SalesKing Monatsbeitrag 08/10 Freelancer Version'
99
+ @dtaus.add_c(@booking)
100
+ str = @dtaus.dta_string
101
+ str.length.should == 256
102
+ str.should include(@kto2.owner_name.upcase)
103
+ out = "0245C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH A VERY LONG NAME EXEEDING 2SALESKING MONATSBEITRAG 08/1 020210 FREELANCER VERSION 037 CHARACTERS EVEN LONGER 54 "
104
+ str.should == out
105
+ end
106
+
93
107
  it "should create c-sektion with default booking text" do
94
108
  @dtaus.default_text = 'Default verwendungszweck'
95
109
  @dtaus.add_c(@booking)
96
110
  str = @dtaus.dta_string
97
111
  str.length.should == 256
98
- str.should include(@kto2.client_name.upcase)
112
+ str.should include(@kto2.owner_name.upcase)
99
113
  out = "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "
100
114
  str.should == out
101
115
  end
@@ -105,8 +119,8 @@ describe KingDta::Dtaus do
105
119
  @dtaus.add(@booking)
106
120
  str = @dtaus.create
107
121
  str.length.should == 512
108
- str.should include(@kto1.client_name.upcase)
109
- str.should include(@kto2.client_name.upcase)
122
+ str.should include(@kto1.owner_name.upcase)
123
+ str.should include(@kto2.owner_name.upcase)
110
124
  str.should include(@dtaus.default_text.upcase)
111
125
  out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
112
126
  "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+
@@ -114,12 +128,21 @@ describe KingDta::Dtaus do
114
128
  str.should == out
115
129
  end
116
130
 
131
+ it "should create whole dta string with long texts exeeding extension" do
132
+ @dtaus.account = KingDta::Account.new(:bank_account_number => @kto1.bank_account_number, :bank_number => @kto1.bank_number,
133
+ :owner_name => 'A very long name exeeding 27 characters even longer 54 chars', :bank_name => @kto1.bank_name)
134
+ @dtaus.add(@booking)
135
+ @dtaus.bookings.first.text = 'Rgn R-3456-0102220 Monatsbeitrag 08/10 Freelancer Version Vielen Dank Ihre SalesKing GmbH' * 20
136
+ @dtaus.bookings.first.account.owner_name = 'A very long name exeeding 27 characters even longer 54 chars'
137
+ str = @dtaus.create ## should not raise error
138
+ end
139
+
117
140
  it "should create whole dta string with long booking text in extension" do
118
141
  @dtaus.add(@booking)
119
142
  @dtaus.bookings.first.text = 'Rgn R-3456-0102220 Monatsbeitrag 08/10 Freelancer Version Vielen Dank Ihre SalesKing GmbH'
120
143
  str = @dtaus.create
121
144
  str.length.should == 640
122
- str.should include(@kto2.client_name.upcase)
145
+ str.should include(@kto2.owner_name.upcase)
123
146
  out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
124
147
  "0274C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGRGN R-3456-0102220 MONATSBE1 0302ITRAG 08/10 FREELANCER VERS02ION VIELEN DANK IHRE SALESK 02ING GMBH "+
125
148
  "0128E 0000001000000000000000000000002787777000000000370400440000000022025 "
@@ -131,8 +154,8 @@ describe KingDta::Dtaus do
131
154
  6.times { @dtaus.add(@booking) }
132
155
  str = @dtaus.create
133
156
  str.length.should == 1792
134
- str.should include(@kto1.client_name.upcase)
135
- str.should include(@kto2.client_name.upcase)
157
+ str.should include(@kto1.owner_name.upcase)
158
+ str.should include(@kto2.owner_name.upcase)
136
159
  str.should include(@dtaus.default_text.upcase)
137
160
  out = "0128ALK3704004400000000GIMME YOUR MONEY AG #{Date.today.strftime("%d%m%y")} 78289700370000000000 #{Date.today.strftime("%d%m%Y")} 1"+
138
161
  "0187C00000000370400440002787777000000000000005000 0000000000037040044782897003700000022025 PETER & MAY GMBH GIMME YOUR MONEY AGDEFAULT VERWENDUNGSZWECK 1 00 "+