Finalisation réception marchandise, ajout de composant UI et ajout de fixtures (!7)
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [ ] TU/TI/TF rédigée - [x] TU/TI/TF OK - [x] CHANGELOG modifié Reviewed-on: #7 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #7.
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
@@ -16,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;
|
||||
@@ -77,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;
|
||||
@@ -90,15 +96,85 @@ class Reception
|
||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
||||
private ?DateTimeImmutable $receptionDate = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
private ?string $merchandiseDetail = null;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: Weight::class, mappedBy: 'reception', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[Groups(['reception:read'])]
|
||||
private Collection $weights;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'receptions')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?ReceptionType $receptionType = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'receptions')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?MerchandiseType $merchandiseType = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Building>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Building::class, inversedBy: 'receptions')]
|
||||
#[ORM\JoinTable(name: 'reception_building')]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private Collection $buildings;
|
||||
|
||||
/**
|
||||
* @var Collection<int, ReceptionPelletBuilding>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: ReceptionPelletBuilding::class, mappedBy: 'reception', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[Groups(['reception:read'])]
|
||||
private Collection $pelletBuildings;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Supplier $supplier = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Address $address = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Truck $truck = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Carrier $carrier = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Driver $driver = null;
|
||||
|
||||
public function __construct(
|
||||
?DateTimeImmutable $receptionDate = null,
|
||||
) {
|
||||
$this->receptionDate = $receptionDate;
|
||||
$this->weights = new ArrayCollection();
|
||||
$this->receptionDate = $receptionDate;
|
||||
$this->weights = new ArrayCollection();
|
||||
$this->buildings = new ArrayCollection();
|
||||
$this->pelletBuildings = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@@ -112,6 +188,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;
|
||||
@@ -158,6 +246,18 @@ class Reception
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMerchandiseDetail(): ?string
|
||||
{
|
||||
return $this->merchandiseDetail;
|
||||
}
|
||||
|
||||
public function setMerchandiseDetail(?string $merchandiseDetail): self
|
||||
{
|
||||
$this->merchandiseDetail = $merchandiseDetail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Weight>
|
||||
*/
|
||||
@@ -166,6 +266,155 @@ class Reception
|
||||
return $this->weights;
|
||||
}
|
||||
|
||||
public function getReceptionType(): ?ReceptionType
|
||||
{
|
||||
return $this->receptionType;
|
||||
}
|
||||
|
||||
public function setReceptionType(?ReceptionType $receptionType): self
|
||||
{
|
||||
$this->receptionType = $receptionType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMerchandiseType(): ?MerchandiseType
|
||||
{
|
||||
return $this->merchandiseType;
|
||||
}
|
||||
|
||||
public function setMerchandiseType(?MerchandiseType $merchandiseType): self
|
||||
{
|
||||
$this->merchandiseType = $merchandiseType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Building>
|
||||
*/
|
||||
public function getBuildings(): Collection
|
||||
{
|
||||
return $this->buildings;
|
||||
}
|
||||
|
||||
public function addBuilding(Building $building): self
|
||||
{
|
||||
if (!$this->buildings->contains($building)) {
|
||||
$this->buildings->add($building);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeBuilding(Building $building): self
|
||||
{
|
||||
$this->buildings->removeElement($building);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, ReceptionPelletBuilding>
|
||||
*/
|
||||
public function getPelletBuildings(): Collection
|
||||
{
|
||||
return $this->pelletBuildings;
|
||||
}
|
||||
|
||||
public function addPelletBuilding(ReceptionPelletBuilding $pelletBuilding): self
|
||||
{
|
||||
if (!$this->pelletBuildings->contains($pelletBuilding)) {
|
||||
$this->pelletBuildings->add($pelletBuilding);
|
||||
$pelletBuilding->setReception($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePelletBuilding(ReceptionPelletBuilding $pelletBuilding): self
|
||||
{
|
||||
if ($this->pelletBuildings->removeElement($pelletBuilding)) {
|
||||
if ($pelletBuilding->getReception() === $this) {
|
||||
$pelletBuilding->setReception(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSupplier(): ?Supplier
|
||||
{
|
||||
return $this->supplier;
|
||||
}
|
||||
|
||||
public function setSupplier(?Supplier $supplier): self
|
||||
{
|
||||
$this->supplier = $supplier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddress(): ?Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setAddress(?Address $address): self
|
||||
{
|
||||
$this->address = $address;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTruck(): ?Truck
|
||||
{
|
||||
return $this->truck;
|
||||
}
|
||||
|
||||
public function setTruck(?Truck $truck): self
|
||||
{
|
||||
$this->truck = $truck;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrier(): ?Carrier
|
||||
{
|
||||
return $this->carrier;
|
||||
}
|
||||
|
||||
public function setCarrier(?Carrier $carrier): self
|
||||
{
|
||||
$this->carrier = $carrier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDriver(): ?Driver
|
||||
{
|
||||
return $this->driver;
|
||||
}
|
||||
|
||||
public function setDriver(?Driver $driver): self
|
||||
{
|
||||
$this->driver = $driver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addWeight(Weight $weight): self
|
||||
{
|
||||
if (!$this->weights->contains($weight)) {
|
||||
@@ -194,4 +443,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('P-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