Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e428a414

Von Jan Büren vor mehr als 6 Jahren hinzugefügt

  • ID e428a414677ec83c7834fb83905c277477edb81f
  • Vorgänger 8bf25ad5
  • Nachfolger 5b5fc3ca

DATEV/CSV.pm Testfälle für aktuelle Überarbeitung angepasst

Ungültiges Encoding wirft jetzt hart einen Fehler
Keine undef-Werte mehr in der Datenstruktur
Unsinninge Iconvs und Encodes erstmal entfernt

Unterschiede anzeigen:

t/datev/datev_format_2018.t
68 68
# check conversion to csv
69 69
$datev1->from($startdate);
70 70
$datev1->to($enddate);
71
my ($datev_ref, $warnings_ref) = SL::DATEV::CSV->new(datev_lines  => $datev1->generate_datev_lines,
71
my ($datev_ref, $warnings_ref, $die_message);
72
eval {
73
  ($datev_ref, $warnings_ref) = SL::DATEV::CSV->new(datev_lines  => $datev1->generate_datev_lines,
72 74
                                                     from         => $startdate,
73 75
                                                     to           => $enddate,
74 76
                                                     locked       => $datev1->locked,
75 77
                                                    );
76
my @warnings = $warnings_ref;
77
is($warnings[0]->[0]->{untranslated},
78
  'Wrong field value \'#1\' for field \'#2\' for the transaction with amount \'#3\'', 'wrong_encoding');
78
  1;
79
} or do {
80
  $die_message = $@;
81
};
82

  
83
ok($die_message =~ m/Falscher Feldwert 'ݗݘݰݶ' für Feld 'belegfeld1' bei der Transaktion mit dem Umsatz von/, 'wrong_encoding');
79 84

  
80 85

  
81
# redefine invnumber, we have mixed encodings, should still generate a warning
82 86
$invoice->invnumber('ݗݘݰݶmuh');
83 87
$invoice->save();
84 88

  
......
91 95
$datev3->to($enddate);
92 96
$datev3->generate_datev_data;
93 97
$datev3->generate_datev_lines;
94
my ($datev_ref2, $warnings_ref2) = SL::DATEV::CSV->new(datev_lines  => $datev3->generate_datev_lines,
98
my ($datev_ref2, $warnings_ref2, $die_message2);
99
eval {
100
  ($datev_ref2, $warnings_ref2) = SL::DATEV::CSV->new(datev_lines  => $datev3->generate_datev_lines,
95 101
                                                       from         => $startdate,
96 102
                                                       to           => $enddate,
97 103
                                                       locked       => $datev3->locked,
98 104
                                                      );
105
  1;
106
} or do {
107
  $die_message2 = $@;
108
};
99 109

  
100

  
101

  
102
@warnings = [];
103
@warnings = $warnings_ref2;
104
is($warnings[0]->[0]->{untranslated},
105
  'Wrong field value \'#1\' for field \'#2\' for the transaction with amount \'#3\'', 'mixed_wrong_encoding');
106

  
107

  
110
# redefine invnumber, we have mixed encodings, should still fail
111
ok($die_message2 =~ m/Falscher Feldwert 'ݗݘݰݶmuh' für Feld 'belegfeld1' bei der Transaktion mit dem Umsatz von/, 'mixed_wrong_encoding');
108 112

  
109 113
# create one haben buchung with GLTransaction today
110 114

  
......
145 149
));
146 150

  
147 151
my $gl_transaction = SL::DB::GLTransaction->new(
148
  reference      => "Reisekosten März 2018",
152
  reference      => "Reise März 2018",
149 153
  description    => "Reisekonsten März 2018 / Ma Schmidt",
150 154
  transdate      => $today,
151 155
  gldate         => $today,
......
176 180

  
177 181
my @data_csv = splice @{ $datev_ref3 }, 2, 5;
178 182
@data_csv    = sort { $a->[0] cmp $b->[0] } @data_csv;
179

  
180
my $cp1252_posting_text   = SL::Iconv::convert("UTF-8", "CP1252", 'Reisekosten März 2018');
181
cmp_bag($data_csv[0], [ 100, 'H', 'EUR', undef, undef, undef, '4660', '1000', 9, '1703', 'Reisekosten ',
182
                     undef, undef, $cp1252_posting_text, undef, undef, undef, undef, undef, undef, undef, undef,
183
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
184
                     undef, undef, '', undef, undef, undef, undef, undef, undef, undef, undef,
185
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
186
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
187
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
188
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
189
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
190
                     undef, undef, undef, undef, undef ]
183
cmp_bag($data_csv[0], [ 100, 'H', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
184
                     '', '', '', '', '', '', '', '', '', '', '',
185
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
186
                     '', '', '', '', '', '', '', '', '', '', '',
187
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
188
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
189
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
190
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
191
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
192
                     '', '', '', '', '' ]
191 193
       );
192 194

  
193 195
done_testing();
t/datev/invoices.t
172 172
my @data_csv = splice @{ $datev_ref }, 2, 5;
173 173
@data_csv    = sort { $a->[0] cmp $b->[0] } @data_csv;
174 174

  
175
my $cp1252_belegfeld1   = SL::Iconv::convert("UTF-8", "CP1252", 'Þ sales ¥& i');
176
my $cp1252_buchungstext = SL::Iconv::convert("UTF-8", "CP1252", 'Þ sales ¥& invöice');
177

  
178
cmp_bag($data_csv[1], [ 535, 'S', 'EUR', undef, undef, undef, '1400', '8300', undef, '0101', $cp1252_belegfeld1,
179
                     undef, undef, $cp1252_buchungstext, undef, undef, undef, undef, undef, undef, undef, undef,
180
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
181
                     undef, 'Crowd-Fu', 'Kostenst', undef, undef, undef, undef, undef, undef, undef, undef,
182
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
183
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
184
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
185
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
186
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
187
                     undef, undef, undef, undef, undef ]
175
cmp_bag($data_csv[1], [ 535, 'S', 'EUR', '', '', '', '1400', '8300', '', '0101', "\x{de} sales \x{a5}& i",
176
                     '', '', '', '', '', '', '', '', '', '', '',
177
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
178
                     '', 'Crowd-Fu', 'Kostenst', '', '', '', '', '', '', '', '',
179
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
180
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
181
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
182
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
183
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
184
                     '', '', '', '', '' ]
188 185
       );
189 186

  
190
cmp_bag($data_csv[0], [ '249,9', 'S', 'EUR', undef, undef, undef, '1400', '8400', undef, '0101', $cp1252_belegfeld1,
191
                     undef, undef, $cp1252_buchungstext, undef, undef, undef, undef, undef, undef, undef, undef,
192
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
193
                     undef, 'Crowd-Fu', 'Kostenst', undef, undef, undef, undef, undef, undef, undef, undef,
194
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
195
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
196
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
197
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
198
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
199
                     undef, undef, undef, undef, undef ]
187
cmp_bag($data_csv[0], [ '249,9', 'S', 'EUR', '', '', '', '1400', '8400', '', '0101', "\x{de} sales \x{a5}& i",
188
                     '', '', '', '', '', '', '', '', '', '', '',
189
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
190
                     '', 'Crowd-Fu', 'Kostenst', '', '', '', '', '', '', '', '',
191
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
192
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
193
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
194
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
195
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
196
                     '', '', '', '', '' ]
200 197
       );
201
cmp_bag($data_csv[2], [ '784,9', 'S', 'EUR', undef, undef, undef, '1200', '1400', undef, '0501', $cp1252_belegfeld1,
202
                     undef, undef, $cp1252_buchungstext, undef, undef, undef, undef, undef, undef, undef, undef,
203
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
204
                     undef, 'Crowd-Fu', 'Kostenst', undef, undef, undef, undef, undef, undef, undef, undef,
205
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
206
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
207
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
208
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
209
                     undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
210
                     undef, undef, undef, undef, undef ]
198
cmp_bag($data_csv[2], [ '784,9', 'S', 'EUR', '', '', '', '1200', '1400', '', '0501', "\x{de} sales \x{a5}& i",
199
                     '', '', '', '', '', '', '', '', '', '', '',
200
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
201
                     '', 'Crowd-Fu', 'Kostenst', '', '', '', '', '', '', '', '',
202
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
203
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
204
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
205
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
206
                     '', '', '', '', '', '', '', '', '', '', '', '', '',
207
                     '', '', '', '', '' ]
211 208
        );
212 209
my $march_9 = DateTime->new(year => 2017, month =>  3, day => 9);
213 210
my $invoice2 = create_sales_invoice(

Auch abrufbar als: Unified diff