fix : correction des retours de la V0
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled

This commit is contained in:
2026-03-18 14:47:03 +01:00
parent 995e7de2cc
commit a905c6a1de
64 changed files with 1979 additions and 1640 deletions

View File

@@ -46,9 +46,9 @@ class Address
#[Groups(['address:read', 'supplier:read', 'customer:read', 'shipment:read'])]
private ?int $id = null;
#[ORM\Column(length: 120)]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read', 'address:write'])]
private string $label = '';
#[ORM\Column(length: 120, nullable: true)]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
private ?string $label = null;
#[ORM\Column(length: 180)]
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read', 'address:write'])]
@@ -93,12 +93,12 @@ class Address
return $this->id;
}
public function getLabel(): string
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
public function setLabel(?string $label): self
{
$this->label = $label;

View File

@@ -67,7 +67,7 @@ class Carrier
public function setName(string $name): self
{
$this->name = $name;
$this->name = mb_strtoupper($name);
return $this;
}

View File

@@ -59,6 +59,11 @@ class Customer
#[Groups(['customer:read', 'customer:write', 'shipment:read'])]
private ?string $phone = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
#[Groups(['customer:read', 'customer:write'])]
private ?User $createdBy = null;
/**
* @var Collection<int, Address>
*/
@@ -85,7 +90,7 @@ class Customer
public function setName(string $name): self
{
$this->name = $name;
$this->name = mb_strtoupper($name);
return $this;
}
@@ -114,6 +119,18 @@ class Customer
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getAddresses(): Collection
{
return $this->addresses;

View File

@@ -8,6 +8,7 @@ use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
@@ -47,6 +48,9 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
normalizationContext: ['groups' => ['reception:read']],
denormalizationContext: ['groups' => ['reception:write']],
),
new Delete(
requirements: ['id' => '\d+'],
),
new Get(
uriTemplate: '/receptions/weigh',
openapi: new OpenApiOperation(
@@ -96,7 +100,10 @@ class Reception
#[ORM\Column(name: 'date_reception', type: 'datetime_immutable')]
#[Groups(['reception:read', 'reception:write', 'reception-bovine:read'])]
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
#[Context(
normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i'],
denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'],
)]
private ?DateTimeImmutable $receptionDate = null;
#[ORM\Column(length: 255, nullable: true)]
@@ -259,6 +266,14 @@ class Reception
public function setReceptionDate(?DateTimeImmutable $receptionDate): self
{
if (null !== $receptionDate && null !== $this->receptionDate) {
// Préserve l'heure existante quand seule la date est mise à jour
$receptionDate = $receptionDate->setTime(
(int) $this->receptionDate->format('H'),
(int) $this->receptionDate->format('i'),
(int) $this->receptionDate->format('s'),
);
}
$this->receptionDate = $receptionDate;
return $this;
@@ -457,8 +472,16 @@ class Reception
#[ORM\PrePersist]
public function initializeReceptionDate(): void
{
$now = new DateTimeImmutable();
if (null === $this->receptionDate) {
$this->receptionDate = new DateTimeImmutable();
$this->receptionDate = $now;
} else {
// Préserve la date choisie mais utilise l'heure courante
$this->receptionDate = $this->receptionDate->setTime(
(int) $now->format('H'),
(int) $now->format('i'),
(int) $now->format('s'),
);
}
}

View File

@@ -8,6 +8,7 @@ use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
@@ -47,6 +48,9 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
normalizationContext: ['groups' => ['shipment:read']],
denormalizationContext: ['groups' => ['shipment:write']],
),
new Delete(
requirements: ['id' => '\d+'],
),
new Get(
uriTemplate: '/shipments/weigh',
openapi: new OpenApiOperation(
@@ -102,7 +106,10 @@ class Shipment
#[ORM\Column(name: 'shipment_date', type: 'datetime_immutable')]
#[Groups(['shipment:read', 'shipment:write'])]
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
#[Context(
normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d H:i'],
denormalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'],
)]
private ?DateTimeImmutable $shipmentDate = null;
#[ORM\ManyToOne]
@@ -245,6 +252,13 @@ class Shipment
public function setShipmentDate(?DateTimeImmutable $shipmentDate): void
{
if (null !== $shipmentDate && null !== $this->shipmentDate) {
$shipmentDate = $shipmentDate->setTime(
(int) $this->shipmentDate->format('H'),
(int) $this->shipmentDate->format('i'),
(int) $this->shipmentDate->format('s'),
);
}
$this->shipmentDate = $shipmentDate;
}
@@ -303,6 +317,21 @@ class Shipment
}
}
#[ORM\PrePersist]
public function initializeShipmentDate(): void
{
$now = new DateTimeImmutable();
if (null === $this->shipmentDate) {
$this->shipmentDate = $now;
} else {
$this->shipmentDate = $this->shipmentDate->setTime(
(int) $now->format('H'),
(int) $now->format('i'),
(int) $now->format('s'),
);
}
}
#[ORM\PostPersist]
public function initializeIdentificationNumber(PostPersistEventArgs $args): void
{

View File

@@ -61,6 +61,11 @@ class Supplier
#[Groups(['supplier:read', 'reception:read', 'supplier:write'])]
private ?string $phone = null;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
#[Groups(['supplier:read', 'supplier:write'])]
private ?User $createdBy = null;
/**
* @var Collection<int, Address>
*/
@@ -87,7 +92,7 @@ class Supplier
public function setName(string $name): self
{
$this->name = $name;
$this->name = mb_strtoupper($name);
return $this;
}
@@ -116,6 +121,18 @@ class Supplier
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
/**
* @return Collection<int, Address>
*/

View File

@@ -61,11 +61,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['user:read', 'user-login:read', 'reception:read', 'shipment:read'])]
#[Groups(['user:read', 'user-login:read', 'reception:read', 'shipment:read', 'supplier:read', 'customer:read'])]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
#[Groups(['user:read', 'user:write', 'user-login:read', 'reception:read', 'shipment:read'])]
#[Groups(['user:read', 'user:write', 'user-login:read', 'reception:read', 'shipment:read', 'supplier:read', 'customer:read'])]
private string $username = '';
#[ORM\Column(type: 'json')]