Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision becc49b1

Von Stephan Köhler vor fast 19 Jahren hinzugefügt

  • ID becc49b1374f60cd4c8b389490859e92a99ae572
  • Vorgänger cb9ded86
  • Nachfolger 07d71c33

Merge von 581,589-595 aus unstable: Patch zum Rundungsfehler
-Bug 189: Patch zum Rundungsfehler
-sub round_amount schnedet nun anhängende Nullen automatisch ab.
-Änderungen bez. sub round_amound von heute Morgen wieder herausgenommen, weil nonfunktional. Das problem scheint woanders zu liegen.
-Darstellungsfehler bei Ganzzahlen behoben. Vorher wurde bspw. '2' als '2,' dargestellt, nun wird richtig formatiert.
-Die Anzahl der dargestellten Nachkommastellen jedes einzelnen Preises sollte mit der eingegebenen Anzahl
an Nachkommastellen übereinstimmen. Die eingegebenen Preise sollten nicht gerundet werden.

Unterschiede anzeigen:

SL/Form.pm
540 540
        $amount =~ s/\d{3,}?/$&,/g;
541 541
        $amount =~ s/,$//;
542 542
        $amount = join '', reverse split //, $amount;
543
        $amount .= "\.$dec".$fillup;
543
        $amount .= "\.$dec".$fillup if ($places ne '' && $places*1 != 0);
544 544
      }
545 545

  
546 546
      if ($myconfig->{numberformat} eq '1.000,00') {
547 547
        $amount =~ s/\d{3,}?/$&./g;
548 548
        $amount =~ s/\.$//;
549 549
        $amount = join '', reverse split //, $amount;
550
        $amount .= ",$dec" .$fillup;
550
        $amount .= ",$dec".$fillup if ($places ne '' && $places*1 != 0);
551 551
      }
552 552

  
553 553
      if ($myconfig->{numberformat} eq '1000,00') {
554 554
        $amount = "$whole";
555
        $amount .= ",$dec" .$fillup;
555
        $amount .= ",$dec" .$fillup if ($places ne '' && $places*1 != 0);
556 556
      }
557 557

  
558 558
      if ($dash =~ /-/) {
......
604 604
  $main::lxdebug->enter_sub();
605 605

  
606 606
  my ($self, $amount, $places) = @_;
607
  my $rc;
607
  my $round_amount;
608 608

  
609
  #  $places = 3 if $places == 2;
610

  
611
  if (($places * 1) >= 0) {
612

  
613
    # add 1/10^$places+3
614
    $rc =
615
      sprintf("%.${places}f",
616
              $amount + (1 / (10**($places + 3))) * (($amount > 0) ? 1 : -1));
617
  } else {
618
    $places *= -1;
619
    $rc =
620
      sprintf("%.f", $amount / (10**$places) + (($amount > 0) ? 0.1 : -0.1)) *
621
      (10**$places);
622
  }
609
  # Rounding like "Kaufmannsrunden"
610
  # Descr. http://de.wikipedia.org/wiki/Rundung
611
  # Inspired by 
612
  # http://www.perl.com/doc/FAQs/FAQ/oldfaq-html/Q4.13.html
613
  # Solves Bug: 189
614
  # Udo Spallek
615
  $amount       = $amount * (10 ** ($places));
616
  $round_amount = int($amount + .5 * ($amount <=> 0))/(10**($places));
623 617

  
624 618
  $main::lxdebug->leave_sub();
625 619

  
626
  return $rc;
620
  return $round_amount;
621
  
627 622
}
628 623

  
629 624

  

Auch abrufbar als: Unified diff