Allow to leave amount field empty when adding a new part lot.

This commit is contained in:
Jan Böhmer 2020-03-30 15:13:23 +02:00
parent 1a0e07fbaf
commit 25a4f804d7
2 changed files with 14 additions and 1 deletions

View file

@ -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;

View file

@ -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',