diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index beb050bd..011c4a8e 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -202,6 +202,12 @@ final class PartsDataTable implements DataTableTypeInterface htmlspecialchars($this->amountFormatter->format($expiredAmount, $context->getPartUnit()))); } + //When the amount is below the minimum amount, we highlight the number red + if ($context->isNotEnoughInstock()) { + $ret = sprintf('%s', + $this->translator->trans('part.info.amount.less_than_desired'), + $ret); + } return $ret; }, diff --git a/src/Entity/Parts/PartTraits/InstockTrait.php b/src/Entity/Parts/PartTraits/InstockTrait.php index 212e58b7..d7b59469 100644 --- a/src/Entity/Parts/PartTraits/InstockTrait.php +++ b/src/Entity/Parts/PartTraits/InstockTrait.php @@ -151,6 +151,15 @@ trait InstockTrait return false; } + /** + * Returns true, if the total instock amount of this part is less than the minimum amount. + * @return bool + */ + public function isNotEnoughInstock(): bool + { + return $this->getAmountSum() < $this->getMinAmount(); + } + /** * Returns the summed amount of this part (over all part lots) * Part Lots that have unknown value or are expired, are not used for this value. diff --git a/templates/parts/info/_main_infos.html.twig b/templates/parts/info/_main_infos.html.twig index 94c1d67d..3f495be3 100644 --- a/templates/parts/info/_main_infos.html.twig +++ b/templates/parts/info/_main_infos.html.twig @@ -41,11 +41,14 @@ {{ helper.structural_entity_link(part.category) }}
- - {{ part.amountSum | format_amount(part.partUnit) }} - / - {{ part.minAmount | format_amount(part.partUnit) }} - + + {{ part.amountSum | format_amount(part.partUnit) }} + / + {{ part.minAmount | format_amount(part.partUnit) }} + + {% if part.notEnoughInstock %} +  {% trans %}part.info.amount.less_than_desired{% endtrans %} + {% endif %}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 9bcc89c8..e2cb67fb 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -11253,5 +11253,11 @@ Element 3 Not allowed to do the desired action. Please check your permissions and the owner of the part lots. + + + part.info.amount.less_than_desired + Less than desired + +