DATEV-Export: Rundungsfehler berücksichtigen & Codevereinfachung
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 5 Feb 2010 13:21:58 +0000 (14:21 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 5 Feb 2010 16:03:46 +0000 (17:03 +0100)
SL/DATEV.pm

index 5da4449..56c3e82 100644 (file)
@@ -482,13 +482,14 @@ sub _get_transactions {
           $absumsatz               += -1 * $new_trans{'amount'};
 
         } else {
-          my $unrounded             = $trans->[$j]->{'amount'} * (1 + $tax_rate) * -1; # + $rounding_error;
+          my $unrounded             = $trans->[$j]->{'amount'} * (1 + $tax_rate) * -1 + $rounding_error;
           my $rounded               = $form->round_amount($unrounded, 2);
-          $rounding_error          += $unrounded - $rounded;
+
+          $rounding_error           = $unrounded - $rounded;
           $new_trans{'amount'}      = $rounded;
-          $new_trans{'umsatz'}      = abs($form->round_amount(($trans->[$j]->{'amount'} * (1 + $tax_rate)), 2)) * $ml;
-          $trans->[$j]->{'umsatz'}  = abs($form->round_amount(($trans->[$j]->{'amount'} * (1 + $tax_rate)), 2)) * $ml;
-          $absumsatz               += $form->round_amount($trans->[$j]->{'amount'} + $trans->[$j]->{'amount'} * $tax_rate, 2);
+          $new_trans{'umsatz'}      = abs($rounded) * $ml;
+          $trans->[$j]->{'umsatz'}  = $new_trans{umsatz};
+          $absumsatz               -= $rounded;
         }
 
         push @{ $form->{DATEV} }, [ \%new_trans, $trans->[$j] ];