From: Sven Schöling Date: Mon, 16 Jan 2012 17:37:16 +0000 (+0100) Subject: SL::Form: Zwei Warnings unterdrücken. X-Git-Tag: release-2.7.0beta1~52 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2d75060f8f44f7be4e65a07cd04b3f1735d9fed7;p=kivitendo-erp.git SL::Form: Zwei Warnings unterdrücken. Warnungen tauchen auf in format_amount, wenn paramtere $dash fehlte, und wenn ohne Nachkommastellen formatiert wurde. --- diff --git a/SL/Form.pm b/SL/Form.pm index 2647a2bca..70a559d35 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -852,6 +852,7 @@ sub format_amount { $main::lxdebug->enter_sub(2); my ($self, $myconfig, $amount, $places, $dash) = @_; + $dash ||= ''; if ($amount eq "") { $amount = 0; @@ -868,9 +869,10 @@ sub format_amount { $amount *= 1; $places *= -1; - my ($actual_places) = ($amount =~ /\.(\d+)/); - $actual_places = length($actual_places); - $places = $actual_places > $places ? $actual_places : $places; + if ($amount =~ /\.(\d+)/) { + my $actual_places = length $1; + $places = $actual_places if $actual_places > $places; + } } } $amount = $self->round_amount($amount, $places); @@ -882,7 +884,7 @@ sub format_amount { $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters $amount = $p[0]; - $amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne ''); + $amount .= $d[0].($p[1]||'').(0 x ($places - length ($p[1]||''))) if ($places || $p[1] ne ''); $amount = do { ($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) :