feat : ajout du numéro identification des receptions et ajustement du bon de reception
This commit is contained in:
@@ -35,19 +35,19 @@ class Address
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||
private string $label = '';
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||
private string $street = '';
|
||||
|
||||
#[ORM\Column(name: 'postal_code', length: 20)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||
private string $postalCode = '';
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||
private string $city = '';
|
||||
|
||||
#[ORM\Column(name: 'country_code', length: 2)]
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\State\ReceptionWeighingProvider;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Context;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
@@ -78,6 +79,10 @@ class Reception
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
private ?string $licensePlate = null;
|
||||
|
||||
#[ORM\Column(length: 20, unique: true, nullable: true)]
|
||||
#[Groups(['reception:read'])]
|
||||
private ?string $identificationNumber = null;
|
||||
|
||||
#[ORM\Column(options: ['default' => 0])]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
private int $currentStep = 0;
|
||||
@@ -155,6 +160,18 @@ class Reception
|
||||
return $this->licensePlate;
|
||||
}
|
||||
|
||||
public function getIdentificationNumber(): ?string
|
||||
{
|
||||
return $this->identificationNumber;
|
||||
}
|
||||
|
||||
public function setIdentificationNumber(?string $identificationNumber): self
|
||||
{
|
||||
$this->identificationNumber = $identificationNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLicensePlate(?string $licensePlate): self
|
||||
{
|
||||
$this->licensePlate = $licensePlate;
|
||||
@@ -321,4 +338,30 @@ class Reception
|
||||
$this->receptionDate = new DateTimeImmutable();
|
||||
}
|
||||
}
|
||||
|
||||
#[ORM\PostPersist]
|
||||
public function initializeIdentificationNumber(PostPersistEventArgs $args): void
|
||||
{
|
||||
if (null !== $this->identificationNumber) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $this->id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$number = sprintf('N-BR-%04d', $this->id);
|
||||
$this->identificationNumber = $number;
|
||||
|
||||
$args->getObjectManager()
|
||||
->getConnection()
|
||||
->executeStatement(
|
||||
'UPDATE reception SET identification_number = :number WHERE id = :id',
|
||||
[
|
||||
'number' => $number,
|
||||
'id' => $this->id,
|
||||
]
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user