Testfälle für neue API von DATEV angepasst
[kivitendo-erp.git] / t / datev / datev_format_2018.t
index 4ab1b8d..0841bc0 100644 (file)
@@ -68,18 +68,18 @@ $datev1->generate_datev_lines;
 # check conversion to csv
 $datev1->from($startdate);
 $datev1->to($enddate);
-my ($datev_ref, $warnings_ref, $die_message);
+my ($datev_csv, $die_message);
 eval {
-  ($datev_ref, $warnings_ref) = SL::DATEV::CSV->new(datev_lines  => $datev1->generate_datev_lines,
-                                                     from         => $startdate,
-                                                     to           => $enddate,
-                                                     locked       => $datev1->locked,
-                                                    );
+  $datev_csv = SL::DATEV::CSV->new(datev_lines  => $datev1->generate_datev_lines,
+                                   from         => $startdate,
+                                   to           => $enddate,
+                                   locked       => $datev1->locked,
+                                  );
+  my $lines_aref = $datev_csv->lines; # dies only if we assign (do stuff with the data)
   1;
 } or do {
   $die_message = $@;
 };
-
 ok($die_message =~ m/Falscher Feldwert 'ݗݘݰݶ' für Feld 'belegfeld1' bei der Transaktion mit dem Umsatz von/, 'wrong_encoding');
 
 
@@ -95,13 +95,15 @@ $datev3->from($startdate);
 $datev3->to($enddate);
 $datev3->generate_datev_data;
 $datev3->generate_datev_lines;
-my ($datev_ref2, $warnings_ref2, $die_message2);
+my ($datev_csv2, $die_message2);
 eval {
-  ($datev_ref2, $warnings_ref2) = SL::DATEV::CSV->new(datev_lines  => $datev3->generate_datev_lines,
-                                                       from         => $startdate,
-                                                       to           => $enddate,
-                                                       locked       => $datev3->locked,
-                                                      );
+  $datev_csv2 = SL::DATEV::CSV->new(datev_lines  => $datev3->generate_datev_lines,
+                                    from         => $startdate,
+                                    to           => $enddate,
+                                    locked       => $datev3->locked,
+                                   );
+my $lines_aref = $datev_csv2->lines; # dies only if we assign (do stuff with the data)
+
   1;
 } or do {
   $die_message2 = $@;
@@ -172,14 +174,14 @@ $datev2->to($enddate);
 $datev2->generate_datev_data;
 $datev2->generate_datev_lines;
 
-my ($datev_ref3, $warnings_ref3) = SL::DATEV::CSV->new(datev_lines  => $datev2->generate_datev_lines,
-                                                       from         => $startdate,
-                                                       to           => $enddate,
-                                                       locked       => $datev2->locked,
-                                                      );
+my $datev_csv3  = SL::DATEV::CSV->new(datev_lines  => $datev2->generate_datev_lines,
+                                      from         => $startdate,
+                                      to           => $enddate,
+                                      locked       => $datev2->locked,
+                                     );
 
-my @data_csv = splice @{ $datev_ref3 }, 2, 5;
-@data_csv    = sort { $a->[0] cmp $b->[0] } @data_csv;
+my @data_csv = $datev_csv3->lines;
+@data_csv    = sort { $a->[0] cmp $b->[0] } @{ $datev_csv3->lines };
 cmp_deeply($data_csv[0], [ 100, 'H', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
                      '', '', '', '', '', '', '', '', '', '', '',
                      '', '', '', '', '', '', '', '', '', '', '', '', '',
@@ -192,6 +194,11 @@ cmp_deeply($data_csv[0], [ 100, 'H', 'EUR', '', '', '', '4660', '1000', 9, '1703
                      '', '', '', '', '' ]
        );
 
+# TODO warnings are not yet tested
+# currently most of the valid_checks are senseless because of
+# the strict input_checks before. Maybe something like encoding mismatch of invnumber,
+# can be altered to just a warning (not a mandantory field!)
+
 done_testing();
 clear_up();