X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fdatev%2Finvoices.t;h=3b2d4af57ac385441d4a1a74a856d6defc4afa33;hb=94f5cb152afa9210162295b6727801c296af0631;hp=9060e5b3901aa55b1cab634287b04bada14be52c;hpb=0ad87689526defc4e51d33b4768158a26c6945dd;p=kivitendo-erp.git diff --git a/t/datev/invoices.t b/t/datev/invoices.t index 9060e5b39..3b2d4af57 100644 --- a/t/datev/invoices.t +++ b/t/datev/invoices.t @@ -73,9 +73,9 @@ cmp_deeply \@data_datev, [ 'konto' => '1400', 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018', 'kost2' => 'Crowd-Funding September 2017', + 'locked' => undef, 'umsatz' => '249.9', 'waehrung' => 'EUR', - 'soll_haben_kennzeichen' => 'S', }, { 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice", @@ -85,15 +85,13 @@ cmp_deeply \@data_datev, [ 'konto' => '1400', 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018', 'kost2' => 'Crowd-Funding September 2017', + 'locked' => undef, 'umsatz' => 535, 'waehrung' => 'EUR', - 'soll_haben_kennzeichen' => 'S', }, { 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice", - - -'buchungstext' => 'Testcustomer', + 'buchungstext' => 'Testcustomer', 'buchungstext' => 'Testcustomer', 'datum' => '05.01.2017', 'gegenkonto' => '1400', @@ -101,8 +99,8 @@ cmp_deeply \@data_datev, [ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018', 'kost2' => 'Crowd-Funding September 2017', 'umsatz' => '784.9', + 'locked' => undef, 'waehrung' => 'EUR', - 'soll_haben_kennzeichen' => 'S', }, ], "trans_id datev check ok"; @@ -119,8 +117,8 @@ cmp_bag $datev1->generate_datev_lines, [ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018', 'kost2' => 'Crowd-Funding September 2017', 'umsatz' => '249.9', + 'locked' => undef, 'waehrung' => 'EUR', - 'soll_haben_kennzeichen' => 'S', }, { 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice", @@ -131,8 +129,8 @@ cmp_bag $datev1->generate_datev_lines, [ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018', 'kost2' => 'Crowd-Funding September 2017', 'umsatz' => 535, + 'locked' => undef, 'waehrung' => 'EUR', - 'soll_haben_kennzeichen' => 'S', }, { 'belegfeld1' => "\x{de} sales \x{a5}& inv\x{f6}ice", @@ -143,8 +141,8 @@ cmp_bag $datev1->generate_datev_lines, [ 'kost1' => 'Kostenstelle DATEV-Schnittstelle 2018', 'kost2' => 'Crowd-Funding September 2017', 'umsatz' => '784.9', + 'locked' => undef, 'waehrung' => 'EUR', - 'soll_haben_kennzeichen' => 'S', }, ], "trans_id datev check use_pk ok"; @@ -160,21 +158,22 @@ $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", - '', '', '', '', '', '', '', '', '', '', '', +cmp_deeply($data_csv[1], [ '535', 'S', 'EUR', '', '', '', '1400', '8300', '', '0101', "\x{de} sales \x{a5}& i", + '', '', 'Testcustomer', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Kostenst', 'Crowd-Fu', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -182,11 +181,11 @@ cmp_deeply($data_csv[1], [ 535, 'S', 'EUR', '', '', '', '1400', '8300', '', '010 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', - '', '', '', '', '' ] + '', '', '1', '', '', '', '', '', '' ] ); cmp_deeply($data_csv[0], [ '249,9', 'S', 'EUR', '', '', '', '1400', '8400', '', '0101', "\x{de} sales \x{a5}& i", - '', '', '', '', '', '', '', '', '', '', '', + '', '', 'Testcustomer', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Kostenst', 'Crowd-Fu', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -194,10 +193,10 @@ cmp_deeply($data_csv[0], [ '249,9', 'S', 'EUR', '', '', '', '1400', '8400', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', - '', '', '', '', '' ] + '', '', '1', '', '', '', '', '', '' ] ); cmp_deeply($data_csv[2], [ '784,9', 'S', 'EUR', '', '', '', '1200', '1400', '', '0501', "\x{de} sales \x{a5}& i", - '', '', '', '', '', '', '', '', '', '', '', + '', '', 'Testcustomer', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'Kostenst', 'Crowd-Fu', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -205,7 +204,7 @@ cmp_deeply($data_csv[2], [ '784,9', 'S', 'EUR', '', '', '', '1200', '1400', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', - '', '', '', '', '' ] + '', '', '1', '', '', '', '', '', '' ] ); my $march_9 = DateTime->new(year => 2017, month => 3, day => 9); my $invoice2 = create_sales_invoice( @@ -248,7 +247,27 @@ $datev->generate_datev_data(use_pk => 1, from_to => $datev->fromto); $datev_lines = $datev->generate_datev_lines; note('testing purchase invoice'); -my $purchase_invoice = new_purchase_invoice(); +my $purchase_invoice = create_ap_transaction( + vendor => $vendor, + invnumber => 'ap1', + amount => '226', + netamount => '200', + transdate => $date, + gldate => $date, + itime => $date, # make sure itime is 1.1., as gldatefrom tests for itime! + taxincluded => 0, + bookings => [ + { + chart => SL::DB::Manager::Chart->find_by(accno => '3400'), + amount => 100, + }, + { + chart => SL::DB::Manager::Chart->find_by(accno => '3300'), + amount => 100, + }, + ], +); + $datev1 = SL::DATEV->new( dbh => $purchase_invoice->db->dbh, trans_id => $purchase_invoice->id, @@ -264,8 +283,8 @@ cmp_deeply $datev1->generate_datev_lines, [ 'konto' => '3400', 'kost1' => undef, 'kost2' => undef, - 'soll_haben_kennzeichen' => 'H', 'umsatz' => 119, + 'locked' => undef, 'waehrung' => 'EUR' }, { @@ -276,8 +295,8 @@ cmp_deeply $datev1->generate_datev_lines, [ 'konto' => '3300', 'kost1' => undef, 'kost2' => undef, - 'soll_haben_kennzeichen' => 'H', 'umsatz' => 107, + 'locked' => undef, 'waehrung' => 'EUR' } ], "trans_id datev check purchase_invoice ok"; @@ -292,8 +311,8 @@ cmp_deeply $datev1->generate_datev_lines, [ 'konto' => '3400', 'kost1' => undef, 'kost2' => undef, - 'soll_haben_kennzeichen' => 'H', 'umsatz' => 119, + 'locked' => undef, 'waehrung' => 'EUR' }, { @@ -304,13 +323,15 @@ cmp_deeply $datev1->generate_datev_lines, [ 'konto' => '3300', 'kost1' => undef, 'kost2' => undef, - 'soll_haben_kennzeichen' => 'H', 'umsatz' => 107, + 'locked' => undef, 'waehrung' => 'EUR' } ], "trans_id datev check purchase_invoice use_pk ok"; note('testing gldatefrom'); +# test an order with transdate in january, but that was booked in march +# gldatefrom in DATEV.pm checks for itime, not gldate!!! $datev = SL::DATEV->new( dbh => $dbh, from => $startdate, @@ -330,109 +351,7 @@ $datev->generate_datev_data(from_to => $datev->fromto); cmp_deeply $datev->generate_datev_lines, [], "no bookings for January made after May 1st: ok"; done_testing(); -# clear_up(); - -sub new_purchase_invoice { - # manually create a Kreditorenbuchung from scratch, ap + acc_trans bookings, as no helper exists yet, like $invoice->post. - # arap-Booking must come last in the acc_trans order - # this function was essentially copied from t/db_helper/payment.t, refactor once $purchase_invoice->post exists - my $currency_id = $::instance_conf->get_currency_id; - my $employee = SL::DB::Manager::Employee->current || die "No employee"; - my $taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || die "No taxzone"; - - my $purchase_invoice = SL::DB::PurchaseInvoice->new( - amount => '226', - currency_id => $currency_id, - employee_id => $employee->id, - gldate => $date, - invnumber => "ap1", - invoice => 0, - itime => $date, - mtime => $date, - netamount => '200', - paid => '0', - taxincluded => 0, - taxzone_id => $taxzone->id, - transdate => $date, - type => 'invoice', - vendor_id => $vendor->id, - )->save; - - my $expense_chart = SL::DB::Manager::Chart->find_by(accno => '3400'); - my $expense_chart_booking= SL::DB::AccTransaction->new( - amount => '-100', - chart_id => $expense_chart->id, - chart_link => $expense_chart->link, - itime => $date, - mtime => $date, - source => '', - tax_id => SL::DB::Manager::Tax->find_by(taxkey => 9)->id, - taxkey => 9, - transdate => $date, - trans_id => $purchase_invoice->id, - ); - $expense_chart_booking->save; - - my $tax_chart = SL::DB::Manager::Chart->find_by(accno => '1576'); - my $tax_chart_booking= SL::DB::AccTransaction->new( - amount => '-19', - chart_id => $tax_chart->id, - chart_link => $tax_chart->link, - itime => $date, - mtime => $date, - source => '', - tax_id => SL::DB::Manager::Tax->find_by(taxkey => 9)->id, - taxkey => 0, - transdate => $date, - trans_id => $purchase_invoice->id, - ); - $tax_chart_booking->save; - $expense_chart = SL::DB::Manager::Chart->find_by(accno => '3300'); - $expense_chart_booking= SL::DB::AccTransaction->new( - amount => '-100', - chart_id => $expense_chart->id, - chart_link => $expense_chart->link, - itime => $date, - mtime => $date, - source => '', - tax_id => SL::DB::Manager::Tax->find_by(taxkey => 8)->id, - taxkey => 8, - transdate => $date, - trans_id => $purchase_invoice->id, - ); - $expense_chart_booking->save; - - $tax_chart = SL::DB::Manager::Chart->find_by(accno => '1571'); - $tax_chart_booking= SL::DB::AccTransaction->new( - trans_id => $purchase_invoice->id, - chart_id => $tax_chart->id, - chart_link => $tax_chart->link, - amount => '-7', - transdate => $date, - itime => $date, - mtime => $date, - source => '', - taxkey => 0, - tax_id => SL::DB::Manager::Tax->find_by(taxkey => 8)->id, - ); - $tax_chart_booking->save; - my $arap_chart = SL::DB::Manager::Chart->find_by(accno => '1600'); - my $arap_booking= SL::DB::AccTransaction->new( - trans_id => $purchase_invoice->id, - chart_id => $arap_chart->id, - chart_link => $arap_chart->link, - amount => '226', - transdate => $date, - itime => $date, - mtime => $date, - source => '', - taxkey => 0, - tax_id => SL::DB::Manager::Tax->find_by(taxkey => 0)->id, - ); - $arap_booking->save; - - return $purchase_invoice; -} +clear_up(); sub clear_up { SL::DB::Manager::AccTransaction->delete_all(all => 1);