+cmp_deeply($data_csv[0],
+ [ '100', 'S', 'EUR', '', '', '', '4660', '1000', 9, '1703', 'Reise März 2',
+ '', '', 'Reisekosten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '1', '', '', '', '', '', '',
+ ],
+ 'gl datev export without delivery date ok');
+
+
+note('testing same invoice, but with deliverydate');
+# 8400 and 8300 should have deliverydate in datev, payment should not
+$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',
+ '', '', '', '', '',
+ ],
+ 'invoice with deliverydate 19% tax export ok';
+
+cmp_deeply $sorted[2],
+ [ '535', 'S', 'EUR', '', '', '',
+ '1400', '8300', '', '1907','meine muh',
+ '', '', 'Test customer', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', "K\x{e4}stchen",
+ '299', '', $ustid, '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '1', '18072017',
+ '', '', '', '', '',
+ ],
+ 'invoice with deliverydate 16% tax export ok';
+
+cmp_deeply $sorted[1],
+ [ '2498,5', 'S', 'EUR', '', '', '',
+ '1200', '1400', '', '2907','meine muh',
+ '', '', 'Test customer', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', "K\x{e4}stchen",
+ '299', '', $ustid, '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '1', '',
+ '', '', '', '', '',
+ ],
+ 'invoice with deliverydate payment export ok';
+
+note('testing same gl transaction with deliverydate');
+$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',
+ '', '', 'Reisekosten März 2018 / Ma Schmidt', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '1', '18072017', '', '', '', '', '',
+ ],
+ 'testing gl transaction with delivery date datev export ok');