feat : ajout de la partie reception des marchandises (étape 3) et modification du bon de réception
This commit is contained in:
92
src/Entity/Building.php
Normal file
92
src/Entity/Building.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'building')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['building:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['building:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Building
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['building:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['building:read', 'reception:read'])]
|
||||
private string $label = '';
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
#[Groups(['building:read', 'reception:read'])]
|
||||
private string $code = '';
|
||||
|
||||
/**
|
||||
* @var Collection<int, Reception>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Reception::class, mappedBy: 'buildings')]
|
||||
private Collection $receptions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->receptions = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): self
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(string $code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Reception>
|
||||
*/
|
||||
public function getReceptions(): Collection
|
||||
{
|
||||
return $this->receptions;
|
||||
}
|
||||
}
|
||||
92
src/Entity/MerchandiseType.php
Normal file
92
src/Entity/MerchandiseType.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'merchandise_type')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['merchandise-type:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['merchandise-type:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class MerchandiseType
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['reception:read', 'merchandise-type:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['reception:read', 'merchandise-type:read'])]
|
||||
private string $label = '';
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
#[Groups(['reception:read', 'merchandise-type:read'])]
|
||||
private string $code = '';
|
||||
|
||||
/**
|
||||
* @var Collection<int, Reception>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'merchandiseType', targetEntity: Reception::class)]
|
||||
private Collection $receptions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->receptions = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): self
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(string $code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Reception>
|
||||
*/
|
||||
public function getReceptions(): Collection
|
||||
{
|
||||
return $this->receptions;
|
||||
}
|
||||
}
|
||||
71
src/Entity/PelletType.php
Normal file
71
src/Entity/PelletType.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'pellet_type')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['pellet-type:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['pellet-type:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class PelletType
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['pellet-type:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['pellet-type:read', 'reception:read'])]
|
||||
private string $label = '';
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
#[Groups(['pellet-type:read', 'reception:read'])]
|
||||
private string $code = '';
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): self
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(string $code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,10 @@ 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;
|
||||
@@ -106,6 +110,28 @@ class Reception
|
||||
#[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'])]
|
||||
@@ -145,8 +171,10 @@ class Reception
|
||||
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
|
||||
@@ -218,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>
|
||||
*/
|
||||
@@ -238,6 +278,71 @@ class Reception
|
||||
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;
|
||||
|
||||
101
src/Entity/ReceptionPelletBuilding.php
Normal file
101
src/Entity/ReceptionPelletBuilding.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'reception_pellet_building')]
|
||||
#[ORM\UniqueConstraint(name: 'uniq_reception_pellet_building', columns: ['reception_id', 'pellet_type_id', 'building_id'])]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['reception-pellet-building:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['reception-pellet-building:read']],
|
||||
),
|
||||
new Post(
|
||||
normalizationContext: ['groups' => ['reception-pellet-building:read']],
|
||||
denormalizationContext: ['groups' => ['reception-pellet-building:write']],
|
||||
),
|
||||
new Delete(),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['reception' => 'exact'])]
|
||||
class ReceptionPelletBuilding
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['reception-pellet-building:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'pelletBuildings')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['reception-pellet-building:read', 'reception-pellet-building:write'])]
|
||||
private ?Reception $reception = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['reception-pellet-building:read', 'reception-pellet-building:write', 'reception:read'])]
|
||||
private ?PelletType $pelletType = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['reception-pellet-building:read', 'reception-pellet-building:write', 'reception:read'])]
|
||||
private ?Building $building = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getReception(): ?Reception
|
||||
{
|
||||
return $this->reception;
|
||||
}
|
||||
|
||||
public function setReception(?Reception $reception): self
|
||||
{
|
||||
$this->reception = $reception;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPelletType(): ?PelletType
|
||||
{
|
||||
return $this->pelletType;
|
||||
}
|
||||
|
||||
public function setPelletType(?PelletType $pelletType): self
|
||||
{
|
||||
$this->pelletType = $pelletType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBuilding(): ?Building
|
||||
{
|
||||
return $this->building;
|
||||
}
|
||||
|
||||
public function setBuilding(?Building $building): self
|
||||
{
|
||||
$this->building = $building;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user