]> wagnertech.de Git - mfinanz.git/blobdiff - t/datev/datev_format_2018.t
Tests: DATEV-CSV-Export: Lieferdatum/Leistungsdatum
[mfinanz.git] / t / datev / datev_format_2018.t
index d97c329982f46b2df89fc05c3e94c666e48ab00f..785cff7e56d6f83952fee680049c89c683102523 100644 (file)
@@ -23,11 +23,12 @@ clear_up();
 my $d = SL::DB::Default->get;
 $d->update_attributes(datev_export_format => 'cp1252');
 
+my $ustid           = 'DE123456788';
 my $buchungsgruppe7 = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 7%') || die "No accounting group for 7\%";
 my $date            = DateTime->new(year => 2017, month =>  7, day => 19);
 my $department      = create_department(description => 'Kästchenweiße heiße Preise');
 my $project         = create_project(projectnumber => 2017, description => '299');
-my $customer        = new_customer(name => 'Test customer', ustid => 'DE12345678')->save();
+my $customer        = new_customer(name => 'Test customer', ustid => $ustid)->save();
 my $part1 = new_part(partnumber => '19', description => 'Part 19%')->save;
 my $part2 = new_part(
   partnumber         => '7',
@@ -153,7 +154,7 @@ cmp_deeply $sorted[0],    [ '1963,5', 'S', 'EUR', '', '', '',
                             '', '', 'Test customer', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', "K\x{e4}stchen",
-                            '299', '','DE12345678', '', '', '',
+                            '299', '', $ustid, '', '', '',
                             '', '', '', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', '', '',
@@ -169,7 +170,7 @@ cmp_deeply $sorted[1],     [ '535', 'S', 'EUR', '', '', '',
                             '', '', 'Test customer', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', "K\x{e4}stchen",
-                            '299', '','DE12345678', '', '', '',
+                            '299', '', $ustid, '', '', '',
                             '', '', '', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', '', '',
                             '', '', '', '', '', '', '', '', '',
@@ -233,6 +234,92 @@ cmp_deeply($data_csv[0], [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '17
                      '', '', '1', '', '', '', '', '', '', ]
        );
 
+
+# check deliverydate
+$invoice->deliverydate(DateTime->new(year => 2017, month =>  7, day => 18));
+$invoice->save();
+
+$datev1 = SL::DATEV->new(
+  dbh        => $dbh,
+  trans_id   => $invoice->id,
+);
+
+$datev1->from($startdate);
+$datev1->to($enddate);
+$datev1->generate_datev_data;
+$datev1->generate_datev_lines;
+
+$datev_csv = SL::DATEV::CSV->new(datev_lines  => $datev1->generate_datev_lines,
+                                 from         => $startdate,
+                                 to           => $enddate,
+                                 locked       => $datev1->locked,
+);
+@sorted    = sort { $a->[0] cmp $b->[0] } @{ $datev_csv->lines };
+cmp_deeply $sorted[0],    [ '1963,5', 'S', 'EUR', '', '', '',
+                            '1400', '8400', '', '1907', 'meine muh',
+                            '', '', 'Test customer', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', "K\x{e4}stchen",
+                            '299', '', $ustid, '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '1', '18072017',
+                            '', '', '', '', '',
+                          ];
+cmp_deeply $sorted[1],     [ '535', 'S', 'EUR', '', '', '',
+                             '1400', '8300', '', '1907','meine muh',
+                            '', '', 'Test customer', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', "K\x{e4}stchen",
+                            '299', '', $ustid, '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '', '',
+                            '', '', '', '', '', '', '', '1', '18072017',
+                            '', '', '', '', '',
+                          ];
+
+$gl_transaction->deliverydate(DateTime->new(year => 2017, month =>  7, day => 18));
+$gl_transaction->save;
+
+$datev1 = SL::DATEV->new(
+  dbh        => $dbh,
+  trans_id   => $gl_transaction->id,
+);
+
+$datev1->from($startdate);
+$datev1->to($enddate);
+$datev1->generate_datev_data;
+
+$datev_csv   = SL::DATEV::CSV->new(datev_lines  => $datev1->generate_datev_lines,
+                                   from         => $startdate,
+                                   to           => $enddate,
+                                   locked       => $datev1->locked,
+);
+
+@sorted      = sort { $a->[0] cmp $b->[0] } @{ $datev_csv->lines };
+cmp_deeply($sorted[0], [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
+                         '', '', 'Reisekonsten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '', '', '', '', '', '', '', '', '', '', '',
+                         '', '', '1', '18072017', '', '', '', '', '', ]
+);
+
+
 # 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,