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

Merge branch '5892-5897-enfants-a-charge-dans-section-foyer' into 'ssa-gironde'

create dependent child form and put it into newly created foyer section in adherent admin

See merge request cooperatic/kohinos-tav!68
parents 78b7b956 97f09943
......@@ -49,6 +49,7 @@ TAV_ENV=0
PRESTA_SELF_INIT_AND_EVAL=0
AUTOMATISATION_RECONVERSION=0
PRESTA_EXTRA_DATA=0
HOUSEHOLD_BASED_ALLOWANCE=0
EMAIL_ERROR=technique@kohinos.net
EMAIL_USER_FROM=noreply@kohinos.fr
......
......@@ -56,6 +56,7 @@ Copier le fichier .env.dist en .env et configurer :
- en environnement TAV, pour activer le parcours d'inscription autonomisé qui intègre la réponse à une questionnaire d'auto-évaluation pour les points de vente, passer PRESTA_SELF_INIT_AND_EVAL à 1
- en environnement TAV, la variable AUTOMATISATION_RECONVERSION permet d'activer l'automatisation des reconversions
- 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
Si vous utilisez Payzen comme moyen de paiement par CB :
......
......@@ -13,4 +13,5 @@ twig:
globals:
tav_env: '%env(TAV_ENV)%'
presta_self_init_and_eval: '%env(PRESTA_SELF_INIT_AND_EVAL)%'
presta_extra_data: '%env(PRESTA_EXTRA_DATA)%'
\ No newline at end of file
presta_extra_data: '%env(PRESTA_EXTRA_DATA)%'
household_based_allowance: '%env(HOUSEHOLD_BASED_ALLOWANCE)%'
\ No newline at end of file
......@@ -16,6 +16,8 @@ parameters:
presta_self_init_and_eval: '%env(PRESTA_SELF_INIT_AND_EVAL)%'
automatisation_reconversion: '%env(AUTOMATISATION_RECONVERSION)%'
presta_extra_data: '%env(PRESTA_EXTRA_DATA)%'
household_based_allowance: '%env(HOUSEHOLD_BASED_ALLOWANCE)%'
# PARAMETRES DES IMPORTS POSSIBLE POUR L'APPLICATION DE GESTION DE MONNAIE LOCALE COMPLEMENTAIRE
app.import.separator: ';'
......
......@@ -5,6 +5,7 @@ namespace App\Admin;
use App\Entity\AccountAdherent;
use App\Entity\Adherent;
use App\Entity\CotisationAdherent;
use App\Entity\DependentChild;
use App\Entity\Geoloc;
use App\Entity\GlobalParameter;
use App\Entity\Groupe;
......@@ -14,6 +15,7 @@ use App\Entity\ProfilDeCotisation;
use App\Enum\CurrencyEnum;
use App\Events\MLCEvents;
use App\Exporter\CustomDoctrineORMQuerySourceIterator;
use App\Form\Type\DependentChildFormType;
use App\Form\Type\GeolocFormType;
use App\Form\Type\UserFormType;
use Doctrine\ORM\Query;
......@@ -35,6 +37,7 @@ use Sonata\UserBundle\Model\UserManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
......@@ -172,6 +175,25 @@ class AdherentAdmin extends AbstractAdmin
;
if ($this->getConfigurationPool()->getContainer()->getParameter('tav_env')) {
if ($this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance')) {
$formMapper
->tab('General')
->with('Foyer', ['class' => 'col-md-7'])
->add('dependentChildren', CollectionType::class, [
'entry_type' => DependentChildFormType::class,
'entry_options' => [
'label' => true,
'data_class' => DependentChild::class,
'attr' => ['class' => 'border pl-3 pr-3 pt-2']
],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' => "Enfant(s) à charge"
])
->end()
->end();
}
// For Comptoir role in edit mode, hide profile choice
$displayProfilChoice = true;
$isComptoirOnly =
......
......@@ -370,11 +370,12 @@ class PrestataireAdmin extends AbstractAdmin
])
->add('conventionnement', ChoiceType::class, [
'choices' => [
'50 %' => 0.5,
'75 %' => 0.75,
'100 %' => 1,
'50 %' => '0.50', //using strings (and not floats) seems required
'75 %' => '0.75', //to make display work fine
'100 %' => '1.00',
],
'required' => false,
'attr' => ['autocomplete' => 'off'] //avoid non-saved value to be displayed
])
->end()
->end();
......
......@@ -10,6 +10,7 @@ use App\Entity\EntityTrait\HasEcompteEntity;
use App\Flux\AccountableInterface;
use App\Flux\AccountableObject;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator;
......@@ -113,9 +114,16 @@ class Adherent extends AccountableObject implements AccountableInterface
*/
private $jourMailRappelCotisation;
/**
* @ORM\OneToMany(targetEntity=DependentChild::class, mappedBy="adherent", orphanRemoval=true, cascade={"persist"})
*/
private $dependentChildren;
public function __construct()
{
$this->accounts = new ArrayCollection();
$this->dependentChildren = new ArrayCollection();
}
public function getId()
......@@ -335,4 +343,34 @@ class Adherent extends AccountableObject implements AccountableInterface
return $this;
}
/**
* @return Collection<int, DependentChild>
*/
public function getDependentChildren(): Collection
{
return $this->dependentChildren;
}
public function addDependentChild(DependentChild $dependentChild): self
{
if (!$this->dependentChildren->contains($dependentChild)) {
$this->dependentChildren[] = $dependentChild;
$dependentChild->setAdherent($this);
}
return $this;
}
public function removeDependentChild(DependentChild $dependentChild): self
{
if ($this->dependentChildren->removeElement($dependentChild)) {
// set the owning side to null (unless already changed)
if ($dependentChild->getAdherent() === $this) {
$dependentChild->setAdherent(null);
}
}
return $this;
}
}
<?php
namespace App\Entity;
use App\Repository\PrestataireProductFamilyRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=DependentChildRepository::class)
* @ORM\Table(name="dependent_child")
*/
class DependentChild
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Adherent::class, inversedBy="adherentDependentChildren")
* @ORM\JoinColumn(nullable=false)
*/
private $adherent;
/**
* @ORM\Column(type="boolean")
*/
private $olderThanFourteen;
/**
* @var float
*
* @ORM\Column(name="sharedcustodypercentage", type="decimal", scale=2, nullable=true)
* @Assert\Type("numeric")
*/
protected $sharedCustodyPercentage;
public function getId(): ?int
{
return $this->id;
}
public function getAdherent(): ?Adherent
{
return $this->adherent;
}
public function setAdherent(?Adherent $adherent): self
{
$this->adherent = $adherent;
return $this;
}
public function getOlderThanFourteen()
{
return $this->olderThanFourteen;
}
public function setOlderThanFourteen($olderThanFourteen)
{
$this->olderThanFourteen = $olderThanFourteen;
return $this;
}
public function getSharedCustodyPercentage()
{
return $this->sharedCustodyPercentage;
}
public function setSharedCustodyPercentage($sharedCustodyPercentage)
{
$this->sharedCustodyPercentage = $sharedCustodyPercentage;
return $this;
}
}
<?php
namespace App\Form\Type;
use App\Entity\DependentChild;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class DependentChildFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('olderThanFourteen', ChoiceType::class, array(
'choices' => [
'oui' => true,
'non' => false
],
'label' => "A-t-il plus de 14 ans ?",
'required' => true,
'expanded' => true
))
->add('sharedCustodyPercentage', ChoiceType::class, [
'label' => "Est-il en garde partagée ?",
'required' => true,
'choices' => [
'non' => null,
'oui : je le garde 25 % du temps' => '0.25',//using strings as values (and not floats) seems required
'oui : je le garde 50 % du temps' => '0.50',//to make display work fine
'oui : je le garde 75 % du temps' => '0.75',
],
'required' => false,
'attr' => ['autocomplete' => 'off'] //avoid non-saved value to be displayed
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => DependentChild::class,
]);
}
public function getBlockPrefix()
{
return 'formDependentChild';
}
}
<?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 Version20240306164256 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('CREATE TABLE dependent_child (id INT AUTO_INCREMENT NOT NULL, adherent_id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', older_than_fourteen TINYINT(1) NOT NULL, conventionnement NUMERIC(10, 2) DEFAULT NULL, INDEX IDX_15BF27C725F06C53 (adherent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE dependent_child ADD CONSTRAINT FK_15BF27C725F06C53 FOREIGN KEY (adherent_id) REFERENCES adherent (id)');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE dependent_child');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\'');
}
}
<?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 Version20240307162630 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 dependent_child CHANGE conventionnement sharedcustodypercentage NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE dependent_child CHANGE sharedcustodypercentage conventionnement NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\'');
}
}
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