From 18a2ca336c2e4c87bd1d6fe55bc9d83e177584a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 9 Nov 2017 10:02:27 +0100 Subject: [PATCH] =?utf8?q?Testf=C3=A4lle=20f=C3=BCr=20neue=20API=20von=20D?= =?utf8?q?ATEV=20angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- t/datev/datev_format_2018.t | 47 +++++++++++++++++++++---------------- t/datev/invoices.t | 19 ++++++++------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/t/datev/datev_format_2018.t b/t/datev/datev_format_2018.t index 4ab1b8dbc..0841bc012 100644 --- a/t/datev/datev_format_2018.t +++ b/t/datev/datev_format_2018.t @@ -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(); diff --git a/t/datev/invoices.t b/t/datev/invoices.t index 9060e5b39..b9bf80f3f 100644 --- a/t/datev/invoices.t +++ b/t/datev/invoices.t @@ -160,18 +160,19 @@ $datev1->use_pk(0); $datev1->generate_datev_data; -my ($datev_ref, $w_ref) = SL::DATEV::CSV->new(datev_lines => $datev1->generate_datev_lines, - from => $startdate, - to => $enddate, - locked => $datev1->locked, +my $datev_csv = SL::DATEV::CSV->new(datev_lines => $datev1->generate_datev_lines, + from => $startdate, + to => $enddate, + locked => $datev1->locked, ); -# warnings should be undef -> no array elements at all -is(scalar @{ $w_ref }, 0); +$datev_csv->lines; + -# splice away the header, because sort won't do # we need sort, because pay_invoice is not acc_trans_id order safe -my @data_csv = splice @{ $datev_ref }, 2, 5; -@data_csv = sort { $a->[0] cmp $b->[0] } @data_csv; +my @data_csv = sort { $a->[0] cmp $b->[0] } @{ $datev_csv->lines }; +# warnings should be undef -> no array elements at all +is(scalar @{ $datev_csv->warnings }, 0); + cmp_deeply($data_csv[1], [ 535, 'S', 'EUR', '', '', '', '1400', '8300', '', '0101', "\x{de} sales \x{a5}& i", '', '', '', '', '', '', '', '', '', '', '', -- 2.20.1