X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/bbd8da97d8ab15a358c1c905a9b4f164ed4db04d..6683b7fbb9c7e1ea2e39e1553afd8e415af42cff:/SL/DATEV.pm diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 055a7f076..384ee3f98 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -226,6 +226,8 @@ sub _get_transactions { my $dbh = $form->get_standard_dbh($myconfig); + my @errors = (); + $fromto =~ s/transdate/ac\.transdate/g; my %taxes = selectall_as_map($form, $dbh, qq|SELECT id, rate FROM tax|, 'id', 'rate'); @@ -324,8 +326,8 @@ sub _get_transactions { || $trans->[$j]->{'taxkey'} eq "1" || $trans->[$j]->{'taxkey'} eq "10" || $trans->[$j]->{'taxkey'} eq "11")) { - my %new_trans = {}; - map({ $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys(%{ $trans->[$notsplitindex] })); + my %new_trans = (); + map { $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys %{ $trans->[$notsplitindex] }; $absumsatz += $trans->[$j]->{'amount'}; $new_trans{'amount'} = $trans->[$j]->{'amount'} * (-1); @@ -338,13 +340,13 @@ sub _get_transactions { } elsif (($j != $notsplitindex) && ($trans->[$j]->{'chart_id'} eq "")) { $absumsatz += ($trans->[$j]->{'amount'} * (1 + $taxes{ $taxid_taxkeys{$trans->[$j]->{'taxkey'}} })); - my %new_trans = {}; - map({ $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys(%{ $trans->[$notsplitindex] })); + my %new_trans = (); + map { $new_trans{$_} = $trans->[$notsplitindex]->{$_}; } keys %{ $trans->[$notsplitindex] }; - $test = 1 + $taxes{ $taxid_taxkeys{$trans->[$j]->{'taxkey'}} }; - $new_trans{'amount'} = $form->round_amount(($trans->[$j]->{'amount'} * $test * -1), 2); - $new_trans{'umsatz'} = abs($form->round_amount(($trans->[$j]->{'amount'} * $test), 2)) * $ml; - $trans->[$j]->{'umsatz'} = abs($form->round_amount(($trans->[$j]->{'amount'} * $test), 2)) * $ml; + my $tax_rate = 1 + $taxes{ $taxid_taxkeys{$trans->[$j]->{'taxkey'}} }; + $new_trans{'amount'} = $form->round_amount(($trans->[$j]->{'amount'} * $tax_rate * -1), 2); + $new_trans{'umsatz'} = abs($form->round_amount(($trans->[$j]->{'amount'} * $tax_rate), 2)) * $ml; + $trans->[$j]->{'umsatz'} = abs($form->round_amount(($trans->[$j]->{'amount'} * $tax_rate), 2)) * $ml; push @splits, [ \%new_trans, $trans->[$j] ]; push @{ $form->{DATEV} }, $splits[-1]; @@ -352,11 +354,13 @@ sub _get_transactions { } if (abs($absumsatz) > 0.01) { - $form->error("Datev-Export fehlgeschlagen! Bei Transaktion $trans->[0]->{trans_id} $absumsatz\n"); + push @errors, "Datev-Export fehlgeschlagen! Bei Transaktion $trans->[0]->{trans_id} ($absumsatz)\n"; } } - $sth->finish; - $dbh->disconnect; + + $sth->finish(); + + $form->error(join("
\n", @errors)) if (@errors); $main::lxdebug->leave_sub(); }