feat : mise à jour du bon de réception WIP

This commit is contained in:
2026-02-03 17:16:47 +01:00
parent 5fd2ab8470
commit 081c2ef403
5 changed files with 642 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260203152543 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE bovin_shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, nb_bovin_send INT NOT NULL, shipment_id INT DEFAULT NULL, bovine_type_id INT DEFAULT NULL, PRIMARY KEY (id))');
$this->addSql('CREATE INDEX IDX_7049F4507BE036FC ON bovin_shipment (shipment_id)');
$this->addSql('CREATE INDEX IDX_7049F4507899F32E ON bovin_shipment (bovine_type_id)');
$this->addSql('CREATE TABLE bovine_type_shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, type_label VARCHAR(255) NOT NULL, type_code VARCHAR(255) NOT NULL, PRIMARY KEY (id))');
$this->addSql('CREATE TABLE customer (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, customer_label VARCHAR(255) NOT NULL, customer_code VARCHAR(255) NOT NULL, id_adress_id INT DEFAULT NULL, PRIMARY KEY (id))');
$this->addSql('CREATE INDEX IDX_81398E094B3458B ON customer (id_adress_id)');
$this->addSql('CREATE TABLE shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, date_receipt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, is_waiting BOOLEAN NOT NULL, licence_plate VARCHAR(255) NOT NULL, test VARCHAR(255) NOT NULL, id_carrier_id INT DEFAULT NULL, id_carrier_1_id INT DEFAULT NULL, id_truck_id INT DEFAULT NULL, licence_plate_1_id INT DEFAULT NULL, id_vehicle_id INT DEFAULT NULL, id_customer_id INT DEFAULT NULL, PRIMARY KEY (id))');
$this->addSql('CREATE INDEX IDX_2CB20DC84554740 ON shipment (id_carrier_id)');
$this->addSql('CREATE INDEX IDX_2CB20DC817F550F ON shipment (id_carrier_1_id)');
$this->addSql('CREATE INDEX IDX_2CB20DC964E905B ON shipment (id_truck_id)');
$this->addSql('CREATE INDEX IDX_2CB20DC3B17D73A ON shipment (licence_plate_1_id)');
$this->addSql('CREATE INDEX IDX_2CB20DCF1D99706 ON shipment (id_vehicle_id)');
$this->addSql('CREATE INDEX IDX_2CB20DC8B870E04 ON shipment (id_customer_id)');
$this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4507BE036FC FOREIGN KEY (shipment_id) REFERENCES shipment (id)');
$this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4507899F32E FOREIGN KEY (bovine_type_id) REFERENCES bovine_type_shipment (id)');
$this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E094B3458B FOREIGN KEY (id_adress_id) REFERENCES address (id)');
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC84554740 FOREIGN KEY (id_carrier_id) REFERENCES carrier (id)');
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC817F550F FOREIGN KEY (id_carrier_1_id) REFERENCES vehicle (id)');
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC964E905B FOREIGN KEY (id_truck_id) REFERENCES vehicle (id)');
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC3B17D73A FOREIGN KEY (licence_plate_1_id) REFERENCES carrier (id)');
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DCF1D99706 FOREIGN KEY (id_vehicle_id) REFERENCES vehicle (id)');
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC8B870E04 FOREIGN KEY (id_customer_id) REFERENCES customer (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4507BE036FC');
$this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4507899F32E');
$this->addSql('ALTER TABLE customer DROP CONSTRAINT FK_81398E094B3458B');
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC84554740');
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC817F550F');
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC964E905B');
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC3B17D73A');
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DCF1D99706');
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC8B870E04');
$this->addSql('DROP TABLE bovin_shipment');
$this->addSql('DROP TABLE bovine_type_shipment');
$this->addSql('DROP TABLE customer');
$this->addSql('DROP TABLE shipment');
}
}

View File

@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'bovin_shipment')]
class BovinShipment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment:read', 'bovine-shipment:read'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'shipment')]
#[Groups(['shipment:read', 'shipment:write', 'bovine-shipment:read', 'bovine-shipment:write'])]
private ?Shipment $Shipment = null;
#[ORM\ManyToOne(inversedBy: 'bovinShipments')]
#[Groups(['shipment:read', 'shipment:write', 'bovine-shipment:read', 'bovine-shipment:write'])]
private ?BovineTypeShipment $BovineType = null;
#[ORM\Column]
#[Groups(['shipment:read', 'shipment:write', 'bovine-shipment:read', 'bovine-shipment:write'])]
private ?int $nbBovinSend = null;
public function getId(): ?int
{
return $this->id;
}
public function getIdShipment(): ?Shipment
{
return $this->Shipment;
}
public function setIdShipment(?Shipment $Shipment): static
{
$this->Shipment = $Shipment;
return $this;
}
public function getIdType(): ?BovineTypeShipment
{
return $this->BovineType;
}
public function setIdType(?BovineTypeShipment $BovineType): static
{
$this->BovineType = $BovineType;
return $this;
}
public function getNbBovinSend(): ?int
{
return $this->nbBovinSend;
}
public function setNbBovinSend(int $nbBovinSend): static
{
$this->nbBovinSend = $nbBovinSend;
return $this;
}
}

View File

@@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class BovineTypeShipment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment:read', 'bovine-type:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'bovine-type:read', 'bovine-type:write'])]
private ?string $type_label = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'bovine-type:read', 'bovine-type:write'])]
private ?string $type_code = null;
/**
* @var Collection<int, BovinShipment>
*/
#[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'id_type')]
#[Groups(['shipment:read', 'shipment:write', 'bovine-type:read', 'bovine-type:write'])]
private Collection $bovinShipments;
public function __construct()
{
$this->bovinShipments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTypeLabel(): ?string
{
return $this->type_label;
}
public function setTypeLabel(string $type_label): static
{
$this->type_label = $type_label;
return $this;
}
public function getTypeCode(): ?string
{
return $this->type_code;
}
public function setTypeCode(string $type_code): static
{
$this->type_code = $type_code;
return $this;
}
public function getBovineShipment(): ?BovineShipment
{
return $this->bovineShipment;
}
public function setBovineShipment(?BovineShipment $bovineShipment): static
{
$this->bovineShipment = $bovineShipment;
return $this;
}
/**
* @return Collection<int, BovinShipment>
*/
public function getBovinShipments(): Collection
{
return $this->bovinShipments;
}
public function addBovinShipment(BovinShipment $bovinShipment): static
{
if (!$this->bovinShipments->contains($bovinShipment)) {
$this->bovinShipments->add($bovinShipment);
$bovinShipment->setIdType($this);
}
return $this;
}
public function removeBovinShipment(BovinShipment $bovinShipment): static
{
if ($this->bovinShipments->removeElement($bovinShipment)) {
// set the owning side to null (unless already changed)
if ($bovinShipment->getIdType() === $this) {
$bovinShipment->setIdType(null);
}
}
return $this;
}
}

113
src/Entity/Customer.php Normal file
View File

@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Customer
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment:read', 'customer:read'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'customer:read', 'customer:write'])]
private ?string $customer_label = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write', 'customer:read', 'customer:write'])]
private ?string $customer_code = null;
#[ORM\ManyToOne(inversedBy: 'customers')]
#[Groups(['shipment:read', 'shipment:write', 'customer:read', 'customer:write'])]
private ?Address $id_adress = null;
/**
* @var Collection<int, Shipment>
*/
#[ORM\OneToMany(targetEntity: Shipment::class, mappedBy: 'id_customer')]
private Collection $shipments;
public function __construct()
{
$this->shipments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCustomerLabel(): ?string
{
return $this->customer_label;
}
public function setCustomerLabel(string $customer_label): static
{
$this->customer_label = $customer_label;
return $this;
}
public function getCustomerCode(): ?string
{
return $this->customer_code;
}
public function setCustomerCode(string $customer_code): static
{
$this->customer_code = $customer_code;
return $this;
}
public function getIdAdress(): ?Address
{
return $this->id_adress;
}
public function setIdAdress(?Address $id_adress): static
{
$this->id_adress = $id_adress;
return $this;
}
/**
* @return Collection<int, Shipment>
*/
public function getShipments(): Collection
{
return $this->shipments;
}
public function addShipment(Shipment $shipment): static
{
if (!$this->shipments->contains($shipment)) {
$this->shipments->add($shipment);
$shipment->setIdCustomer($this);
}
return $this;
}
public function removeShipment(Shipment $shipment): static
{
if ($this->shipments->removeElement($shipment)) {
// set the owning side to null (unless already changed)
if ($shipment->getIdCustomer() === $this) {
$shipment->setIdCustomer(null);
}
}
return $this;
}
}

284
src/Entity/Shipment.php Normal file
View File

@@ -0,0 +1,284 @@
<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use DateTime;
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: 'shipment')]
#[ApiResource(
operations: [
new Get(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['shipment:read']],
),
new GetCollection(
normalizationContext: ['groups' => ['shipment:read']],
),
new Post(
normalizationContext: ['groups' => ['shipment:read']],
denormalizationContext: ['groups' => ['shipment:write']],
),
new Patch(
requirements: ['id' => '\d+'],
normalizationContext: ['groups' => ['shipment:read']],
denormalizationContext: ['groups' => ['shipment:write']],
),
// new Get(
// uriTemplate: '/receptions/weigh',
// openapi: new OpenApiOperation(
// summary: 'Fetch the current weight reading',
// description: 'Queries the pont-bascule and returns the weight data.',
// ),
// normalizationContext: ['groups' => ['reception:weigh:read']],
// output: PontBasculeReading::class,
// provider: ReceptionWeighingProvider::class,
// ),
// new Get(
// uriTemplate: '/receptions/{id}/receipt',
// requirements: ['id' => '\d+'],
// openapi: new OpenApiOperation(
// summary: 'Render a reception receipt',
// description: 'Returns a PDF receipt for the reception.',
// ),
// output: false,
// provider: ReceptionReceiptProvider::class,
// ),
],
)]
class Shipment
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['shipment:read'])]
private ?int $id = null;
#[ORM\Column]
#[Groups(['shipment:read', 'shipment:write'])]
private ?DateTime $date_receipt = null;
#[ORM\Column]
#[Groups(['shipment:read', 'shipment:write'])]
private ?bool $is_waiting = null;
#[ORM\Column(length: 255)]
#[Groups(['shipment:read', 'shipment:write'])]
private ?string $licence_plate = null;
#[ORM\ManyToOne(inversedBy: 'id_carrier_1')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?carrier $id_carrier = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?vehicle $id_carrier_1 = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Vehicle $id_truck = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?carrier $licence_plate_1 = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Vehicle $id_vehicle = null;
#[ORM\ManyToOne(inversedBy: 'shipments')]
#[Groups(['shipment:read', 'shipment:write'])]
private ?Customer $id_customer = null;
/**
* @var Collection<int, BovinShipment>
*/
#[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'id_shipment')]
private Collection $id_type;
#[ORM\Column(length: 255)]
private ?string $test = null;
public function __construct()
{
$this->id_type = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDateReceipt(): ?DateTime
{
return $this->date_receipt;
}
public function setDateReceipt(DateTime $date_receipt): static
{
$this->date_receipt = $date_receipt;
return $this;
}
public function isWaiting(): ?bool
{
return $this->is_waiting;
}
public function setIsWaiting(bool $is_waiting): static
{
$this->is_waiting = $is_waiting;
return $this;
}
public function getLicencePlate(): ?string
{
return $this->licence_plate;
}
public function setLicencePlate(string $licence_plate): static
{
$this->licence_plate = $licence_plate;
return $this;
}
public function getIdCarrier(): ?carrier
{
return $this->id_carrier;
}
public function setIdCarrier(?carrier $id_carrier): static
{
$this->id_carrier = $id_carrier;
return $this;
}
public function getIdCarrier1(): ?vehicle
{
return $this->id_carrier_1;
}
public function setIdCarrier1(?vehicle $id_carrier_1): static
{
$this->id_carrier_1 = $id_carrier_1;
return $this;
}
public function getIdTruck(): ?Vehicle
{
return $this->id_truck;
}
public function setIdTruck(?Vehicle $id_truck): static
{
$this->id_truck = $id_truck;
return $this;
}
public function getLicencePlate1(): ?carrier
{
return $this->licence_plate_1;
}
public function setLicencePlate1(?carrier $licence_plate_1): static
{
$this->licence_plate_1 = $licence_plate_1;
return $this;
}
public function getIdVehicle(): ?Vehicle
{
return $this->id_vehicle;
}
public function setIdVehicle(?Vehicle $id_vehicle): static
{
$this->id_vehicle = $id_vehicle;
return $this;
}
public function getIdCustomer(): ?Customer
{
return $this->id_customer;
}
public function setIdCustomer(?Customer $id_customer): static
{
$this->id_customer = $id_customer;
return $this;
}
public function getBovineShipment(): ?BovineShipment
{
return $this->bovineShipment;
}
public function setBovineShipment(?BovineShipment $bovineShipment): static
{
$this->bovineShipment = $bovineShipment;
return $this;
}
/**
* @return Collection<int, BovinShipment>
*/
public function getIdType(): Collection
{
return $this->id_type;
}
public function addIdType(BovinShipment $idType): static
{
if (!$this->id_type->contains($idType)) {
$this->id_type->add($idType);
$idType->setIdShipment($this);
}
return $this;
}
public function removeIdType(BovinShipment $idType): static
{
if ($this->id_type->removeElement($idType)) {
// set the owning side to null (unless already changed)
if ($idType->getIdShipment() === $this) {
$idType->setIdShipment(null);
}
}
return $this;
}
public function getTest(): ?string
{
return $this->test;
}
public function setTest(string $test): static
{
$this->test = $test;
return $this;
}
}