X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/54a4321bc31f0a56b8acbfa8e3a48f210409293d..f27a8a8ff5f1949aaee43f1df987ca3d05ba5eba:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index 90b7d3d2f..b63e633ab 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -147,7 +147,7 @@ sub new { $self->{action} = lc $self->{action}; $self->{action} =~ s/( |-|,|\#)/_/g; - $self->{version} = "2.4.1"; + $self->{version} = "2.4.2"; $main::lxdebug->leave_sub(); @@ -653,7 +653,18 @@ sub format_amount { } my $neg = ($amount =~ s/-//); - $amount = $self->round_amount($amount, $places) if ($places =~ /\d/); + if (defined($places) && ($places ne '')) { + 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 @@ -679,18 +690,6 @@ sub parse_amount { my ($self, $myconfig, $amount) = @_; - if ($myconfig->{in_numberformat} == 1) { - # Extra input number format 1000.00 or 1000,00 - $amount =~ s/,/\./g; - $amount = scalar reverse $amount; - $amount =~ s/\./DOT/; - $amount =~ s/\.//g; - $amount =~ s/DOT/\./; - $amount = scalar reverse $amount; - $main::lxdebug->leave_sub(2); - return ($amount * 1); - } - if ( ($myconfig->{numberformat} eq '1.000,00') || ($myconfig->{numberformat} eq '1000,00')) { $amount =~ s/\.//g; @@ -1149,11 +1148,11 @@ sub set_payment_options { selectrow_query($self, $dbh, $query); my $total = ($self->{invtotal}) ? $self->{invtotal} : $self->{ordtotal}; + my $skonto_amount = $self->parse_amount($myconfig, $total) * + $self->{percent_skonto}; $self->{skonto_amount} = - $self->format_amount($myconfig, - $self->parse_amount($myconfig, $total) * - $self->{percent_skonto}, 2); + $self->format_amount($myconfig, $skonto_amount, 2); if ($self->{"language_id"}) { $query = @@ -1183,9 +1182,7 @@ sub set_payment_options { my $saved_numberformat = $myconfig->{"numberformat"}; $myconfig->{"numberformat"} = $output_numberformat; $self->{skonto_amount} = - $self->format_amount($myconfig, - $self->parse_amount($myconfig, $total) * - $self->{percent_skonto}, 2); + $self->format_amount($myconfig, $skonto_amount, 2); $myconfig->{"numberformat"} = $saved_numberformat; } }