Commit fbf78c7b by Kohinos Cooperatic

payment hotfix for tests in preprod env

parent 9a51843b
......@@ -128,17 +128,11 @@ class UserAdherentController extends FluxController
* Returns error message or null if no error.
*/
private function paiementCotisTavValidation($flux) {
//Look for existing recurring payment
if($reason = $this->tavCotisationsUtils->checkExistingRecurringPayment($flux->getDestinataire()->getUser()->getEmail())) {
return implode(" ", array_column($reason,'reason'));
}
// Look for existing cotisation
if ($this->tavCotisationsUtils->checkExistingCotisation($flux)) {
return "Cotisation déjà payée ce mois-ci.";
}
$destinataire = $flux->getDestinataire();
if($reason = $this->tavCotisationsUtils->preventCotisationDuplication($destinataire)) {
return $reason;
}
// Look for cotisation data depending on active process
if (true == $this->getParameter('household_based_allowance')) {
......
......@@ -205,10 +205,10 @@ class UserComptoirController extends FluxController
$flux = $form->getData();
// Look for existing cotisation
if ($this->tavCotisationsUtils->checkExistingCotisation($flux)) {
if ($reason = $this->tavCotisationsUtils->preventCotisationDuplication($flux->getDestinataire())) {
$this->addFlash(
'error',
$this->translator->trans('L\'adhérent•e a déjà payé sa cotisation ce mois-ci.')
$this->translator->trans($reason)
);
return $this->redirectToRoute('index');
......
......@@ -33,15 +33,32 @@ class TAVCotisationUtils
}
/**
* Check if cotisation already exist this month the the recipient of the given Flux.
* Check if there is an active recurring paiement or if cotisation already exist this month
* by returning a descriptive reason string if so, else an empty string.
*/
public function checkExistingCotisation(Flux $flux)
public function preventCotisationDuplication(Adherent $adherent)
{
//Look for existing recurring payment
if($reason = $this->checkExistingRecurringPayment($adherent->getUser()->getEmail())) {
return implode(" ", array_column($reason,'reason'));
}
//Look for existing cotisation
if ($this->checkExistingCotisation($adherent)) {
return "Cotisation déjà payée ce mois-ci.";
}
return "";
}
/**
* Check if cotisation already exist this month.
*/
private function checkExistingCotisation(Adherent $adherent)
{
$first_day_this_month = date('Y-m-01');
$last_day_this_month = date('Y-m-t');
$existing = $this->em->getRepository(Flux::class)->getTavCotisationsBetweenDates(
$flux->getDestinataire(),
$adherent,
$first_day_this_month,
$last_day_this_month
);
......@@ -50,7 +67,8 @@ class TAVCotisationUtils
}
/**
* Returns a descriptive string of existing payment, or empty string.
* Returns an array containing a descriptive string of existing payment
* as well as other information about the payment, or an empty array.
*
* @param String $userEmail
*/
......
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