Revision a2bab345
Von Sven Schöling vor etwa 8 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
948 | 948 |
} |
949 | 949 |
|
950 | 950 |
sub round_amount { |
951 |
my ($self, $amount, $places) = @_; |
|
951 |
my ($self, $amount, $places, $adjust) = @_;
|
|
952 | 952 |
|
953 | 953 |
return 0 if !defined $amount; |
954 | 954 |
|
955 | 955 |
$places //= 0; |
956 | 956 |
|
957 |
if ($adjust) { |
|
958 |
my $precision = $::instance_conf->get_precision || 0.01; |
|
959 |
return $self->round_amount( $self->round_amount($amount / $precision, 0) * $precision, $places); |
|
960 |
} |
|
961 |
|
|
957 | 962 |
# We use Perl's knowledge of string representation for |
958 | 963 |
# rounding. First, convert the floating point number to a string |
959 | 964 |
# with a high number of places. Then split the string on the decimal |
Auch abrufbar als: Unified diff
Reapply "Form: round_amount precision support"
Und mit neuer Autorschaft neu.