mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 09:53:35 +02:00
Allow to leave amount field empty when adding a new part lot.
This commit is contained in:
parent
1a0e07fbaf
commit
25a4f804d7
2 changed files with 14 additions and 1 deletions
|
@ -303,8 +303,20 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
||||||
return (float) $this->amount;
|
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;
|
$this->amount = $new_amount;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -88,6 +88,7 @@ class PartLotType extends AbstractType
|
||||||
|
|
||||||
$builder->add('amount', SIUnitType::class, [
|
$builder->add('amount', SIUnitType::class, [
|
||||||
'measurement_unit' => $options['measurement_unit'],
|
'measurement_unit' => $options['measurement_unit'],
|
||||||
|
'required' => false,
|
||||||
'label' => 'part_lot.edit.amount',
|
'label' => 'part_lot.edit.amount',
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'class' => 'form-control-sm',
|
'class' => 'form-control-sm',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue