From ac0c6a8692e05549cb2dc0a60e692f550fa72894 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 12 Feb 2007 09:41:22 +0000 Subject: [PATCH] Neues Feature: Wenn die Anzahl Dezimalstellen bei format_amount() negativ ist, dann werden mindestens (und nicht exakt) so viele Stellen angezeigt. --- SL/Form.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- 2.20.1