X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAM.pm;h=fa6e128ea7d57424c86df0c702fa30cf3ccc0b3b;hb=75e721508b508648ffe2454f10cfe29ba8a359dd;hp=9802269746c2578905fb1572fff78e5f2f804808;hpb=29795499e0623f7ff7ea739ed3b61d66dad0e7c6;p=kivitendo-erp.git 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();