Commit 7a518f57 by Yvon

ccas : create ccas dedicated check for transaction cancellation

parent 0e358c9e
......@@ -287,20 +287,39 @@ class UserController extends AbstractController
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');
//Ccas transactions.
if ($transactionAdherentPrestataire->getIsCcas()) {
//Allowed if and only if transaction is from current month
$now = new \DateTime();
if (
$transactionAdherentPrestataire->getCreatedAt()->format('m') !== $now->format('m')
|| $transactionAdherentPrestataire->getCreatedAt()->format('Y') !== $now->format('Y')
) {
//display the same error message for CCAS or non CCAS as prestataire are not supposed to know if a transaction is CCAS or not
$this->addFlash(
'error',
'Cette transaction ne plus être annulée car une reconversion a été demandée depuis.'
);
return $this->redirectToRoute('index');
}
}
//Non ccas transactions,
else {
//we 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
......
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