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) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-08 19:45:44 +02:00
parent 8d91795250
commit 978fcb9156
3 changed files with 40 additions and 1 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -712,14 +712,24 @@
</div>
<div>
<label for="mp-method-{{ a.id }}" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Methode de paiement</label>
<select id="mp-method-{{ a.id }}" name="method" required class="input-glass w-full px-3 py-2 text-xs font-bold">
<select id="mp-method-{{ a.id }}" name="method" required class="input-glass w-full px-3 py-2 text-xs font-bold" onchange="document.getElementById('mp-echeancier-wrap-{{ a.id }}').classList.toggle('hidden', this.value !== 'echeancier')">
<option value="virement">Virement bancaire</option>
<option value="cheque">Cheque</option>
<option value="especes">Especes</option>
<option value="cb_externe">CB (terminal externe)</option>
<option value="echeancier">Echeancier</option>
<option value="autre">Autre</option>
</select>
</div>
<div id="mp-echeancier-wrap-{{ a.id }}" class="hidden">
<label for="mp-echeancier-{{ a.id }}" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Echeancier lie</label>
<select id="mp-echeancier-{{ a.id }}" name="echeancierId" class="input-glass w-full px-3 py-2 text-xs font-bold">
<option value="">— Selectionner —</option>
{% for ech in echeancierList %}
<option value="{{ ech.id }}">{{ ech.description|length > 40 ? ech.description[:40] ~ '...' : ech.description }} ({{ ech.nbPaid }}/{{ ech.nbLines }} - {{ ech.totalAmountHt }} &euro;)</option>
{% endfor %}
</select>
</div>
<div>
<label for="mp-reference-{{ a.id }}" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Reference (optionnel)</label>
<input type="text" id="mp-reference-{{ a.id }}" name="reference" placeholder="N de virement, n de cheque..." class="input-glass w-full px-3 py-2 text-xs font-bold">