+$datev1->use_pk(1);
+$datev1->generate_datev_data;
+# TODO for cmp_deeply we need to sort the incoming data structure (see below)
+cmp_bag $datev1->generate_datev_lines, [
+ {
+ 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice",
+ 'buchungstext' => 'Testcustomer',
+ 'datum' => '01.01.2017',
+ 'gegenkonto' => '8400',
+ 'konto' => $customer->customernumber,
+ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018',
+ 'kost2' => 'Crowd-Funding September 2017',
+ 'umsatz' => '249.9',
+ 'locked' => undef,
+ 'waehrung' => 'EUR',
+ },
+ {
+ 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice",
+ 'buchungstext' => 'Testcustomer',
+ 'datum' => '01.01.2017',
+ 'gegenkonto' => '8300',
+ 'konto' => $customer->customernumber,
+ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018',
+ 'kost2' => 'Crowd-Funding September 2017',
+ 'umsatz' => 535,
+ 'locked' => undef,
+ 'waehrung' => 'EUR',
+ },
+ {
+ 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice",
+ 'buchungstext' => 'Testcustomer',
+ 'datum' => '05.01.2017',
+ 'gegenkonto' => $customer->customernumber,
+ 'konto' => '1200',
+ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018',
+ 'kost2' => 'Crowd-Funding September 2017',
+ 'umsatz' => '784.9',
+ 'locked' => undef,
+ 'waehrung' => 'EUR',
+ },
+ ], "trans_id datev check use_pk ok";
+
+
+my $startdate = DateTime->new(year => 2017, month => 1, day => 1);
+my $enddate = DateTime->new(year => 2017, month => 12, day => 31);
+
+# check conversion to csv
+$datev1->from($startdate);
+$datev1->to($enddate);
+# reset use_pk for csv_buchungsexport
+$datev1->use_pk(0);
+$datev1->generate_datev_data;
+
+
+my $datev_csv = SL::DATEV::CSV->new(datev_lines => $datev1->generate_datev_lines,
+ from => $startdate,
+ to => $enddate,
+ locked => $datev1->locked,
+ );
+$datev_csv->lines;
+
+
+# we need sort, because pay_invoice is not acc_trans_id order safe
+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",
+ '', '', 'Testcustomer', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', 'Kostenst', 'Crowd-Fu', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '1', '', '', '', '', '', '' ]
+ );
+
+cmp_deeply($data_csv[0], [ '249,9', 'S', 'EUR', '', '', '', '1400', '8400', '', '0101', "\x{de} sales \x{a5}& i",
+ '', '', 'Testcustomer', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', 'Kostenst', 'Crowd-Fu', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '1', '', '', '', '', '', '' ]
+ );
+cmp_deeply($data_csv[2], [ '784,9', 'S', 'EUR', '', '', '', '1200', '1400', '', '0501', "\x{de} sales \x{a5}& i",
+ '', '', 'Testcustomer', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', 'Kostenst', 'Crowd-Fu', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '', '', '', '', '', '', '', '', '', '', '',
+ '', '', '1', '', '', '', '', '', '' ]
+ );