From: Moritz Bunkus Date: Mon, 12 Feb 2007 09:41:22 +0000 (+0000) Subject: Neues Feature: Wenn die Anzahl Dezimalstellen bei format_amount() negativ ist, dann... X-Git-Tag: release-2.4.2~124 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/commitdiff_plain/ac0c6a8692e05549cb2dc0a60e692f550fa72894?ds=inline Neues Feature: Wenn die Anzahl Dezimalstellen bei format_amount() negativ ist, dann werden mindestens (und nicht exakt) so viele Stellen angezeigt. --- diff --git a/SL/Form.pm b/SL/Form.pm index df17c4b07..44d857c86 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -653,7 +653,18 @@ sub format_amount { } my $neg = ($amount =~ s/-//); - $amount = $self->round_amount($amount, $places) if ($places =~ /\d/); + if (defined($places)) { + if ($places < 0) { + $amount *= 1; + $places *= -1; + + my ($actual_places) = ($amount =~ /\.(\d+)/); + $actual_places = length($actual_places); + $places = $actual_places > $places ? $actual_places : $places; + } + + $amount = $self->round_amount($amount, $places); + } my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars my @p = split(/\./, $amount); # split amount at decimal point