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:
@@ -311,6 +311,19 @@ class AdvertController extends AbstractController
|
|||||||
$amountFormatted = number_format((float) $amount, 2, '.', '');
|
$amountFormatted = number_format((float) $amount, 2, '.', '');
|
||||||
$payment = new \App\Entity\AdvertPayment($advert, \App\Entity\AdvertPayment::TYPE_SUCCESS, $amountFormatted);
|
$payment = new \App\Entity\AdvertPayment($advert, \App\Entity\AdvertPayment::TYPE_SUCCESS, $amountFormatted);
|
||||||
$payment->setMethod($method);
|
$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);
|
$this->em->persist($payment);
|
||||||
|
|
||||||
// Tracker l'evenement
|
// Tracker l'evenement
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ class AdvertPayment
|
|||||||
#[ORM\Column(length: 30, nullable: true)]
|
#[ORM\Column(length: 30, nullable: true)]
|
||||||
private ?string $method = null;
|
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]
|
#[ORM\Column]
|
||||||
private \DateTimeImmutable $createdAt;
|
private \DateTimeImmutable $createdAt;
|
||||||
|
|
||||||
@@ -73,6 +77,18 @@ class AdvertPayment
|
|||||||
return $this;
|
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
|
public function getCreatedAt(): \DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
|
|||||||
@@ -712,14 +712,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<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>
|
<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="virement">Virement bancaire</option>
|
||||||
<option value="cheque">Cheque</option>
|
<option value="cheque">Cheque</option>
|
||||||
<option value="especes">Especes</option>
|
<option value="especes">Especes</option>
|
||||||
<option value="cb_externe">CB (terminal externe)</option>
|
<option value="cb_externe">CB (terminal externe)</option>
|
||||||
|
<option value="echeancier">Echeancier</option>
|
||||||
<option value="autre">Autre</option>
|
<option value="autre">Autre</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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 }} €)</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<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>
|
<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">
|
<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">
|
||||||
|
|||||||
Reference in New Issue
Block a user