diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index ef82a8bd..e2f85d0b 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -303,8 +303,20 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named return (float) $this->amount; } - public function setAmount(float $new_amount): self + /** + * Sets the amount of parts in the part lot. + * If null is passed, amount will be set to unknown. + * @param float|null $new_amount + * @return $this + */ + public function setAmount(?float $new_amount): self { + //Treat null like unknown amount + if ($new_amount === null) { + $this->instock_unknown = true; + $new_amount = 0.0; + } + $this->amount = $new_amount; return $this; diff --git a/src/Form/Part/PartLotType.php b/src/Form/Part/PartLotType.php index 8d67e514..78461f0b 100644 --- a/src/Form/Part/PartLotType.php +++ b/src/Form/Part/PartLotType.php @@ -88,6 +88,7 @@ class PartLotType extends AbstractType $builder->add('amount', SIUnitType::class, [ 'measurement_unit' => $options['measurement_unit'], + 'required' => false, 'label' => 'part_lot.edit.amount', 'attr' => [ 'class' => 'form-control-sm',