From 978fcb9156cbee46fcd31882435fb08050b2b9c8 Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Wed, 8 Apr 2026 19:45:44 +0200 Subject: [PATCH] feat: methode paiement echeancier liee aux echeanciers du client - Ajout methode "Echeancier" dans le select du modal paiement manuel - Select dynamique des echeanciers du client (visible si methode=echeancier) - AdvertPayment : relation ManyToOne vers Echeancier (nullable) - Controller : lie l'echeancier au paiement, label avec description Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Controller/Admin/AdvertController.php | 13 +++++++++++++ src/Entity/AdvertPayment.php | 16 ++++++++++++++++ templates/admin/clients/show.html.twig | 12 +++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/Controller/Admin/AdvertController.php b/src/Controller/Admin/AdvertController.php index 80c5677..ed901ce 100644 --- a/src/Controller/Admin/AdvertController.php +++ b/src/Controller/Admin/AdvertController.php @@ -311,6 +311,19 @@ class AdvertController extends AbstractController $amountFormatted = number_format((float) $amount, 2, '.', ''); $payment = new \App\Entity\AdvertPayment($advert, \App\Entity\AdvertPayment::TYPE_SUCCESS, $amountFormatted); $payment->setMethod($method); + + // Lier a un echeancier si methode = echeancier + if ('echeancier' === $method) { + $echeancierId = $request->request->getInt('echeancierId'); + if ($echeancierId > 0) { + $echeancier = $this->em->getRepository(\App\Entity\Echeancier::class)->find($echeancierId); + if (null !== $echeancier) { + $payment->setEcheancier($echeancier); + $methodLabel = 'Echeancier #'.$echeancier->getId().' - '.$echeancier->getDescription(); + } + } + } + $this->em->persist($payment); // Tracker l'evenement diff --git a/src/Entity/AdvertPayment.php b/src/Entity/AdvertPayment.php index f6a37ae..6998efe 100644 --- a/src/Entity/AdvertPayment.php +++ b/src/Entity/AdvertPayment.php @@ -30,6 +30,10 @@ class AdvertPayment #[ORM\Column(length: 30, nullable: true)] private ?string $method = null; + #[ORM\ManyToOne(targetEntity: \App\Entity\Echeancier::class)] + #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] + private ?\App\Entity\Echeancier $echeancier = null; + #[ORM\Column] private \DateTimeImmutable $createdAt; @@ -73,6 +77,18 @@ class AdvertPayment return $this; } + public function getEcheancier(): ?\App\Entity\Echeancier + { + return $this->echeancier; + } + + public function setEcheancier(?\App\Entity\Echeancier $echeancier): static + { + $this->echeancier = $echeancier; + + return $this; + } + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; diff --git a/templates/admin/clients/show.html.twig b/templates/admin/clients/show.html.twig index b21475f..c94a562 100644 --- a/templates/admin/clients/show.html.twig +++ b/templates/admin/clients/show.html.twig @@ -712,14 +712,24 @@
- +
+