X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDATEV.pm;h=af188f70a4e911f433464217e59deaac3c146fef;hb=9b16f8f89f00a7429f85144527a97d1168ea0000;hp=51fe4bde59a142b57e76793e45bda6d08c4a8d74;hpb=324726acd30b8992854a2d59fec2a50265613eef;p=kivitendo-erp.git diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 51fe4bde5..af188f70a 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -37,6 +37,7 @@ use SL::DB; use SL::HTML::Util (); use SL::Iconv; use SL::Locale::String qw(t8); +use SL::VATIDNr; use Data::Dumper; use DateTime; @@ -574,7 +575,7 @@ sub generate_datev_data { UNION ALL SELECT ac.acc_trans_id, ac.transdate, ac.gldate, ac.trans_id,gl.id, ac.amount, ac.taxkey, ac.memo, - gl.reference AS invnumber, NULL AS duedate, ac.amount as umsatz, NULL as deliverydate, gl.itime::date, + gl.reference AS invnumber, NULL AS duedate, ac.amount as umsatz, gl.deliverydate, gl.itime::date, gl.description AS name, NULL as ustid, '' AS vcname, NULL AS customer_id, NULL AS vendor_id, c.accno, c.description AS accname, c.taxkey_id as charttax, c.datevautomatik, c.id, ac.chart_link AS link, FALSE AS invoice, @@ -1045,11 +1046,26 @@ sub generate_datev_lines { $datev_data{buchungstext} = $transaction->[$haben]->{'name'}; } if (($transaction->[$haben]->{'ustid'} // '') ne "") { - $datev_data{ustid} = $transaction->[$haben]->{'ustid'}; + $datev_data{ustid} = SL::VATIDNr->normalize($transaction->[$haben]->{'ustid'}); } if (($transaction->[$haben]->{'duedate'} // '') ne "") { $datev_data{belegfeld2} = $transaction->[$haben]->{'duedate'}; } + + # if deliverydate exists, add it to datev export if it is + # * an ar/ap booking that is not a payment + # * a gl booking + if ( ($transaction->[$haben]->{'deliverydate'} // '') ne '' + && ( + ( $transaction->[$haben]->{'table'} =~ /^(ar|ap)$/ + && $transaction->[$haben]->{'link'} !~ m/_paid/ + && $transaction->[$soll]->{'link'} !~ m/_paid/ + ) + || $transaction->[$haben]->{'table'} eq 'gl' + ) + ) { + $datev_data{leistungsdatum} = $transaction->[$haben]->{'deliverydate'}; + } } $datev_data{umsatz} = abs($umsatz); # sales invoices without tax have a different sign??? @@ -1070,6 +1086,8 @@ sub generate_datev_lines { # $datev_data{buchungsschluessel} = !$datevautomatik ? $taxkey : "4"; $datev_data{buchungsschluessel} = $taxkey; } + # set lock for each transaction + $datev_data{locked} = $self->locked; push(@datev_lines, \%datev_data) if $datev_data{umsatz}; } @@ -1162,7 +1180,7 @@ sub kne_buchungsexport { $name =~ s/\ *$//; $kne_file->add_block("\x1E" . $name . "\x1C"); - $kne_file->add_block("\xBA" . $kne->{'ustid'} . "\x1C") if $kne->{'ustid'}; + $kne_file->add_block("\xBA" . SL::VATIDNr->normalize($kne->{'ustid'}) . "\x1C") if $kne->{'ustid'}; $kne_file->add_block("\xB3" . $kne->{'waehrung'} . "\x1C" . "\x79"); }; @@ -1631,7 +1649,7 @@ Forces a garbage collection on previous exports which will delete all exports th =item errors -Returns a list of errors that occured. If no errors occured, the export was a success. +Returns a list of errors that occurred. If no errors occurred, the export was a success. =item export