X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/ed276d3517c3c5d617a414536ae09c213700f0bb..1422e28a66f8a5def07ce531db0c07a3ff6e8432:/SL/DATEV.pm diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 7f38c88c1..cd04053ba 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -426,10 +426,11 @@ sub _get_transactions { $ref->{is_tax} = 1; } - if ( !$ref->{invoice} - && $ref->{is_tax} - && !($prev_ref->{is_tax}) - && (_sign($ref->{amount}) == _sign($prev_ref->{amount}))) { + if ( !$ref->{invoice} # we have a non-invoice booking (=gl) + && $ref->{is_tax} # that has "is_tax" set + && !($prev_ref->{is_tax}) # previous line wasn't is_tax + && (_sign($ref->{amount}) == _sign($prev_ref->{amount}))) # and sign same as previous sign + { $trans->[$i - 1]->{tax_amount} = $ref->{amount}; } } @@ -442,7 +443,10 @@ sub _get_transactions { } for my $j (0 .. (scalar(@{$trans}) - 1)) { - if (abs($trans->[$j]->{'amount'}) > abs($absumsatz)) { + # for gl-bookings no split is allowed and there is no AR/AP account, so we always use the maximum value as a reference + # for ap/ar bookings we can always search for AR/AP in link and use that + if ( ( not $trans->[$j]->{'invoice'} and abs($trans->[$j]->{'amount'}) > abs($absumsatz) ) + or ($trans->[$j]->{'invoice'} and ($trans->[$j]->{'link'} eq 'AR' or $trans->[$j]->{'link'} eq 'AP'))) { $absumsatz = $trans->[$j]->{'amount'}; $notsplitindex = $j; }