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) }}