Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b084886b

Von Bernd Bleßmann vor etwa 3 Jahren hinzugefügt

  • ID b084886b68e6eb9e5d25605894641ce24ae23473
  • Vorgänger 1a4d8bb8
  • Nachfolger e569098e

Definitionen von format_amount_units entfernt.

Durch die zwei vorgherigen commits wird format_amount_units nicht
mehr verwendet.

Unterschiede anzeigen:

SL/Form.pm
709 709
  SL::Helper::Number::_format_number($amount, $places, %$myconfig, dash => $dash);
710 710
}
711 711

  
712
sub format_amount_units {
713
  $main::lxdebug->enter_sub();
714

  
715
  my $self             = shift;
716
  my %params           = @_;
717

  
718
  my $myconfig         = \%main::myconfig;
719
  my $amount           = $params{amount} * 1;
720
  my $places           = $params{places};
721
  my $part_unit_name   = $params{part_unit};
722
  my $amount_unit_name = $params{amount_unit};
723
  my $conv_units       = $params{conv_units};
724
  my $max_places       = $params{max_places};
725

  
726
  if (!$part_unit_name) {
727
    $main::lxdebug->leave_sub();
728
    return '';
729
  }
730

  
731
  my $all_units        = AM->retrieve_all_units;
732

  
733
  if (('' eq ref $conv_units) && ($conv_units =~ /convertible/)) {
734
    $conv_units = AM->convertible_units($all_units, $part_unit_name, $conv_units eq 'convertible_not_smaller');
735
  }
736

  
737
  if (!scalar @{ $conv_units }) {
738
    my $result = $self->format_amount($myconfig, $amount, $places, undef, $max_places) . " " . $part_unit_name;
739
    $main::lxdebug->leave_sub();
740
    return $result;
741
  }
742

  
743
  my $part_unit  = $all_units->{$part_unit_name};
744
  my $conv_unit  = ($amount_unit_name && ($amount_unit_name ne $part_unit_name)) ? $all_units->{$amount_unit_name} : $part_unit;
745

  
746
  $amount       *= $conv_unit->{factor};
747

  
748
  my @values;
749
  my $num;
750

  
751
  foreach my $unit (@$conv_units) {
752
    my $last = $unit->{name} eq $part_unit->{name};
753
    if (!$last) {
754
      $num     = int($amount / $unit->{factor});
755
      $amount -= $num * $unit->{factor};
756
    }
757

  
758
    if ($last ? $amount : $num) {
759
      push @values, { "unit"   => $unit->{name},
760
                      "amount" => $last ? $amount / $unit->{factor} : $num,
761
                      "places" => $last ? $places : 0 };
762
    }
763

  
764
    last if $last;
765
  }
766

  
767
  if (!@values) {
768
    push @values, { "unit"   => $part_unit_name,
769
                    "amount" => 0,
770
                    "places" => 0 };
771
  }
772

  
773
  my $result = join " ", map { $self->format_amount($myconfig, $_->{amount}, $_->{places}, undef, $max_places), $_->{unit} } @values;
774

  
775
  $main::lxdebug->leave_sub();
776

  
777
  return $result;
778
}
779

  
780 712
sub format_string {
781 713
  $main::lxdebug->enter_sub(2);
782 714

  
SL/Template/Plugin/LxERP.pm
41 41
  return '';
42 42
}
43 43

  
44
sub format_amount_units {
45
  my ($self, $amount, $amount_unit, $part_unit) = @_;
46

  
47
  return $main::form->format_amount_units('amount'      => $amount,
48
                                          'part_unit'   => $part_unit,
49
                                          'amount_unit' => $amount_unit,
50
                                          'conv_units'  => 'convertible_not_smaller');
51
}
52

  
53 44
sub format_percent {
54 45
  my ($self, $var, $places, $skip_zero) = @_;
55 46

  

Auch abrufbar als: Unified diff