Commit 9c6a71e3 by Yvon Kerdoncuff

Merge branch…

Merge branch '6234-bloquer-les-annulations-de-transactions-d-avant-la-derniere-reconversion' into 'develop'

prevent cancelling transactions which happened before last reconversion

See merge request cooperatic/kohinos-tav!87
parents b3184aff 62776c66
...@@ -8,6 +8,7 @@ use App\Entity\CotisationPrestataire; ...@@ -8,6 +8,7 @@ use App\Entity\CotisationPrestataire;
use App\Entity\GlobalParameter; use App\Entity\GlobalParameter;
use App\Entity\Payment; use App\Entity\Payment;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\Reconversion;
use App\Entity\TransactionPrestataireAdherent; use App\Entity\TransactionPrestataireAdherent;
use App\Entity\User; use App\Entity\User;
use App\Entity\TransactionAdherentPrestataire; use App\Entity\TransactionAdherentPrestataire;
...@@ -31,6 +32,7 @@ use Symfony\Component\Routing\Annotation\Route; ...@@ -31,6 +32,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Twig\Environment; use Twig\Environment;
use App\Entity\Flux;
class UserController extends AbstractController class UserController extends AbstractController
{ {
...@@ -285,6 +287,22 @@ class UserController extends AbstractController ...@@ -285,6 +287,22 @@ class UserController extends AbstractController
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
//Prevent cancelling transactions which happened before a reconversion (to avoid refunding money that's been reconverted)
if (
$this->em->getRepository(Flux::class)->getQueryByPrestataire(
$presta,
null,
Reconversion::TYPE_RECONVERSION_PRESTATAIRE,
$transactionAdherentPrestataire->getCreatedAt()->format("Y-m-d H:i:s")
)->getResult()
) {
$this->addFlash(
'error',
'Cette transaction ne plus être annulée car une reconversion a été demandée depuis.'
);
return $this->redirectToRoute('index');
}
//Create new transaction in opposite direction //Create new transaction in opposite direction
$flux = new TransactionPrestataireAdherent(); $flux = new TransactionPrestataireAdherent();
$flux->setExpediteur($presta); $flux->setExpediteur($presta);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment