X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/29795499e0623f7ff7ea739ed3b61d66dad0e7c6..a1070c2d94abd46d8bba45c2a57609e59f2582a9:/SL/AM.pm diff --git a/SL/AM.pm b/SL/AM.pm index 980226974..fa6e128ea 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1880,6 +1880,17 @@ sub units_in_use { $main::lxdebug->leave_sub(); } +# if $a is translatable to $b, return the factor between them. +# else return 1 +sub convert_unit { + $main::lxdebug->enter_sub(2); + ($this, $a, $b, $all_units) = @_; + + $main::lxdebug->leave_sub(2) and return 0 unless $all_units->{$a} && $all_units->{$b}; + $main::lxdebug->leave_sub(2) and return 0 unless $all_units->{$a}{base_unit} eq $all_units->{$b}{base_unit}; + $main::lxdebug->leave_sub(2) and return $all_units->{$a}{factor} / $all_units->{$b}{factor}; +} + sub unit_select_data { $main::lxdebug->enter_sub();