tamaki.mes.utils.formatUnitRatio
Description
Formats a quantity unit and a time unit into a readable ratio string. The quantity unit is pluralised
and the time unit is singularised, then they are joined with a slash. For example, "BOTTLE" and
"MINUTES" become "bottles/minute".
If either argument is empty or None, the function returns None.
Syntax
tamaki.mes.utils.formatUnitRatio(unitQuantity, unitTime)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
unitQuantity | String | False | The quantity unit (for example "BOTTLE"). |
unitTime | String | False | The time unit (for example "MINUTES"). |
Returns
A String ratio such as "bottles/minute", or None if either argument is empty.
Code Examples
# In a binding script transform: build a rate label such as "12.00 bottles/minute"
result = "{:.2f}".format(value['maxStdRate']) if value['maxStdRate'] else '0'
result += ' ' + str(tamaki.mes.utils.formatUnitRatio(value['uom'] or '', value['uomRate'] or ''))
return result