payment_dta 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +45 -0
  3. data/VERSION +1 -0
  4. data/generators/payment/USAGE +5 -0
  5. data/generators/payment/payment_generator.rb +76 -0
  6. data/generators/payment/templates/model.rb.erb +39 -0
  7. data/generators/payment/templates/spec.rb.erb +48 -0
  8. data/lib/payment_dta.rb +4 -0
  9. data/lib/payment_dta/character_conversion.rb +251 -0
  10. data/lib/payment_dta/dta_file.rb +55 -0
  11. data/lib/payment_dta/payment_sorting.rb +19 -0
  12. data/lib/payment_dta/payments/bank_cheque_payment.rb +60 -0
  13. data/lib/payment_dta/payments/base.rb +288 -0
  14. data/lib/payment_dta/payments/domestic_chf_payment.rb +67 -0
  15. data/lib/payment_dta/payments/esr_payment.rb +48 -0
  16. data/lib/payment_dta/payments/financial_institution_payment.rb +56 -0
  17. data/lib/payment_dta/payments/iban_payment.rb +76 -0
  18. data/lib/payment_dta/payments/special_financial_institution_payment.rb +64 -0
  19. data/lib/payment_dta/payments/total_record.rb +31 -0
  20. data/script/destroy +14 -0
  21. data/script/generate +14 -0
  22. data/spec/factory.rb +82 -0
  23. data/spec/lib/bank_cheque_payment_spec.rb +178 -0
  24. data/spec/lib/character_conversion_spec.rb +280 -0
  25. data/spec/lib/domestic_chf_payment_spec.rb +189 -0
  26. data/spec/lib/dta_file_spec.rb +81 -0
  27. data/spec/lib/esr_payment_spec.rb +157 -0
  28. data/spec/lib/financial_institution_payment_spec.rb +229 -0
  29. data/spec/lib/iban_payment_spec.rb +201 -0
  30. data/spec/lib/payment_header_spec.rb +221 -0
  31. data/spec/lib/payment_spec.rb +15 -0
  32. data/spec/lib/special_financial_institution_payment_spec.rb +238 -0
  33. data/spec/lib/total_record_spec.rb +20 -0
  34. data/spec/spec_helper.rb +9 -0
  35. metadata +107 -0
@@ -0,0 +1,280 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'character_conversion'
3
+
4
+ CONVERSION_MAP_UTF8 = {
5
+ 32 => {:name => "SPACE", :convert_to => " "},
6
+ 33 => {:name => "EXCLAMATION MARK", :convert_to => "."},
7
+ 34 => {:name => "QUOTATION MARK", :convert_to => "."},
8
+ 35 => {:name => "NUMBER SIGN", :convert_to => "."},
9
+ 36 => {:name => "DOLLAR SIGN", :convert_to => "."},
10
+ 37 => {:name => "PERCENT SIGN", :convert_to => "."},
11
+ 38 => {:name => "AMPERSAND", :convert_to => "+"},
12
+ 39 => {:name => "APOSTROPHE", :convert_to => "'"},
13
+ 40 => {:name => "LEFT PARENTHESIS", :convert_to => "("},
14
+ 41 => {:name => "RIGHT PARENTHESIS", :convert_to => ")"},
15
+ 42 => {:name => "ASTERISK", :convert_to => "."},
16
+ 43 => {:name => "PLUS SIGN", :convert_to => "+"},
17
+ 44 => {:name => "COMMA", :convert_to => ","},
18
+ 45 => {:name => "HYPHEN-MINUS", :convert_to => "-"},
19
+ 46 => {:name => "FULL STOP", :convert_to => "."},
20
+ 47 => {:name => "SOLIDUS", :convert_to => "/"},
21
+ 48 => {:name => "DIGIT ZERO", :convert_to => "0"},
22
+ 49 => {:name => "DIGIT ONE", :convert_to => "1"},
23
+ 50 => {:name => "DIGIT TWO", :convert_to => "2"},
24
+ 51 => {:name => "DIGIT THREE", :convert_to => "3"},
25
+ 52 => {:name => "DIGIT FOUR", :convert_to => "4"},
26
+ 53 => {:name => "DIGIT FIVE", :convert_to => "5"},
27
+ 54 => {:name => "DIGIT SIX", :convert_to => "6"},
28
+ 55 => {:name => "DIGIT SEVEN", :convert_to => "7"},
29
+ 56 => {:name => "DIGIT EIGHT", :convert_to => "8"},
30
+ 57 => {:name => "DIGIT NINE", :convert_to => "9"},
31
+ 58 => {:name => "COLON", :convert_to => ":"},
32
+ 59 => {:name => "SEMICOLON", :convert_to => "."},
33
+ 60 => {:name => "LESS-THAN SIGN", :convert_to => "."},
34
+ 61 => {:name => "EQUALS SIGN", :convert_to => "."},
35
+ 62 => {:name => "GREATER-THAN SIGN", :convert_to => "."},
36
+ 63 => {:name => "QUESTION MARK", :convert_to => "?"},
37
+ 64 => {:name => "COMMERCIAL AT", :convert_to => "."},
38
+ 65 => {:name => "LATIN CAPITAL LETTER A", :convert_to => "A"},
39
+ 66 => {:name => "LATIN CAPITAL LETTER B", :convert_to => "B"},
40
+ 67 => {:name => "LATIN CAPITAL LETTER C", :convert_to => "C"},
41
+ 68 => {:name => "LATIN CAPITAL LETTER D", :convert_to => "D"},
42
+ 69 => {:name => "LATIN CAPITAL LETTER E", :convert_to => "E"},
43
+ 70 => {:name => "LATIN CAPITAL LETTER F", :convert_to => "F"},
44
+ 71 => {:name => "LATIN CAPITAL LETTER G", :convert_to => "G"},
45
+ 72 => {:name => "LATIN CAPITAL LETTER H", :convert_to => "H"},
46
+ 73 => {:name => "LATIN CAPITAL LETTER I", :convert_to => "I"},
47
+ 74 => {:name => "LATIN CAPITAL LETTER J", :convert_to => "J"},
48
+ 75 => {:name => "LATIN CAPITAL LETTER K", :convert_to => "K"},
49
+ 76 => {:name => "LATIN CAPITAL LETTER L", :convert_to => "L"},
50
+ 77 => {:name => "LATIN CAPITAL LETTER M", :convert_to => "M"},
51
+ 78 => {:name => "LATIN CAPITAL LETTER N", :convert_to => "N"},
52
+ 79 => {:name => "LATIN CAPITAL LETTER O", :convert_to => "O"},
53
+ 80 => {:name => "LATIN CAPITAL LETTER P", :convert_to => "P"},
54
+ 81 => {:name => "LATIN CAPITAL LETTER Q", :convert_to => "Q"},
55
+ 82 => {:name => "LATIN CAPITAL LETTER R", :convert_to => "R"},
56
+ 83 => {:name => "LATIN CAPITAL LETTER S", :convert_to => "S"},
57
+ 84 => {:name => "LATIN CAPITAL LETTER T", :convert_to => "T"},
58
+ 85 => {:name => "LATIN CAPITAL LETTER U", :convert_to => "U"},
59
+ 86 => {:name => "LATIN CAPITAL LETTER V", :convert_to => "V"},
60
+ 87 => {:name => "LATIN CAPITAL LETTER W", :convert_to => "W"},
61
+ 88 => {:name => "LATIN CAPITAL LETTER X", :convert_to => "X"},
62
+ 89 => {:name => "LATIN CAPITAL LETTER Y", :convert_to => "Y"},
63
+ 90 => {:name => "LATIN CAPITAL LETTER Z", :convert_to => "Z"},
64
+ 91 => {:name => "LEFT SQUARE BRACKET", :convert_to => "."},
65
+ 92 => {:name => "REVERSE SOLIDUS", :convert_to => "."},
66
+ 93 => {:name => "RIGHT SQUARE BRACKET", :convert_to => "."},
67
+ 94 => {:name => "CIRCUMFLEX ACCENT", :convert_to => "."},
68
+ 95 => {:name => "LOW LINE", :convert_to => "."},
69
+ 96 => {:name => "GRAVE ACCENT", :convert_to => "."},
70
+ 97 => {:name => "LATIN SMALL LETTER A", :convert_to => "a"},
71
+ 98 => {:name => "LATIN SMALL LETTER B", :convert_to => "b"},
72
+ 99 => {:name => "LATIN SMALL LETTER C", :convert_to => "c"},
73
+ 100 => {:name => "LATIN SMALL LETTER D", :convert_to => "d"},
74
+ 101 => {:name => "LATIN SMALL LETTER E", :convert_to => "e"},
75
+ 102 => {:name => "LATIN SMALL LETTER F", :convert_to => "f"},
76
+ 103 => {:name => "LATIN SMALL LETTER G", :convert_to => "g"},
77
+ 104 => {:name => "LATIN SMALL LETTER H", :convert_to => "h"},
78
+ 105 => {:name => "LATIN SMALL LETTER I", :convert_to => "i"},
79
+ 106 => {:name => "LATIN SMALL LETTER J", :convert_to => "j"},
80
+ 107 => {:name => "LATIN SMALL LETTER K", :convert_to => "k"},
81
+ 108 => {:name => "LATIN SMALL LETTER L", :convert_to => "l"},
82
+ 109 => {:name => "LATIN SMALL LETTER M", :convert_to => "m"},
83
+ 110 => {:name => "LATIN SMALL LETTER N", :convert_to => "n"},
84
+ 111 => {:name => "LATIN SMALL LETTER O", :convert_to => "o"},
85
+ 112 => {:name => "LATIN SMALL LETTER P", :convert_to => "p"},
86
+ 113 => {:name => "LATIN SMALL LETTER Q", :convert_to => "q"},
87
+ 114 => {:name => "LATIN SMALL LETTER R", :convert_to => "r"},
88
+ 115 => {:name => "LATIN SMALL LETTER S", :convert_to => "s"},
89
+ 116 => {:name => "LATIN SMALL LETTER T", :convert_to => "t"},
90
+ 117 => {:name => "LATIN SMALL LETTER U", :convert_to => "u"},
91
+ 118 => {:name => "LATIN SMALL LETTER V", :convert_to => "v"},
92
+ 119 => {:name => "LATIN SMALL LETTER W", :convert_to => "w"},
93
+ 120 => {:name => "LATIN SMALL LETTER X", :convert_to => "x"},
94
+ 121 => {:name => "LATIN SMALL LETTER Y", :convert_to => "y"},
95
+ 122 => {:name => "LATIN SMALL LETTER Z", :convert_to => "z"},
96
+ 123 => {:name => "LEFT CURLY BRACKET", :convert_to => "."},
97
+ 124 => {:name => "VERTICAL LINE", :convert_to => "."},
98
+ 125 => {:name => "RIGHT CURLY BRACKET", :convert_to => "."},
99
+ 126 => {:name => "TILDE", :convert_to => "."},
100
+ 127 => {:name => "CONTROL", :convert_to => ' '},
101
+ 194128 => {:name => "CONTROL", :convert_to => ' '},
102
+ 194129 => {:name => "CONTROL", :convert_to => ' '},
103
+ 194130 => {:name => "CONTROL", :convert_to => ' '},
104
+ 194131 => {:name => "CONTROL", :convert_to => ' '},
105
+ 194132 => {:name => "CONTROL", :convert_to => ' '},
106
+ 194133 => {:name => "CONTROL", :convert_to => ' '},
107
+ 194134 => {:name => "CONTROL", :convert_to => ' '},
108
+ 194135 => {:name => "CONTROL", :convert_to => ' '},
109
+ 194136 => {:name => "CONTROL", :convert_to => ' '},
110
+ 194137 => {:name => "CONTROL", :convert_to => ' '},
111
+ 194138 => {:name => "CONTROL", :convert_to => ' '},
112
+ 194139 => {:name => "CONTROL", :convert_to => ' '},
113
+ 194140 => {:name => "CONTROL", :convert_to => ' '},
114
+ 194141 => {:name => "CONTROL", :convert_to => ' '},
115
+ 194142 => {:name => "CONTROL", :convert_to => ' '},
116
+ 194143 => {:name => "CONTROL", :convert_to => ' '},
117
+ 194144 => {:name => "CONTROL", :convert_to => ' '},
118
+ 194145 => {:name => "CONTROL", :convert_to => ' '},
119
+ 194146 => {:name => "CONTROL", :convert_to => ' '},
120
+ 194147 => {:name => "CONTROL", :convert_to => ' '},
121
+ 194148 => {:name => "CONTROL", :convert_to => ' '},
122
+ 194149 => {:name => "CONTROL", :convert_to => ' '},
123
+ 194150 => {:name => "CONTROL", :convert_to => ' '},
124
+ 194151 => {:name => "CONTROL", :convert_to => ' '},
125
+ 194152 => {:name => "CONTROL", :convert_to => ' '},
126
+ 194153 => {:name => "CONTROL", :convert_to => ' '},
127
+ 194154 => {:name => "CONTROL", :convert_to => ' '},
128
+ 194155 => {:name => "CONTROL", :convert_to => ' '},
129
+ 194156 => {:name => "CONTROL", :convert_to => ' '},
130
+ 194157 => {:name => "CONTROL", :convert_to => ' '},
131
+ 194158 => {:name => "CONTROL", :convert_to => ' '},
132
+ 194159 => {:name => "CONTROL", :convert_to => ' '},
133
+ 194160 => {:name => "NO-BREAK SPACE", :convert_to => '.'},
134
+ 194161 => {:name => "INVERTED EXCLAMATION MARK", :convert_to => '.'},
135
+ 194162 => {:name => "CENT SIGN", :convert_to => '.'},
136
+ 194163 => {:name => "POUND SIGN", :convert_to => '.'},
137
+ 194164 => {:name => "CURRENCY SIGN", :convert_to => '.'},
138
+ 194165 => {:name => "YEN SIGN", :convert_to => '.'},
139
+ 194166 => {:name => "BROKEN BAR", :convert_to => '.'},
140
+ 194167 => {:name => "SECTION SIGN", :convert_to => '.'},
141
+ 194168 => {:name => "DIAERESIS", :convert_to => '.'},
142
+ 194169 => {:name => "COPYRIGHT SIGN", :convert_to => '.'},
143
+ 194170 => {:name => "FEMININE ORDINAL INDICATOR", :convert_to => '.'},
144
+ 194171 => {:name => "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK", :convert_to => '.'},
145
+ 194172 => {:name => "NOT SIGN", :convert_to => '.'},
146
+ 194173 => {:name => "SOFT HYPHEN", :convert_to => '.'},
147
+ 194174 => {:name => "REGISTERED SIGN", :convert_to => '.'},
148
+ 194175 => {:name => "MACRON", :convert_to => '.'},
149
+ 194176 => {:name => "DEGREE SIGN", :convert_to => '.'},
150
+ 194177 => {:name => "PLUS-MINUS SIGN", :convert_to => '.'},
151
+ 194178 => {:name => "SUPERSCRIPT TWO", :convert_to => '.'},
152
+ 194179 => {:name => "SUPERSCRIPT THREE", :convert_to => '.'},
153
+ 194180 => {:name => "ACUTE ACCENT", :convert_to => '.'},
154
+ 194181 => {:name => "MICRO SIGN", :convert_to => '.'},
155
+ 194182 => {:name => "PILCROW SIGN", :convert_to => '.'},
156
+ 194183 => {:name => "MIDDLE DOT", :convert_to => '.'},
157
+ 194184 => {:name => "CEDILLA", :convert_to => '.'},
158
+ 194185 => {:name => "SUPERSCRIPT ONE", :convert_to => '.'},
159
+ 194186 => {:name => "MASCULINE ORDINAL INDICATOR", :convert_to => '.'},
160
+ 194187 => {:name => "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK", :convert_to => '.'},
161
+ 194188 => {:name => "VULGAR FRACTION ONE QUARTER", :convert_to => '.'},
162
+ 194189 => {:name => "VULGAR FRACTION ONE HALF", :convert_to => '.'},
163
+ 194190 => {:name => "VULGAR FRACTION THREE QUARTERS", :convert_to => '.'},
164
+ 194191 => {:name => "INVERTED QUESTION MARK", :convert_to => '.'},
165
+ 195128 => {:name => "LATIN CAPITAL LETTER A WITH GRAVE", :convert_to => 'A'},
166
+ 195129 => {:name => "LATIN CAPITAL LETTER A WITH ACUTE", :convert_to => 'A'},
167
+ 195130 => {:name => "LATIN CAPITAL LETTER A WITH CIRCUMFLEX", :convert_to => 'A'},
168
+ 195131 => {:name => "LATIN CAPITAL LETTER A WITH TILDE", :convert_to => 'A'},
169
+ 195132 => {:name => "LATIN CAPITAL LETTER A WITH DIAERESIS", :convert_to => 'AE'},
170
+ 195133 => {:name => "LATIN CAPITAL LETTER A WITH RING ABOVE", :convert_to => 'A'},
171
+ 195134 => {:name => "LATIN CAPITAL LETTER AE", :convert_to => 'AE'},
172
+ 195135 => {:name => "LATIN CAPITAL LETTER C WITH CEDILLA", :convert_to => 'C'},
173
+ 195136 => {:name => "LATIN CAPITAL LETTER E WITH GRAVE", :convert_to => 'E'},
174
+ 195137 => {:name => "LATIN CAPITAL LETTER E WITH ACUTE", :convert_to => 'E'},
175
+ 195138 => {:name => "LATIN CAPITAL LETTER E WITH CIRCUMFLEX", :convert_to => 'E'},
176
+ 195139 => {:name => "LATIN CAPITAL LETTER E WITH DIAERES", :convert_to => 'E'},
177
+ 195140 => {:name => "LATIN CAPITAL LETTER I WITH GRAVE", :convert_to => 'I'},
178
+ 195141 => {:name => "LATIN CAPITAL LETTER I WITH ACUTE", :convert_to => 'I'},
179
+ 195142 => {:name => "LATIN CAPITAL LETTER I WITH CIRCUMFLEX", :convert_to => 'I'},
180
+ 195143 => {:name => "LATIN CAPITAL LETTER I WITH DIAERESIS", :convert_to => 'I'},
181
+ 195144 => {:name => "LATIN CAPITAL LETTER ETH", :convert_to => '.'},
182
+ 195145 => {:name => "LATIN CAPITAL LETTER N WITH TILDE", :convert_to => 'N'},
183
+ 195146 => {:name => "LATIN CAPITAL LETTER O WITH GRAVE", :convert_to => 'O'},
184
+ 195147 => {:name => "LATIN CAPITAL LETTER O WITH ACUTE", :convert_to => 'O'},
185
+ 195148 => {:name => "LATIN CAPITAL LETTER O WITH CIRCUMFLEX", :convert_to => 'O'},
186
+ 195149 => {:name => "LATIN CAPITAL LETTER O WITH TILDE", :convert_to => 'O'},
187
+ 195150 => {:name => "LATIN CAPITAL LETTER O WITH DIAERESIS", :convert_to => 'OE'},
188
+ 195151 => {:name => "MULTIPLICATION SIGN", :convert_to => '.'},
189
+ 195152 => {:name => "LATIN CAPITAL LETTER O WITH STROKE", :convert_to => '.'},
190
+ 195153 => {:name => "LATIN CAPITAL LETTER U WITH GRAVE", :convert_to => 'U'},
191
+ 195154 => {:name => "LATIN CAPITAL LETTER U WITH ACUTE", :convert_to => 'U'},
192
+ 195155 => {:name => "LATIN CAPITAL LETTER U WITH CIRCUMFLEX", :convert_to => 'U'},
193
+ 195156 => {:name => "LATIN CAPITAL LETTER U WITH DIAERESIS", :convert_to => 'UE'},
194
+ 195157 => {:name => "LATIN CAPITAL LETTER Y WITH ACUTE", :convert_to => 'Y'},
195
+ 195158 => {:name => "LATIN CAPITAL LETTER THORN", :convert_to => '.'},
196
+ 195159 => {:name => "LATIN SMALL LETTER SHARP S", :convert_to => 'ss'},
197
+ 195160 => {:name => "LATIN SMALL LETTER A WITH GRAVE", :convert_to => 'a'},
198
+ 195161 => {:name => "LATIN SMALL LETTER A WITH ACUTE", :convert_to => 'a'},
199
+ 195162 => {:name => "LATIN SMALL LETTER A WITH CIRCUMFLEX", :convert_to => 'a'},
200
+ 195163 => {:name => "LATIN SMALL LETTER A WITH TILDE", :convert_to => 'a'},
201
+ 195164 => {:name => "LATIN SMALL LETTER A WITH DIAERESIS", :convert_to => 'ae'},
202
+ 195165 => {:name => "LATIN SMALL LETTER A WITH RING ABOVE", :convert_to => 'a'},
203
+ 195166 => {:name => "LATIN SMALL LETTER AE", :convert_to => 'ae'},
204
+ 195167 => {:name => "LATIN SMALL LETTER C WITH CEDILLA", :convert_to => 'c'},
205
+ 195168 => {:name => "LATIN SMALL LETTER E WITH GRAVE", :convert_to => 'e'},
206
+ 195169 => {:name => "LATIN SMALL LETTER E WITH ACUTE", :convert_to => 'e'},
207
+ 195170 => {:name => "LATIN SMALL LETTER E WITH CIRCUMFLEX", :convert_to => 'e'},
208
+ 195171 => {:name => "LATIN SMALL LETTER E WITH DIAERESIS", :convert_to => 'e'},
209
+ 195172 => {:name => "LATIN SMALL LETTER I WITH GRAVE", :convert_to => 'i'},
210
+ 195173 => {:name => "LATIN SMALL LETTER I WITH ACUTE", :convert_to => 'i'},
211
+ 195174 => {:name => "LATIN SMALL LETTER I WITH CIRCUMFLEX", :convert_to => 'i'},
212
+ 195175 => {:name => "LATIN SMALL LETTER I WITH DIAERESIS", :convert_to => 'i'},
213
+ 195176 => {:name => "LATIN SMALL LETTER ETH", :convert_to => '.'},
214
+ 195177 => {:name => "LATIN SMALL LETTER N WITH TILE", :convert_to => 'n'},
215
+ 195178 => {:name => "LATIN SMALL LETTER O WITH GRAVE", :convert_to => 'o'},
216
+ 195179 => {:name => "LATIN SMALL LETTER O WITH ACUTE", :convert_to => 'o'},
217
+ 195180 => {:name => "LATIN SMALL LETTER O WITH CIRCUMFLEX", :convert_to => 'o'},
218
+ 195181 => {:name => "LATIN SMALL LETTER O WITH TILDE", :convert_to => 'o'},
219
+ 195182 => {:name => "LATIN SMALL LETTER O WITH DIAERESIS", :convert_to => 'oe'},
220
+ 195183 => {:name => "DIVISION SIGN", :convert_to => '.'},
221
+ 195184 => {:name => "LATIN SMALL LETTER O WITH STROKE", :convert_to => '.'},
222
+ 195185 => {:name => "LATIN SMALL LETTER U WITH GRAVE", :convert_to => 'u'},
223
+ 195186 => {:name => "LATIN SMALL LETTER U WITH ACUTE", :convert_to => 'u'},
224
+ 195187 => {:name => "LATIN SMALL LETTER U WITH CIRCUMFLEX", :convert_to => 'u'},
225
+ 195188 => {:name => "LATIN SMALL LETTER U WITH DIAERESIS", :convert_to => 'ue'},
226
+ 195189 => {:name => "LATIN SMALL LETTER Y WITH ACUTE", :convert_to => 'y'},
227
+ 195190 => {:name => "LATIN SMALL LETTER THORN", :convert_to => '.'},
228
+ 195191 => {:name => "LATIN SMALL LETTER Y WITH DIAERESIS", :convert_to => 'y'},
229
+ }
230
+
231
+
232
+ class Converter
233
+ extend DTA::CharacterConversion
234
+ end
235
+
236
+ def create_character_from_ut8_decimal_code(code)
237
+ if code < 128
238
+ code.chr
239
+ else
240
+ [code.to_s[0,3].to_i,code.to_s[3,3].to_i].pack("C*")
241
+ end
242
+ end
243
+ describe "dta character conversion and encoding" do
244
+ # UTF-8 encoding uses 2 bytes for non US-ASCII characters
245
+ # ISO Latincode 8859-1 uses 1 byte
246
+ it "should map the string before encoding it" do
247
+ Converter.should_receive(:map_characters).with("Äöü").and_return("AEoeue")
248
+ Converter.dta_string("Äöü")
249
+ end
250
+
251
+ it "should encode the strings" do
252
+ Converter.should_receive(:encode_characters).with("AEoeue").and_return(Iconv.conv("ISO-8859-1", "UTF8","Äöü"))
253
+ Converter.dta_string("Äöü")
254
+ end
255
+
256
+ describe "character mapping/reduction" do
257
+ CONVERSION_MAP_UTF8.each do |id,conversion|
258
+ it "should map #{conversion[:name]} to '#{conversion[:convert_to]}'" do
259
+ character = create_character_from_ut8_decimal_code(id)
260
+ Converter.map_characters(character).should == conversion[:convert_to]
261
+ end
262
+ end
263
+
264
+ it "should map strings" do
265
+ Converter.map_characters("ÄäÜüÖö").should == "AEaeUEueOEoe"
266
+ end
267
+ end
268
+
269
+ describe 'DTA character encoding' do
270
+
271
+ it "should have a default system encoding of utf8" do
272
+ $KCODE.should == 'UTF8'
273
+ end
274
+
275
+ it "should convert the encoding from UTF8 to ISO Latincode 8859-1" do
276
+ encoded_string = Converter.encode_characters("Ä")
277
+ encoded_string.size.should == 1
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,189 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'payments/domestic_chf_payment'
3
+
4
+ describe DomesticCHFPayment do
5
+
6
+ it "should have a total length of 640 characters" do
7
+ Factory.create_domestic_chf_payment.record.size.should == 640
8
+ end
9
+
10
+ describe 'segment 1' do
11
+ it 'should set the segment field to 01' do
12
+ Factory.create_domestic_chf_payment.segment1[0,2].should == '01'
13
+ end
14
+
15
+ it 'should have a reference number' do
16
+ Factory.create_domestic_chf_payment(:issuer_identification => 'ABC01', :transaction_number => '00123478901').segment1[53,16].should == "ABC0100123478901"
17
+ end
18
+
19
+ it 'should have an account to be debited without IBAN justified left filled with blanks' do
20
+ Factory.create_domestic_chf_payment(:account_to_be_debited => '10235678').segment1[69,24].should == '10235678 '
21
+ end
22
+
23
+ it 'should have an account to be debited with IBAN' do
24
+ Factory.create_domestic_chf_payment(:account_to_be_debited => 'CH9300762011623852957').segment1[69,24].should == 'CH9300762011623852957 '
25
+ end
26
+
27
+ it 'should have a blank payment amount valuta (6 blanks)' do
28
+ Factory.create_domestic_chf_payment.segment1[93,6].should == ' '
29
+ end
30
+
31
+ it 'should have a payment amount currency code' do
32
+ Factory.create_domestic_chf_payment(:payment_amount_currency => 'CHF').segment1[99,3].should == 'CHF'
33
+ end
34
+
35
+ it 'should have a payment amount justified left filled with blanks' do
36
+ Factory.create_domestic_chf_payment(:payment_amount => '3949.75').segment1[102,12].should == '3949.75 '
37
+ end
38
+
39
+ it 'should have a reserve field' do
40
+ Factory.create_domestic_chf_payment.segment1[114,14].should == ' '.ljust(14)
41
+ end
42
+
43
+ it 'should have a total length of 128 characters' do
44
+ Factory.create_domestic_chf_payment.segment1.size.should == 128
45
+ end
46
+ end
47
+ describe 'segment 2' do
48
+ it 'should set the segment field to 02' do
49
+ Factory.create_domestic_chf_payment.segment2[0,2].should == '02'
50
+ end
51
+
52
+ it 'should have an ordering partys address line 1' do
53
+ Factory.create_domestic_chf_payment(:ordering_partys_address_line1 => 'John Doe').segment2[2,24].should == 'John Doe'.ljust(24)
54
+ end
55
+
56
+ it 'should have an ordering partys address line 2' do
57
+ Factory.create_domestic_chf_payment(:ordering_partys_address_line2 => 'Bahnhofstrasse 1').segment2[26,24].should == 'Bahnhofstrasse 1'.ljust(24)
58
+ end
59
+
60
+ it 'should have an ordering partys address line 3' do
61
+ Factory.create_domestic_chf_payment(:ordering_partys_address_line3 => '8000 Zurich').segment2[50,24].should == '8000 Zurich'.ljust(24)
62
+ end
63
+
64
+ it 'should have an ordering partys address line 4' do
65
+ Factory.create_domestic_chf_payment(:ordering_partys_address_line4 => 'Schweiz').segment2[74,24].should == 'Schweiz'.ljust(24)
66
+ end
67
+
68
+ it 'should have a reserve field' do
69
+ Factory.create_domestic_chf_payment.segment2[98,30].should == ''.ljust(30)
70
+ end
71
+
72
+ it 'should have a length of 128 characters' do
73
+ Factory.create_domestic_chf_payment.segment2.size.should == 128
74
+ end
75
+ end
76
+
77
+ describe 'segment 3' do
78
+ it 'should set the segment field to 03' do
79
+ Factory.create_domestic_chf_payment.segment3[0,2].should == '03'
80
+ end
81
+
82
+ it 'should have the beneficiarys bank account number' do
83
+ Factory.create_domestic_chf_payment(:beneficiarys_bank_account_number =>'111222333').segment3[2,30].should == '/C/111222333'.ljust(30)
84
+ end
85
+
86
+ it 'should have a address line 1' do
87
+ Factory.create_domestic_chf_payment(:beneficiary_address_line1 => 'Michael Recipient').segment3[32,24].should == 'Michael Recipient'.ljust(24)
88
+ end
89
+
90
+ it 'should have a beneficiary address line 2' do
91
+ Factory.create_domestic_chf_payment(:beneficiary_address_line2 => 'Empfaengerstrasse 1').segment3[56,24].should == 'Empfaengerstrasse 1'.ljust(24)
92
+ end
93
+
94
+ it 'should have a beneficiary address line 3' do
95
+ Factory.create_domestic_chf_payment(:beneficiary_address_line3 => '8640 Rapperswil').segment3[80,24].should == '8640 Rapperswil'.ljust(24)
96
+ end
97
+
98
+ it 'should have a beneficiary address line 4' do
99
+ Factory.create_domestic_chf_payment(:beneficiary_address_line4 => 'Schweiz').segment3[104,24].should == 'Schweiz'.ljust(24)
100
+ end
101
+
102
+ it 'should have a length of 128 characters' do
103
+ Factory.create_domestic_chf_payment.segment3.size.should == 128
104
+ end
105
+ end
106
+
107
+ describe 'segment 4' do
108
+ it 'should set the segment field to 04' do
109
+ Factory.create_domestic_chf_payment.segment4[0,2].should == '04'
110
+ end
111
+
112
+ it "should have a reson for payment message line 1" do
113
+ Factory.create_domestic_chf_payment(:reason_for_payment_message_line1 => 'LINE1').segment4[2,28].should == 'LINE1'.ljust(28)
114
+ end
115
+
116
+ it "should have a reson for payment message line 2" do
117
+ Factory.create_domestic_chf_payment(:reason_for_payment_message_line2 => 'LINE2').segment4[30,28].should == 'LINE2'.ljust(28)
118
+ end
119
+
120
+ it "should have a reson for payment message line 3" do
121
+ Factory.create_domestic_chf_payment(:reason_for_payment_message_line3 => 'LINE3').segment4[58,28].should == 'LINE3'.ljust(28)
122
+ end
123
+
124
+ it "should have a reson for payment message line 4" do
125
+ Factory.create_domestic_chf_payment(:reason_for_payment_message_line4 => 'LINE4').segment4[86,28].should == 'LINE4'.ljust(28)
126
+ end
127
+
128
+ it 'should have a reserve field' do
129
+ Factory.create_domestic_chf_payment.segment4[114,14].should == ' '.ljust(14)
130
+ end
131
+
132
+ it 'should have a length of 128 characters' do
133
+ Factory.create_domestic_chf_payment.segment4.size.should == 128
134
+ end
135
+ end
136
+
137
+ describe 'segment 5' do
138
+ it 'should set the segment field to 05' do
139
+ Factory.create_domestic_chf_payment.segment5[0,2].should == '05'
140
+ end
141
+
142
+ it 'should have the end beneficiarys bank account number' do
143
+ Factory.create_domestic_chf_payment(:end_beneficiarys_bank_account_number =>'111222333').segment5[2,30].should == '/C/111222333'.ljust(30)
144
+ end
145
+
146
+ it 'should have an end beneficiary address line 1' do
147
+ Factory.create_domestic_chf_payment(:end_beneficiary_address_line1 => 'Michael Recipient').segment5[32,24].should == 'Michael Recipient'.ljust(24)
148
+ end
149
+
150
+ it 'should have an beneficiary address line 2' do
151
+ Factory.create_domestic_chf_payment(:end_beneficiary_address_line2 => 'Empfaengerstrasse 1').segment5[56,24].should == 'Empfaengerstrasse 1'.ljust(24)
152
+ end
153
+
154
+ it 'should have an end beneficiary address line 3' do
155
+ Factory.create_domestic_chf_payment(:end_beneficiary_address_line3 => '8640 Rapperswil').segment5[80,24].should == '8640 Rapperswil'.ljust(24)
156
+ end
157
+
158
+ it 'should have an end beneficiary address line 4' do
159
+ Factory.create_domestic_chf_payment(:end_beneficiary_address_line4 => 'Schweiz').segment5[104,24].should == 'Schweiz'.ljust(24)
160
+ end
161
+
162
+ it 'should have a length of 128 characters' do
163
+ Factory.create_domestic_chf_payment.segment5.size.should == 128
164
+ end
165
+ end
166
+
167
+ describe 'comparison' do
168
+ it 'should sort by execution date ascending' do
169
+ @record1 = Factory.create_domestic_chf_payment(:requested_processing_date => "091026")
170
+ @record2 = Factory.create_domestic_chf_payment(:requested_processing_date => "091027")
171
+
172
+ (@record1 < @record2).should be_true
173
+ end
174
+
175
+ it "should sort by issuer identification when the execution date is equal" do
176
+ @record1 = Factory.create_domestic_chf_payment(:requested_processing_date => "091026", :issuer_identification => "AAAAA")
177
+ @record2 = Factory.create_domestic_chf_payment(:requested_processing_date => "091026",:issuer_identification => "BBBBB")
178
+
179
+ (@record1 < @record2).should be_true
180
+ end
181
+
182
+ it "should sort by issuers clearing number when execution date and issuer identification are equal" do
183
+ @record1 = Factory.create_domestic_chf_payment(:requested_processing_date => "091026", :issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '253')
184
+ @record2 = Factory.create_domestic_chf_payment(:requested_processing_date => "091026",:issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '254')
185
+
186
+ (@record1 < @record2).should be_true
187
+ end
188
+ end
189
+ end