Commit 7a518f57 by Yvon

ccas : create ccas dedicated check for transaction cancellation

parent 0e358c9e
...@@ -287,20 +287,39 @@ class UserController extends AbstractController ...@@ -287,20 +287,39 @@ 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) //Ccas transactions.
if ( if ($transactionAdherentPrestataire->getIsCcas()) {
$this->em->getRepository(Flux::class)->getQueryByPrestataire( //Allowed if and only if transaction is from current month
$presta, $now = new \DateTime();
null, if (
Reconversion::TYPE_RECONVERSION_PRESTATAIRE, $transactionAdherentPrestataire->getCreatedAt()->format('m') !== $now->format('m')
$transactionAdherentPrestataire->getCreatedAt()->format("Y-m-d H:i:s") || $transactionAdherentPrestataire->getCreatedAt()->format('Y') !== $now->format('Y')
)->getResult() ) {
) { //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( $this->addFlash(
'error', 'error',
'Cette transaction ne plus être annulée car une reconversion a été demandée depuis.' 'Cette transaction ne plus être annulée car une reconversion a été demandée depuis.'
); );
return $this->redirectToRoute('index'); 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 //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