X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/4bc8abba0059b4c7a490a43d1eebfb7a3b4e8647..2a0cbd885790174fa0f212e6661b30362650a42c:/SL/DB/Unit.pm diff --git a/SL/DB/Unit.pm b/SL/DB/Unit.pm index 900558fbd..508aa7477 100644 --- a/SL/DB/Unit.pm +++ b/SL/DB/Unit.pm @@ -1,5 +1,8 @@ package SL::DB::Unit; +use List::MoreUtils qw(any); + + use strict; use SL::DB::MetaSetup::Unit; @@ -54,7 +57,13 @@ sub convert_to { my $my_base_factor = $self->base_factor || 1; my $other_base_factor = $other_unit->base_factor || 1; - return $qty * $my_base_factor / $other_base_factor; + return ($qty // 0) * $my_base_factor / $other_base_factor; +} + +sub is_time_based { + my ($self) = @_; + + return any { $_->id == $self->id } @{ SL::DB::Manager::Unit->time_based_units }; } 1;