From: Bernd Bleßmann Date: Wed, 22 Sep 2021 08:25:12 +0000 (+0200) Subject: Definitionen von format_amount_units entfernt. X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~339 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b084886b68e6eb9e5d25605894641ce24ae23473;p=kivitendo-erp.git Definitionen von format_amount_units entfernt. Durch die zwei vorgherigen commits wird format_amount_units nicht mehr verwendet. --- diff --git a/SL/Form.pm b/SL/Form.pm index 668fd9e44..06c0b2317 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -709,74 +709,6 @@ sub format_amount { SL::Helper::Number::_format_number($amount, $places, %$myconfig, dash => $dash); } -sub format_amount_units { - $main::lxdebug->enter_sub(); - - my $self = shift; - my %params = @_; - - my $myconfig = \%main::myconfig; - my $amount = $params{amount} * 1; - my $places = $params{places}; - my $part_unit_name = $params{part_unit}; - my $amount_unit_name = $params{amount_unit}; - my $conv_units = $params{conv_units}; - my $max_places = $params{max_places}; - - if (!$part_unit_name) { - $main::lxdebug->leave_sub(); - return ''; - } - - my $all_units = AM->retrieve_all_units; - - if (('' eq ref $conv_units) && ($conv_units =~ /convertible/)) { - $conv_units = AM->convertible_units($all_units, $part_unit_name, $conv_units eq 'convertible_not_smaller'); - } - - if (!scalar @{ $conv_units }) { - my $result = $self->format_amount($myconfig, $amount, $places, undef, $max_places) . " " . $part_unit_name; - $main::lxdebug->leave_sub(); - return $result; - } - - my $part_unit = $all_units->{$part_unit_name}; - my $conv_unit = ($amount_unit_name && ($amount_unit_name ne $part_unit_name)) ? $all_units->{$amount_unit_name} : $part_unit; - - $amount *= $conv_unit->{factor}; - - my @values; - my $num; - - foreach my $unit (@$conv_units) { - my $last = $unit->{name} eq $part_unit->{name}; - if (!$last) { - $num = int($amount / $unit->{factor}); - $amount -= $num * $unit->{factor}; - } - - if ($last ? $amount : $num) { - push @values, { "unit" => $unit->{name}, - "amount" => $last ? $amount / $unit->{factor} : $num, - "places" => $last ? $places : 0 }; - } - - last if $last; - } - - if (!@values) { - push @values, { "unit" => $part_unit_name, - "amount" => 0, - "places" => 0 }; - } - - my $result = join " ", map { $self->format_amount($myconfig, $_->{amount}, $_->{places}, undef, $max_places), $_->{unit} } @values; - - $main::lxdebug->leave_sub(); - - return $result; -} - sub format_string { $main::lxdebug->enter_sub(2); diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm index f935a5910..66424fc63 100644 --- a/SL/Template/Plugin/LxERP.pm +++ b/SL/Template/Plugin/LxERP.pm @@ -41,15 +41,6 @@ sub round_amount { return ''; } -sub format_amount_units { - my ($self, $amount, $amount_unit, $part_unit) = @_; - - return $main::form->format_amount_units('amount' => $amount, - 'part_unit' => $part_unit, - 'amount_unit' => $amount_unit, - 'conv_units' => 'convertible_not_smaller'); -} - sub format_percent { my ($self, $var, $places, $skip_zero) = @_;