895 |
895 |
my $taxkey = 0;
|
896 |
896 |
my $charttax = 0;
|
897 |
897 |
my $ustid ="";
|
898 |
|
my $document_guid ="";
|
899 |
898 |
my ($haben, $soll);
|
900 |
899 |
for (my $i = 0; $i < $trans_lines; $i++) {
|
901 |
900 |
if ($trans_lines == 2) {
|
... | ... | |
984 |
983 |
# set lock for each transaction
|
985 |
984 |
$datev_data{locked} = $self->locked;
|
986 |
985 |
# add guids if datev export with documents is requested
|
987 |
|
if ($self->documents) {
|
988 |
|
# add exactly one document link for the latest created/uploaded document
|
989 |
|
my $latest_document = SL::DB::Manager::File->get_first(query =>
|
|
986 |
# no records for bank transactions with ar or ap
|
|
987 |
# die Dumper($transaction->[$haben]->{link}) if $transaction->[$haben]->{link} =~ m/paid/;
|
|
988 |
if ( $self->documents && ($transaction->[$haben]->{table} eq 'gl'
|
|
989 |
|| ($datev_data{konto} !~ m/(1810|1370)/ && $datev_data{gegenkonto} !~ m/(1810|1370)/ )) ) {
|
|
990 |
# add all document links for the latest created/uploaded document
|
|
991 |
my $latest_documents = SL::DB::Manager::File->get_all(query =>
|
990 |
992 |
[
|
991 |
|
object_id => $transaction->[$haben]->{trans_id},
|
992 |
|
file_type => 'document'
|
|
993 |
object_id => $transaction->[$haben]->{trans_id},
|
|
994 |
file_type => 'document',
|
|
995 |
or => [
|
|
996 |
object_type => 'gl_transaction',
|
|
997 |
object_type => 'purchase_invoice',
|
|
998 |
object_type => 'invoice',
|
|
999 |
object_type => 'credit_note',
|
|
1000 |
],
|
993 |
1001 |
],
|
994 |
1002 |
sort_by => 'itime DESC');
|
995 |
|
if (ref $latest_document eq 'SL::DB::File') {
|
|
1003 |
#if (ref $latest_document eq 'SL::DB::File') {
|
|
1004 |
if (scalar @{ $latest_documents }) {
|
996 |
1005 |
# if we have a booking document add guid from the latest version
|
997 |
|
$datev_data{document_guid} = $latest_document->file_version->[-1]->guid;
|
998 |
|
push @{ $self->{guids} }, $datev_data{document_guid};
|
|
1006 |
# one record may be referenced to more transaction (credit booking with different accounts)
|
|
1007 |
# therefore collect guids in hash
|
|
1008 |
foreach my $latest_document (@{ $latest_documents }) {
|
|
1009 |
die "No file datatype:" . ref $latest_document unless (ref $latest_document eq 'SL::DB::File');
|
|
1010 |
my $latest_guid = $latest_document->file_version->[-1]->guid;
|
|
1011 |
|
|
1012 |
$self->{guids}{$latest_guid} = 1;
|
|
1013 |
$datev_data{document_guid} .= $datev_data{document_guid} ? ',' : '';
|
|
1014 |
$datev_data{document_guid} .= $latest_guid;
|
|
1015 |
}
|
999 |
1016 |
}
|
1000 |
1017 |
}
|
1001 |
1018 |
push(@datev_lines, \%datev_data) if $datev_data{umsatz};
|
DATEV: Belegexport -> Eine Buchung darf mehrere Belege haben und ...
Filter für nicht Buchungsdokumente (trans_id ist nur in ar, ap und gl
eindeutig).