Project 'cooperatic/kohinos-tav' was moved to 'agplv3/kohinos-tav'. Please update any links and bookmarks that may still have the old path.
Commit b29dc3cb by Damien Moulard

Merge branch '6171-adherent-eligible-to-ccas' into 'ssa-gironde'

ccas: add ccas related fields to adherent entity, generate anonymous code at saving

See merge request cooperatic/kohinos-tav!90
parents b3184aff 4e10c676
......@@ -51,6 +51,7 @@ AUTOMATISATION_RECONVERSION=0
PRESTA_EXTRA_DATA=0
HOUSEHOLD_BASED_ALLOWANCE=0
SSA_FRIENDLY_FLUX_TYPE_NAMES=0
CCAS_MODE=0
FIX_BALANCE_ADHERENT_PASSWORD=ChangeMe
EMAIL_ERROR=technique@kohinos.net
......
......@@ -59,6 +59,7 @@ Copier le fichier .env.dist en .env et configurer :
- en environnement TAV, la variable PRESTA_EXTRA_DATA permet d'indiquer puis d'afficher publiquement plus de données concernant les prestataires (e.g. familles de produits)
- en environnement TAV, la variable HOUSEHOLD_BASED_ALLOWANCE permet d'activer un mode de cotisations libres et d'allocations basées sur la composition du foyer
- en environnement TAV, la variable SSA_FRIENDLY_FLUX_TYPE_NAMES permet d'adapter le nommage des types de flux à un projet de type ssa
- en environnement TAV, la varialble CCAS_MODE permet d'activer les fonctionnalités de branchement avec une CCAS. Attention : Pour activer CCAS_MODE, le paramètre AUTOMATISATION_RECONVERSION doit OBLIGATOIREMENT être activé.
Si vous utilisez Payzen comme moyen de paiement par CB :
......
......@@ -19,6 +19,7 @@ parameters:
household_based_allowance: '%env(HOUSEHOLD_BASED_ALLOWANCE)%'
ssa_friendly_flux_type_names: '%env(SSA_FRIENDLY_FLUX_TYPE_NAMES)%'
fix_balance_adherent_password: '%env(FIX_BALANCE_ADHERENT_PASSWORD)%'
ccas_mode: '%env(CCAS_MODE)%'
# PARAMETRES DES IMPORTS POSSIBLE POUR L'APPLICATION DE GESTION DE MONNAIE LOCALE COMPLEMENTAIRE
......
......@@ -49,6 +49,7 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Ramsey\Uuid\Uuid;
/**
* Administration des adhérents.
......@@ -192,12 +193,29 @@ class AdherentAdmin extends AbstractAdmin
->end()
;
/**
* In TAV env, 2 allowance processes possible:
* - household based (if param set)
* - cotisation profile and rate based (default)
*/
if ($tav_env) {
if ($this->getConfigurationPool()->getContainer()->getParameter('ccas_mode')) {
$formMapper
->tab('General')
->with('Identité')
->add('ccasAccepted', null, [
'label' => 'A pris connaissance et accepté la procédure des aides facultatives CCAS',
'attr' => ['autocomplete' => 'off']
])
->add('ccasEligible', null, [
'label' => 'Éligible aux aides facultatives CCAS',
'attr' => ['autocomplete' => 'off']
])
->end()
->end()
;
}
/**
* In TAV env, 2 allowance processes possible:
* - household based (if param set)
* - cotisation profile and rate based (default)
*/
if ($household_based_allowance) {
$formMapper
->tab('General')
......@@ -445,6 +463,32 @@ class AdherentAdmin extends AbstractAdmin
}
}
}
if ($this->getConfigurationPool()->getContainer()->getParameter('ccas_mode')) {
// generate anonymous token if doesn't exist, if ccasAccepted and ccasEligible
if (
is_null($adherent->getAnonymousToken())
&& $adherent->getCcasEligible()
&& $adherent->getCcasAccepted()
) {
$uuid = Uuid::uuid4()->toString();
// Get 8 first digits of uuid so unique code is readable for manual treatment
$uniqueCode = substr($uuid, 0, 8);
// 8 first digits of uuid isn't assured to be unique, so perform a unicity check before saving
$codeExists = $em->getRepository(Adherent::class)->findOneBy(['anonymousToken' => $uniqueCode]);
while (!is_null($codeExists)) {
$uuid = Uuid::uuid4()->toString();
$uniqueCode = substr($uuid, 0, 8);
$codeExists = $em->getRepository(Adherent::class)->findOneBy(['anonymousToken' => $uniqueCode]);
}
$adherent->setAnonymousToken($uniqueCode);
$em->persist($adherent);
$em->flush();
}
}
});
parent::configureFormFields($formMapper);
}
......
......@@ -144,6 +144,21 @@ class Adherent extends AccountableObject implements AccountableInterface
*/
private $allocationAmount;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $ccasAccepted;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private $ccasEligible;
/**
* @ORM\Column(type="string", length=36, nullable=true, unique=true)
*/
private $anonymousToken;
public function __construct()
{
......@@ -452,4 +467,40 @@ class Adherent extends AccountableObject implements AccountableInterface
//This formula has been configured for ssa gironde project
return 2 * $this->allocationAmount;
}
public function getCcasAccepted(): ?bool
{
return $this->ccasAccepted;
}
public function setCcasAccepted(bool $ccasAccepted): self
{
$this->ccasAccepted = $ccasAccepted;
return $this;
}
public function getCcasEligible(): ?bool
{
return $this->ccasEligible;
}
public function setCcasEligible(bool $ccasEligible): self
{
$this->ccasEligible = $ccasEligible;
return $this;
}
public function getAnonymousToken(): ?string
{
return $this->anonymousToken;
}
public function setAnonymousToken(?string $anonymousToken): self
{
$this->anonymousToken = $anonymousToken;
return $this;
}
}
......@@ -43,9 +43,6 @@ class UserFormType extends AbstractType
'label' => 'Téléphone mobile :',
'required' => false,
])
->add('enabled', null, [
'label' => 'Activé ?',
])
->add('comment', null, [
'label' => 'Commentaire',
'required' => false,
......@@ -53,6 +50,10 @@ class UserFormType extends AbstractType
'placeholder' => 'Indiquez par exemple pourquoi ce compte a été désactivé'
)
])
->add('enabled', null, [
'label' => 'Activé ?',
'attr' => ['autocomplete' => 'off']
])
;
}
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240503085754 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE adherent ADD ccas_accepted TINYINT(1) DEFAULT \'0\' NOT NULL, ADD ccas_eligible TINYINT(1) DEFAULT \'0\' NOT NULL, ADD anonymous_token VARCHAR(36) DEFAULT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_90D3F060FCE1E3BD ON adherent (anonymous_token)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_90D3F060FCE1E3BD ON adherent');
$this->addSql('ALTER TABLE adherent DROP ccas_accepted, DROP ccas_eligible, DROP anonymous_token');
}
}
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