Commit 34d7bb75 by Yvon Kerdoncuff

Merge branch 'develop' into ssamontpellier_prod

parents 576eb4ad df1ae30a
...@@ -71,8 +71,9 @@ $(document).ready(function() { ...@@ -71,8 +71,9 @@ $(document).ready(function() {
}); });
}); });
// Hide or display Cotisation, Profils de Cotisation and Products Families submenu depending on TAV env // Hide or display Cotisation, Profils de Cotisation and Products Families submenu depending on TAV env and/or household mode
const tav_env = document.getElementsByName('is-tav-env')[0].getAttribute('content'); const tav_env = document.getElementsByName('is-tav-env')[0].getAttribute('content');
const household_based_allowance = document.getElementsByName('is-household-based-allowance')[0].getAttribute('content');
let linksToCotisationAdherent = $('a[href="/admin/cotisation_adherent/list"]'); let linksToCotisationAdherent = $('a[href="/admin/cotisation_adherent/list"]');
for(let i = 0 ; i < linksToCotisationAdherent.length ; i++) { for(let i = 0 ; i < linksToCotisationAdherent.length ; i++) {
...@@ -89,7 +90,7 @@ $(document).ready(function() { ...@@ -89,7 +90,7 @@ $(document).ready(function() {
let linksToProfilDeCotisation = $('a[href="/admin/profilcotisation/list"]'); let linksToProfilDeCotisation = $('a[href="/admin/profilcotisation/list"]');
for(let i = 0 ; i < linksToProfilDeCotisation.length ; i++) { for(let i = 0 ; i < linksToProfilDeCotisation.length ; i++) {
if(linksToProfilDeCotisation[i].innerText === "Profils De Cotisation") { if(linksToProfilDeCotisation[i].innerText === "Profils De Cotisation") {
linksToProfilDeCotisation[i].parentNode.style.display = (tav_env === "1") ? "" : "none"; linksToProfilDeCotisation[i].parentNode.style.display = (tav_env === "1" && household_based_allowance === "0") ? "" : "none";
} }
} }
let linksToProductsFamily = $('a[href="/admin/app/productfamily/list"]'); let linksToProductsFamily = $('a[href="/admin/app/productfamily/list"]');
......
...@@ -137,6 +137,12 @@ services: ...@@ -137,6 +137,12 @@ services:
class: App\Utils\PaymentUtils class: App\Utils\PaymentUtils
autowire: true autowire: true
app.utils.moyens:
class: App\Utils\MoyensUtils
autowire: true
public: true
arguments: ['@app.utils.custom_entity_manager']
app.twig.main.extension: app.twig.main.extension:
class: App\Twig\AppExtension class: App\Twig\AppExtension
autowire: false autowire: false
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"admin": { "admin": {
"js": [ "js": [
"/build/runtime.6ad5c9da.js", "/build/runtime.6ad5c9da.js",
"/build/admin.a08fea06.js" "/build/admin.3f7739a8.js"
], ],
"css": [ "css": [
"/build/admin.4de55830.css" "/build/admin.4de55830.css"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"build/app.css": "/build/app.ec67f059.css", "build/app.css": "/build/app.ec67f059.css",
"build/app.js": "/build/app.3644f7b2.js", "build/app.js": "/build/app.3644f7b2.js",
"build/admin.css": "/build/admin.4de55830.css", "build/admin.css": "/build/admin.4de55830.css",
"build/admin.js": "/build/admin.a08fea06.js", "build/admin.js": "/build/admin.3f7739a8.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js", "build/runtime.js": "/build/runtime.6ad5c9da.js",
"build/images/fa-solid-900.svg": "/build/images/fa-solid-900.a838c42a.svg", "build/images/fa-solid-900.svg": "/build/images/fa-solid-900.a838c42a.svg",
"build/images/fa-brands-400.svg": "/build/images/fa-brands-400.05d20183.svg", "build/images/fa-brands-400.svg": "/build/images/fa-brands-400.05d20183.svg",
......
...@@ -172,6 +172,10 @@ class AdherentAdmin extends AbstractAdmin ...@@ -172,6 +172,10 @@ class AdherentAdmin extends AbstractAdmin
$adherent->setGeoloc(new Geoloc()); $adherent->setGeoloc(new Geoloc());
} }
$withQuartier = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::GEOLOC_WITH_QUARTIER);
$withSubterritory = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::GEOLOC_WITH_SUBTERRITORY);
$formMapper $formMapper
->tab('General') ->tab('General')
->with('Identité', ['class' => 'col-md-7']) ->with('Identité', ['class' => 'col-md-7'])
...@@ -185,11 +189,8 @@ class AdherentAdmin extends AbstractAdmin ...@@ -185,11 +189,8 @@ class AdherentAdmin extends AbstractAdmin
'required' => true, 'required' => true,
'with_geoloc' => false, 'with_geoloc' => false,
'with_latlon' => false, 'with_latlon' => false,
'with_subterritory' => 'with_subterritory' => 'true' === $withSubterritory,
$tav_env 'with_quartier' => 'true' === $withQuartier
&& $household_based_allowance
&& !$simplified_household_based_allowance,
'with_quartier' => $tav_env && $household_based_allowance
]) ])
->end() ->end()
->with('Groupe', ['class' => 'col-md-5']) ->with('Groupe', ['class' => 'col-md-5'])
...@@ -205,6 +206,8 @@ class AdherentAdmin extends AbstractAdmin ...@@ -205,6 +206,8 @@ class AdherentAdmin extends AbstractAdmin
; ;
if ($tav_env) { if ($tav_env) {
$mlc = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_SYMBOL);
if ($this->getConfigurationPool()->getContainer()->getParameter('ccas_mode')) { if ($this->getConfigurationPool()->getContainer()->getParameter('ccas_mode')) {
$formMapper $formMapper
->tab('General') ->tab('General')
...@@ -325,6 +328,17 @@ class AdherentAdmin extends AbstractAdmin ...@@ -325,6 +328,17 @@ class AdherentAdmin extends AbstractAdmin
$cotisSectionInfo .= " " . $adherent->getProfilDeCotisation() . "."; $cotisSectionInfo .= " " . $adherent->getProfilDeCotisation() . ".";
} }
$maxAllocationAmount = $em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT);
$allowanceCalculationLimitationMsg = (null !== $maxAllocationAmount) ? " dans la limite de {$maxAllocationAmount} {$mlc}" : '';
$minCotisationAmount = $em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_COTISATION_MINIMUM);
$minimumByShare = $em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_COTIS_MINIMUM_BY_SHARE);
$minGranularity = ('true' === $minimumByShare) ? 'part' : 'foyer';
$minCotisationMsg = (null !== $minCotisationAmount) ? "Montant minimum : {$minCotisationAmount}€ par {$minGranularity}." : '';
// Add cotisation info // Add cotisation info
$formMapper $formMapper
->tab('General') ->tab('General')
...@@ -334,14 +348,14 @@ class AdherentAdmin extends AbstractAdmin ...@@ -334,14 +348,14 @@ class AdherentAdmin extends AbstractAdmin
]) ])
->add('cotisationAmount', NumberType::class, [ ->add('cotisationAmount', NumberType::class, [
'label' => 'Montant de la cotisation (en €)', 'label' => 'Montant de la cotisation (en €)',
'help' => $simplified_household_based_allowance ? '' : 'Montant minimum : 10€ par foyer + 5€/personne supplémentaire du foyer', 'help' => $minCotisationMsg,
'disabled' => $disableHouseholdAllowanceFields, 'disabled' => $disableHouseholdAllowanceFields,
]) ])
->add('allocationAmount', NumberType::class, [ ->add('allocationAmount', NumberType::class, [
'label' => 'Montant d\'allocation prévu en fonction du foyer (en MonA)', 'label' => 'Montant d\'allocation prévu en fonction du foyer (en MonA)',
'disabled' => true, 'disabled' => true,
'required' => false, 'required' => false,
'help' => 'Le montant de l\'allocation sera calculé automatiquement en fonction des informations du foyer une fois les informations sauvegardées.' 'help' => "Le montant de l'allocation sera calculé automatiquement en fonction des informations du foyer une fois les informations sauvegardées{$allowanceCalculationLimitationMsg}."
]) ])
->end() ->end()
->end(); ->end();
...@@ -453,7 +467,6 @@ class AdherentAdmin extends AbstractAdmin ...@@ -453,7 +467,6 @@ class AdherentAdmin extends AbstractAdmin
if (!empty($adherent) && !empty($adherent->getEmlcAccount()) ) { if (!empty($adherent) && !empty($adherent->getEmlcAccount()) ) {
$balance = $adherent->getEmlcAccount()->getBalance(); $balance = $adherent->getEmlcAccount()->getBalance();
$mlc = $em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_SYMBOL);
$formMapper $formMapper
->tab('General') ->tab('General')
->with('Informations de cotisation') ->with('Informations de cotisation')
...@@ -550,15 +563,30 @@ class AdherentAdmin extends AbstractAdmin ...@@ -550,15 +563,30 @@ class AdherentAdmin extends AbstractAdmin
} }
if ($this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance')) { if ($this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance')) {
if (!$this->getConfigurationPool()->getContainer()->getParameter('simplified_household_based_allowance')) { // check cotisation amount above minimum if activated
// check cotisation amount $minCotisationAmount = $em->getRepository(GlobalParameter::class)
$adultsCount = $adherent->getHouseholdAdultCount(); ->val(GlobalParameter::SSA_HOUSEHOLD_COTISATION_MINIMUM);
$dependentChildrenCount = count($adherent->getDependentChildren());
$minCotisationAmount = 10 + 5 * ( $adultsCount - 1 ) + 5 * $dependentChildrenCount; if (null !== $minCotisationAmount) {
// if minimum by share is activated
if ($adherent->getCotisationAmount() < $minCotisationAmount) { $minimumByShare = $em->getRepository(GlobalParameter::class)
$event->getForm()->get('cotisationAmount')->addError(new FormError('Le montant minimum est de ' . $minCotisationAmount . '€ (selon les données du foyer indiquées)')); ->val(GlobalParameter::SSA_HOUSEHOLD_COTIS_MINIMUM_BY_SHARE);
}
if ('true' === $minimumByShare) {
$cotisationBaseAmount = $em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_BASE_AMOUNT);
$calculatedAllocationAmount = $this->tavCotisationUtils->getCalculatedHouseholdAllowanceValue($adherent);
$sharesNb = round($calculatedAllocationAmount / $cotisationBaseAmount, 2);
$minAmountByShares = ((int) $minCotisationAmount) * $sharesNb;
if ($adherent->getCotisationAmount() < $minAmountByShares) {
$event->getForm()->get('cotisationAmount')->addError(new FormError("Montant invalide : le minimum est de {$minAmountByShares}€"));
}
} else if ($adherent->getCotisationAmount() < (int) $minCotisationAmount) {
$event->getForm()->get('cotisationAmount')->addError(new FormError('Montant invalide'));
}
} }
// try to fix balance if required // try to fix balance if required
...@@ -724,16 +752,18 @@ class AdherentAdmin extends AbstractAdmin ...@@ -724,16 +752,18 @@ class AdherentAdmin extends AbstractAdmin
]) ])
; ;
$withSubterritory = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::GEOLOC_WITH_SUBTERRITORY);
if('true' === $withSubterritory) {
$datagridMapper->add('geoloc.subterritory', null, [
'label' => 'Territoire',
'advanced_filter' => false,
'show_filter' => true,
]);
}
if ($this->getConfigurationPool()->getContainer()->getParameter('tav_env')) { if ($this->getConfigurationPool()->getContainer()->getParameter('tav_env')) {
$datagridMapper $datagridMapper
->remove('cotisationajour'); ->remove('cotisationajour');
if($this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance')) {
$datagridMapper->add('geoloc.subterritory', null, [
'label' => 'Territoire',
'advanced_filter' => false,
'show_filter' => true,
]);
}
if ($this->getConfigurationPool()->getContainer()->getParameter('ccas_mode')) { if ($this->getConfigurationPool()->getContainer()->getParameter('ccas_mode')) {
$datagridMapper $datagridMapper
->add('anonymoustoken', CallbackFilter::class, [ ->add('anonymoustoken', CallbackFilter::class, [
......
...@@ -4,6 +4,7 @@ namespace App\Admin; ...@@ -4,6 +4,7 @@ namespace App\Admin;
use App\Entity\Flux; use App\Entity\Flux;
use App\Entity\Subterritory; use App\Entity\Subterritory;
use App\Entity\GlobalParameter;
use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Datagrid\ListMapper;
...@@ -177,11 +178,10 @@ class FluxAdmin extends AbstractAdmin ...@@ -177,11 +178,10 @@ class FluxAdmin extends AbstractAdmin
]) ])
; ;
// In household based allowance (but not simplified) add filter on adherent territory // Add filter on adherent territory if active
$household_based_allowance = $this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance'); $withSubterritory = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::GEOLOC_WITH_SUBTERRITORY);
$simplified_household_based_allowance = $this->getConfigurationPool()->getContainer()->getParameter('simplified_household_based_allowance');
if($household_based_allowance && !$simplified_household_based_allowance) { if('true' === $withSubterritory) {
$datagridMapper->add('territory', CallbackFilter::class, [ $datagridMapper->add('territory', CallbackFilter::class, [
'callback' => [$this, 'getTerritoryFilter'], 'callback' => [$this, 'getTerritoryFilter'],
'field_type' => SChoiceType::class, 'field_type' => SChoiceType::class,
......
...@@ -71,11 +71,10 @@ class OperationAdherentAdmin extends OperationAdmin ...@@ -71,11 +71,10 @@ class OperationAdherentAdmin extends OperationAdmin
'show_filter' => true, 'show_filter' => true,
]); ]);
// In household based allowance (but not simplified) add filter on adherent territory // Add filter on adherent territory if active
$household_based_allowance = $this->getConfigurationPool()->getContainer()->getParameter('household_based_allowance'); $withSubterritory = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(GlobalParameter::class)->val(GlobalParameter::GEOLOC_WITH_SUBTERRITORY);
$simplified_household_based_allowance = $this->getConfigurationPool()->getContainer()->getParameter('simplified_household_based_allowance');
if($household_based_allowance && !$simplified_household_based_allowance) { if('true' === $withSubterritory) {
$datagridMapper->add('account.adherent.geoloc.subterritory', null, [ $datagridMapper->add('account.adherent.geoloc.subterritory', null, [
'label' => 'Territoire', 'label' => 'Territoire',
'advanced_filter' => false, 'advanced_filter' => false,
......
...@@ -4,6 +4,7 @@ namespace App\Admin; ...@@ -4,6 +4,7 @@ namespace App\Admin;
use App\Entity\AccountPrestataire; use App\Entity\AccountPrestataire;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\Caissier;
use App\Entity\ContactPrestataire; use App\Entity\ContactPrestataire;
use App\Entity\CotisationAdherent; use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire; use App\Entity\CotisationPrestataire;
...@@ -179,6 +180,11 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -179,6 +180,11 @@ class PrestataireAdmin extends AbstractAdmin
} }
} }
$existingCaissiers = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Caissier::class)->findBy(['prestataire' => $presta]);
$existingCaissiersUsers = array_map(function ($caissier) {
return $caissier->getUser();
}, $existingCaissiers);
$formMapper $formMapper
->tab('Prestataire') ->tab('Prestataire')
->with('Prestataire', ['class' => 'col-md-6']) ->with('Prestataire', ['class' => 'col-md-6'])
...@@ -333,11 +339,12 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -333,11 +339,12 @@ class PrestataireAdmin extends AbstractAdmin
->end() ->end()
->with('Caissier(s)', ['class' => 'col-md-6']) ->with('Caissier(s)', ['class' => 'col-md-6'])
->add('caissiers', EntityType::class, [ ->add('caissiers', EntityType::class, [
// 'mapped' => false, 'mapped' => false,
'class' => User::class, 'class' => User::class, // instance of user so we can set existing users as choices
'multiple' => true, 'multiple' => true,
'required' => false, 'required' => false,
'label' => 'Associer à un(des) utilisateur(s) existant :', 'label' => 'Associer à un(des) utilisateur(s) existant :',
'data' => $existingCaissiersUsers,
'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(User::class)->findOrderByName(), 'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(User::class)->findOrderByName(),
'choice_label' => function ($user) { 'choice_label' => function ($user) {
return $user->getLastname() . ' ' . $user->getFirstname() . ' (' . $user->getEmail() . ')'; return $user->getLastname() . ' ' . $user->getFirstname() . ' (' . $user->getEmail() . ')';
...@@ -419,31 +426,58 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -419,31 +426,58 @@ class PrestataireAdmin extends AbstractAdmin
// )) // ))
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager(); $em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
$formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { $formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($existingCaissiers) {
$prestataire = $event->getData(); $prestataire = $event->getData();
$users = null; $users = null;
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
/* /*
Permet d'ajouter le nouvel utilisateur crée (newusers) aux gestionnaires du presta Permet d'ajouter le nouvel utilisateur créé (newusers) aux gestionnaires du presta
(On crée un compte adhérent en même temps que le prestataire) (On crée un compte adhérent en même temps que le prestataire)
Ajoute et/ou supprime le(s) caissier(s)
*/ */
if (null != $event->getForm()->get('users')->getData()) { if (null != $event->getForm()->get('users')->getData()) {
$users = $event->getForm()->get('users')->getData(); $users = $event->getForm()->get('users')->getData();
$this->addUsersOrCaissers($users, $prestataire); $this->addUsersOrCaissiers($users, $prestataire);
} }
if (null != $event->getForm()->get('caissiers')->getData()) { if (null != $event->getForm()->get('caissiers')->getData()) {
$caissiers = $event->getForm()->get('caissiers')->getData(); $caissiers = $event->getForm()->get('caissiers')->getData(); // instances of user here
$this->addUsersOrCaissers($caissiers, $prestataire, 'ROLE_CAISSIER'); $this->addUsersOrCaissiers($caissiers, $prestataire, 'ROLE_CAISSIER');
// Remove caissiers: get difference between existing caissier and caissiers set in field
$caissiersToRemove = [];
foreach ($existingCaissiers as $existingCaissier) {
$remove = true;
foreach ($caissiers as $caissierUser) {
if ($existingCaissier->getUser()->getId() === $caissierUser->getId()) {
$remove = false;
break;
}
}
if (true === $remove) {
// if user is only caissier for this prestataire and caissier is removed,
// remove role caissier for user
if (count($existingCaissier->getUser()->getCaissiers()) === 1) {
$groupeCaissier = $em->getRepository(Usergroup::class)->findOneByName('Caissier');
$existingCaissier->getUser()->removePossibleGroup($groupeCaissier);
}
// Remove caissier from prestataire
$prestataire->removeCaissier($existingCaissier);
}
}
} }
if (null != $event->getForm()->get('newusers')->getData()) { if (null != $event->getForm()->get('newusers')->getData()) {
$newusers = $event->getForm()->get('newusers')->getData(); $newusers = $event->getForm()->get('newusers')->getData();
$return = $this->addUsersOrCaissers($newusers, $prestataire); $return = $this->addUsersOrCaissiers($newusers, $prestataire);
if (false === $return) { if (false === $return) {
$event->getForm()->get('newusers')->addError(new FormError('Gestionnaires : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!')); $event->getForm()->get('newusers')->addError(new FormError('Gestionnaires : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!'));
} }
} }
if (null != $event->getForm()->get('newcaissiers')->getData()) { if (null != $event->getForm()->get('newcaissiers')->getData()) {
$newcaissiers = $event->getForm()->get('newcaissiers')->getData(); $newcaissiers = $event->getForm()->get('newcaissiers')->getData();
$return = $this->addUsersOrCaissers($newcaissiers, $prestataire, 'ROLE_CAISSIER'); $return = $this->addUsersOrCaissiers($newcaissiers, $prestataire, 'ROLE_CAISSIER');
if (count($return) > 0) { if (count($return) > 0) {
$event->getForm()->get('newcaissiers')->addError(new FormError('Caissiers : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!')); $event->getForm()->get('newcaissiers')->addError(new FormError('Caissiers : Courriel(s) déjà utilisé : ' . implode(', ', $return) . '!'));
} }
...@@ -452,7 +486,7 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -452,7 +486,7 @@ class PrestataireAdmin extends AbstractAdmin
parent::configureFormFields($formMapper); parent::configureFormFields($formMapper);
} }
private function addUsersOrCaissers($users, Prestataire $prestataire, string $role = 'ROLE_PRESTATAIRE') private function addUsersOrCaissiers($users, Prestataire $prestataire, string $role = 'ROLE_PRESTATAIRE')
{ {
$return = []; $return = [];
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager(); $em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
...@@ -474,18 +508,27 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -474,18 +508,27 @@ class PrestataireAdmin extends AbstractAdmin
} }
if ('ROLE_PRESTATAIRE' == $role) { if ('ROLE_PRESTATAIRE' == $role) {
$prestataire->addUser($user); $prestataire->addUser($user);
$groupePresta = $em->getRepository(Usergroup::class)->findOneByName('Prestataire');
if ($newUser) { if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_PRESTATAIRE, new PrestataireEvent($user, $prestataire, $this->getRequest())); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_PRESTATAIRE, new PrestataireEvent($user, $prestataire, $this->getRequest()));
} }
$groupePresta = $em->getRepository(Usergroup::class)->findOneByName('Prestataire');
$user->addPossiblegroup($groupePresta);
} elseif ('ROLE_CAISSIER' == $role) { } elseif ('ROLE_CAISSIER' == $role) {
$prestataire->addCaissier($user); $caissier = $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(Caissier::class)->findOneBy(['prestataire' => $prestataire, 'user' => $user]);
$groupePresta = $em->getRepository(Usergroup::class)->findOneByName('Caissier'); if (null === $caissier) {
$caissier = new Caissier();
$caissier->setUser($user);
$caissier->setPrestataire($prestataire);
$em->persist($caissier);
}
$prestataire->addCaissier($caissier);
if ($newUser) { if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $this->getRequest())); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $this->getRequest()));
} }
$groupeCaissier = $em->getRepository(Usergroup::class)->findOneByName('Caissier');
$user->addPossiblegroup($groupeCaissier);
} }
$user->addPossiblegroup($groupePresta);
$this->userManager->updateCanonicalFields($user); $this->userManager->updateCanonicalFields($user);
$em->persist($user); $em->persist($user);
if ($newUser) { if ($newUser) {
......
...@@ -290,6 +290,7 @@ class FluxController extends AbstractController ...@@ -290,6 +290,7 @@ class FluxController extends AbstractController
'Date' => 'createdAt', 'Date' => 'createdAt',
'Expediteur' => 'flux.expediteur', 'Expediteur' => 'flux.expediteur',
'Destinataire' => 'flux.destinataire', 'Destinataire' => 'flux.destinataire',
'Operateur' => 'flux.operateur',
'Montant' => 'montant', 'Montant' => 'montant',
'Type parent' => 'flux.parenttype', 'Type parent' => 'flux.parenttype',
'Type' => 'flux.type', 'Type' => 'flux.type',
......
...@@ -6,6 +6,7 @@ use App\Entity\AccountComptoir; ...@@ -6,6 +6,7 @@ use App\Entity\AccountComptoir;
use App\Entity\AccountGroupe; use App\Entity\AccountGroupe;
use App\Entity\AccountPrestataire; use App\Entity\AccountPrestataire;
use App\Entity\AccountSiege; use App\Entity\AccountSiege;
use App\Entity\Caissier;
use App\Entity\Comptoir; use App\Entity\Comptoir;
use App\Entity\Geoloc; use App\Entity\Geoloc;
use App\Entity\GeolocPrestataire; use App\Entity\GeolocPrestataire;
...@@ -696,11 +697,12 @@ class IndexController extends AbstractController ...@@ -696,11 +697,12 @@ class IndexController extends AbstractController
public function prestaChoiceAction(Usergroup $group, Prestataire $prestataire, Request $request) public function prestaChoiceAction(Usergroup $group, Prestataire $prestataire, Request $request)
{ {
$this->em->refresh($this->getUser()); $this->em->refresh($this->getUser());
if (!(($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_PRESTATAIRE', $value->getRoles()); // prevent operation if user isn't a prestataire
}) and $this->getUser()->getPrestataires()->contains($prestataire)) || (($this->getUser()->getPossiblegroups()->exists(function ($key, $value) { if (
return in_array('ROLE_CAISSIER', $value->getRoles()); !($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
}) and $this->getUser()->getCaissiers()->contains($prestataire)))) return in_array('ROLE_PRESTATAIRE', $value->getRoles());
}) and $this->getUser()->getPrestataires()->contains($prestataire))
) { ) {
$this->addFlash( $this->addFlash(
'error', 'error',
...@@ -717,6 +719,39 @@ class IndexController extends AbstractController ...@@ -717,6 +719,39 @@ class IndexController extends AbstractController
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
/**
* Choix du presta géré.
*
* @Route("/login/caissier/choice/{usergrpid}/{caissierid}", name="caissier_choice")
* @ParamConverter("group", class="App:Usergroup", options={"mapping": {"usergrpid": "id"}})
* @ParamConverter("caissier", class="App:Caissier", options={"mapping": {"caissierid": "id"}})
* @IsGranted("ROLE_USER")
*/
public function caissierChoiceAction(Usergroup $group, Caissier $caissier, Request $request)
{
$this->em->refresh($this->getUser());
// prevent operation if user isn't a caissier
if (
!($this->getUser()->getPossiblegroups()->exists(function ($key, $value) {
return in_array('ROLE_CAISSIER', $value->getRoles());
}) and $this->getUser()->getCaissiers()->contains($caissier))
) {
$this->addFlash(
'error',
'Accès impossible !'
);
return $this->redirectToRoute('index');
}
$this->removeOldSessionParams();
// On enregistre le presta choisit en session
$this->session->set('_prestagere', $caissier->getPrestataire());
$this->reloadUserTokenFromGroup($group, $request);
return $this->redirectToRoute('index');
}
/** /**
* @Route("/login/group/choice/{id}", name="usergroup_choice") * @Route("/login/group/choice/{id}", name="usergroup_choice")
* @IsGranted("ROLE_USER") * @IsGranted("ROLE_USER")
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Caissier;
use App\Entity\Groupe; use App\Entity\Groupe;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\Rubrique; use App\Entity\Rubrique;
...@@ -16,18 +17,21 @@ use Symfony\Component\Routing\Annotation\Route; ...@@ -16,18 +17,21 @@ use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
class PrestatairesController extends FrontController class PrestatairesController extends FrontController
{ {
protected $em; protected $em;
private $router; private $router;
private $session; private $session;
private $security;
public function __construct(EntityManagerInterface $em, RouterInterface $router, SessionInterface $session) public function __construct(EntityManagerInterface $em, RouterInterface $router, SessionInterface $session, Security $security)
{ {
$this->em = $em; $this->em = $em;
$this->router = $router; $this->router = $router;
$this->session = $session; $this->session = $session;
$this->security = $security;
} }
/** /**
...@@ -165,45 +169,53 @@ class PrestatairesController extends FrontController ...@@ -165,45 +169,53 @@ class PrestatairesController extends FrontController
} }
/** /**
* Get the total transactions amount towards the Prestataire since the last time it was fetched. * Get the total transactions amount towards the Prestataire operated by the connected Caissier,
* Exclude Reconversions from calculation. * since the last time it was fetched.
* *
* @Route("/prestataires/get_last_transactions", name="get_presta_last_transactions") * @Route("/prestataires/get_caissier_last_transactions", name="get_caissier_last_transactions")
* @IsGranted({"ROLE_CAISSIER", "ROLE_PRESTATAIRE"}) * @IsGranted({"ROLE_CAISSIER"})
*/ */
public function getLastTransactionsAmount() public function getLastCaissierTransactionsAmount()
{ {
if (!$this->session->has('_prestagere')) { if (!$this->session->has('_prestagere')) {
return null; return null;
} }
// Get last export datetime (presta creation if first export) $user = $this->security->getUser();
$presta = $this->em->getRepository(Prestataire::class)->findOneById($this->session->get('_prestagere')->getId()); $presta = $this->em->getRepository(Prestataire::class)->findOneById($this->session->get('_prestagere')->getId());
$caissier = $this->em->getRepository(Caissier::class)->findOneBy(['prestataire' => $presta, 'user' => $user]);
$datetime_last_export = $presta->getLastTransactionsExportDatetime(); // Get last caissier export datetime
$datetime_last_export = $caissier->getLastTransactionsExportDatetime();
if (null == $datetime_last_export) { if (null == $datetime_last_export) {
$datetime_last_export = $presta->getCreatedAt(); // for transition purposes from Prestataire level export towards Caissier level export,
// get prestataire last export if caissier export date is not yet set
$datetime_last_export = $caissier->getLastTransactionsExportDatetime();
if (null == $datetime_last_export) {
// prestaire creation if first export
$datetime_last_export = $presta->getCreatedAt();
}
} }
// Get total amount // Get total amount of transactions operated by connecteed Caissier for this Prestataire
$flux = $this->em->getRepository(Flux::class)->getQueryByPrestataire( $flux = $this->em->getRepository(Flux::class)->getQueryByCaissier(
$this->session->get('_prestagere'), $user,
null, $presta,
null,
$datetime_last_export->format(("Y-m-d H:i:s")) $datetime_last_export->format(("Y-m-d H:i:s"))
)->getResult(); )->getResult();
$total_amount = 0; $total_amount = 0;
foreach ($flux as $flux_item) { foreach ($flux as $flux_item) {
// Exclude reconversions from calculation // Exclude reconversions from calculation (extra security but probably unecessary, as reconversions don't have an operator)
if ($flux_item->getType() != "reconversion_prestataire") { if ($flux_item->getType() != "reconversion_prestataire") {
$total_amount += $flux_item->getMontant(); $total_amount += $flux_item->getMontant();
} }
} }
// Set now as this presta last export date // Set now as this caissier last export datetime
$presta->setLastTransactionsExportDatetime(new \Datetime('now')); $caissier->setLastTransactionsExportDatetime(new \Datetime('now'));
$this->em->persist($presta); $this->em->persist($caissier);
$this->em->flush(); $this->em->flush();
$str_datetime = $datetime_last_export->format('d/m/Y H\hi'); $str_datetime = $datetime_last_export->format('d/m/Y H\hi');
......
...@@ -4,6 +4,7 @@ namespace App\Controller; ...@@ -4,6 +4,7 @@ namespace App\Controller;
use App\Entity\AchatMonnaieAConfirmerPrestataire; use App\Entity\AchatMonnaieAConfirmerPrestataire;
use App\Entity\AchatMonnaiePrestataire; use App\Entity\AchatMonnaiePrestataire;
use App\Entity\Caissier;
use App\Entity\GlobalParameter; use App\Entity\GlobalParameter;
use App\Entity\Payment; use App\Entity\Payment;
use App\Entity\Prestataire; use App\Entity\Prestataire;
...@@ -75,12 +76,17 @@ class UserPrestataireController extends FluxController ...@@ -75,12 +76,17 @@ class UserPrestataireController extends FluxController
$this->translator->trans($errorText) $this->translator->trans($errorText)
); );
} else { } else {
// Remove caissier(s) if delete from the field // Remove caissier(s) if deleted from the field
foreach ($originalCaissiers as $oldCaissier) { foreach ($originalCaissiers as $oldCaissier) {
if (!in_array($oldCaissier->getEmail(), $caissiers)) { if (!in_array($oldCaissier->getUser()->getEmail(), $caissiers)) {
$groupePresta = $this->em->getRepository(Usergroup::class)->findOneByName('Caissier'); // if user is only caissier for this prestataire and caissier is removed,
$oldCaissier->removePossibleGroup($groupePresta); // remove role caissier for user
$this->em->persist($oldCaissier); if (count($oldCaissier->getUser()->getCaissiers()) === 1) {
$groupeCaissier = $this->em->getRepository(Usergroup::class)->findOneByName('Caissier');
$oldCaissier->getUser()->removePossibleGroup($groupeCaissier);
$this->em->persist($oldCaissier->getUser());
}
$form->getData()->getCaissiers()->removeElement($oldCaissier); $form->getData()->getCaissiers()->removeElement($oldCaissier);
} }
} }
...@@ -134,12 +140,19 @@ class UserPrestataireController extends FluxController ...@@ -134,12 +140,19 @@ class UserPrestataireController extends FluxController
$user->setEmail($email); $user->setEmail($email);
$user->setUsername($email); $user->setUsername($email);
} }
$prestataire->addCaissier($user); $caissier = $this->em->getRepository(Caissier::class)->findOneBy(['prestataire' => $prestataire, 'user' => $user]);
$groupePresta = $this->em->getRepository(Usergroup::class)->findOneByName('Caissier'); if (null === $caissier) {
$caissier = new Caissier();
$caissier->setUser($user);
$caissier->setPrestataire($prestataire);
$this->em->persist($caissier);
}
$prestataire->addCaissier($caissier);
$groupeCaissier = $this->em->getRepository(Usergroup::class)->findOneByName('Caissier');
if ($newUser) { if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $request)); $this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $request));
} }
$user->addPossiblegroup($groupePresta); $user->addPossiblegroup($groupeCaissier);
$this->userManager->updateCanonicalFields($user); $this->userManager->updateCanonicalFields($user);
$this->em->persist($user); $this->em->persist($user);
if ($newUser) { if ($newUser) {
......
<?php
namespace App\Entity;
use App\Repository\CaissierRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CaissierRepository::class)
*/
class Caissier
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="caissiers")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity=Prestataire::class, inversedBy="caissiers")
* @ORM\JoinColumn(nullable=false)
*/
private $prestataire;
/**
* Caissiers can export all the transactions since the last export.
*
* @ORM\Column(type="datetime", nullable=true)
*/
private $lastTransactionsExportDatetime;
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getPrestataire(): ?Prestataire
{
return $this->prestataire;
}
public function setPrestataire(?Prestataire $prestataire): self
{
$this->prestataire = $prestataire;
return $this;
}
public function getLastTransactionsExportDatetime(): ?\DateTimeInterface
{
return $this->lastTransactionsExportDatetime;
}
public function setLastTransactionsExportDatetime(?\DateTimeInterface $lastTransactionsExportDatetime): self
{
$this->lastTransactionsExportDatetime = $lastTransactionsExportDatetime;
return $this;
}
public function __toString()
{
return $this->getUser()->__toString();
}
}
...@@ -29,7 +29,7 @@ class DependentChild ...@@ -29,7 +29,7 @@ class DependentChild
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
*/ */
private $olderThanFourteen; private $olderThanLimitAge;
/** /**
* @var float * @var float
...@@ -57,14 +57,14 @@ class DependentChild ...@@ -57,14 +57,14 @@ class DependentChild
return $this; return $this;
} }
public function getOlderThanFourteen() public function getOlderThanLimitAge()
{ {
return $this->olderThanFourteen; return $this->olderThanLimitAge;
} }
public function setOlderThanFourteen($olderThanFourteen) public function setOlderThanLimitAge($olderThanLimitAge)
{ {
$this->olderThanFourteen = $olderThanFourteen; $this->olderThanLimitAge = $olderThanLimitAge;
return $this; return $this;
} }
......
...@@ -61,6 +61,22 @@ class GlobalParameter ...@@ -61,6 +61,22 @@ class GlobalParameter
const SSA_SIMPL_HOUSEHOLD_ADMIN_TEXT_INFO_ADHERENT_FALLBACKS_TO_PROFILECOTIS = 'SSA_SIMPL_HOUSEHOLD_ADMIN_TEXT_INFO_ADHERENT_FALLBACKS_TO_PROFILECOTIS'; const SSA_SIMPL_HOUSEHOLD_ADMIN_TEXT_INFO_ADHERENT_FALLBACKS_TO_PROFILECOTIS = 'SSA_SIMPL_HOUSEHOLD_ADMIN_TEXT_INFO_ADHERENT_FALLBACKS_TO_PROFILECOTIS';
const SSA_DISABLE_COTISATION = 'SSA_DISABLE_COTISATION'; const SSA_DISABLE_COTISATION = 'SSA_DISABLE_COTISATION';
const SSA_FORCE_ALLOCATION_AMOUNT = 'SSA_FORCE_ALLOCATION_AMOUNT'; const SSA_FORCE_ALLOCATION_AMOUNT = 'SSA_FORCE_ALLOCATION_AMOUNT';
const SSA_HOUSEHOLD_BASE_AMOUNT = 'SSA_HOUSEHOLD_BASE_AMOUNT';
const SSA_HOUSEHOLD_SECONDARY_AMOUNT = 'SSA_HOUSEHOLD_SECONDARY_AMOUNT';
const SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE = 'SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE';
const SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT = 'SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT';
const SSA_HOUSEHOLD_USE_SHARED_CUSTODY = 'SSA_HOUSEHOLD_USE_SHARED_CUSTODY';
const SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT = 'SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT';
const SSA_HOUSEHOLD_COTISATION_MINIMUM = 'SSA_HOUSEHOLD_COTISATION_MINIMUM';
const SSA_HOUSEHOLD_WITH_QUARTIER = 'SSA_HOUSEHOLD_WITH_QUARTIER';
const SSA_HOUSEHOLD_QUARTIER_LIST_VALUES = 'SSA_HOUSEHOLD_QUARTIER_LIST_VALUES';
const SSA_HOUSEHOLD_WITH_SUBTERRITORY = 'SSA_HOUSEHOLD_WITH_SUBTERRITORY';
const SSA_HOUSEHOLD_COTIS_MINIMUM_BY_SHARE = 'SSA_HOUSEHOLD_COTIS_MINIMUM_BY_SHARE';
const GEOLOC_WITH_QUARTIER = 'GEOLOC_WITH_QUARTIER';
const GEOLOC_QUARTIER_LIST_VALUES = 'GEOLOC_QUARTIER_LIST_VALUES';
const GEOLOC_WITH_SUBTERRITORY = 'GEOLOC_WITH_SUBTERRITORY';
const COMPTOIR_PAYMENT_TYPES = 'COMPTOIR_PAYMENT_TYPES';
/** /**
* @var \Ramsey\Uuid\UuidInterface * @var \Ramsey\Uuid\UuidInterface
* *
...@@ -130,7 +146,10 @@ class GlobalParameter ...@@ -130,7 +146,10 @@ class GlobalParameter
return $this->value; return $this->value;
} }
public function setValue(string $value): self /**
* Allow to set null value with '?string'
*/
public function setValue(?string $value): self
{ {
$this->value = $value; $this->value = $value;
......
...@@ -291,16 +291,9 @@ class Prestataire extends AccountableObject implements AccountableInterface ...@@ -291,16 +291,9 @@ class Prestataire extends AccountableObject implements AccountableInterface
protected $users; protected $users;
/** /**
* @var ArrayCollection|User[] * @ORM\OneToMany(targetEntity=Caissier::class, mappedBy="prestataire", orphanRemoval=true)
*
* @ORM\ManyToMany(targetEntity="User", inversedBy="caissiers", cascade={"persist"})
* @ORM\JoinTable(name="user_caissier",
* joinColumns={@ORM\JoinColumn(name="prestataire_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
* @Groups({"read", "write"})
*/ */
protected $caissiers; private $caissiers;
/** /**
* @var Groupe * @var Groupe
...@@ -359,7 +352,9 @@ class Prestataire extends AccountableObject implements AccountableInterface ...@@ -359,7 +352,9 @@ class Prestataire extends AccountableObject implements AccountableInterface
private $comments; private $comments;
/** /**
* Caissiers can export all the transactions since the last export. * [UNUSED]
* This field has been moved to the Caissier entity.
* This field is kept for transitions purposes only and isn't updated anymore.
* *
* @ORM\Column(type="datetime", nullable=true) * @ORM\Column(type="datetime", nullable=true)
*/ */
...@@ -794,9 +789,9 @@ class Prestataire extends AccountableObject implements AccountableInterface ...@@ -794,9 +789,9 @@ class Prestataire extends AccountableObject implements AccountableInterface
} }
/** /**
* @return ArrayCollection[]|User * @return Collection<int, Caissier>
*/ */
public function getCaissiers() public function getCaissiers(): Collection
{ {
return $this->caissiers; return $this->caissiers;
} }
...@@ -872,31 +867,23 @@ class Prestataire extends AccountableObject implements AccountableInterface ...@@ -872,31 +867,23 @@ class Prestataire extends AccountableObject implements AccountableInterface
return $this; return $this;
} }
/** public function addCaissier(Caissier $caissier): self
* @param User $caissier
*
* @return $this
*/
public function addCaissier(User $caissier): self
{ {
if (!$this->caissiers->contains($caissier)) { if (!$this->caissiers->contains($caissier)) {
$this->caissiers[] = $caissier; $this->caissiers[] = $caissier;
$caissier->addCaissier($this); $caissier->setPrestataire($this);
} }
return $this; return $this;
} }
/** public function removeCaissier(Caissier $caissier): self
* @param User $caissier
*
* @return $this
*/
public function removeCaissier(User $caissier)
{ {
if ($this->caissiers->contains($caissier)) { if ($this->caissiers->removeElement($caissier)) {
$this->caissiers->removeElement($caissier); // set the owning side to null (unless already changed)
$caissier->removeCaissier($this); if ($caissier->getPrestataire() === $this) {
$caissier->setPrestataire(null);
}
} }
return $this; return $this;
......
...@@ -126,9 +126,9 @@ class User extends BaseUser ...@@ -126,9 +126,9 @@ class User extends BaseUser
protected $prestataires; protected $prestataires;
/** /**
* @ORM\ManyToMany(targetEntity="App\Entity\Prestataire", mappedBy="caissiers", cascade={"persist"}, fetch="EAGER") * @ORM\OneToMany(targetEntity=Caissier::class, mappedBy="user", orphanRemoval=true)
*/ */
protected $caissiers; private $caissiers;
/** /**
* @ORM\ManyToMany(targetEntity="App\Entity\Groupe", mappedBy="gestionnaires", cascade={"persist"}, fetch="EAGER") * @ORM\ManyToMany(targetEntity="App\Entity\Groupe", mappedBy="gestionnaires", cascade={"persist"}, fetch="EAGER")
...@@ -418,48 +418,35 @@ class User extends BaseUser ...@@ -418,48 +418,35 @@ class User extends BaseUser
} }
/** /**
* Get caissiers. * @return Collection<int, Caissier>
*
* @return
*/ */
public function getCaissiers() public function getCaissiers(): Collection
{ {
return $this->caissiers; return $this->caissiers;
} }
/** public function addCaissier(Caissier $caissier): self
* @param Prestataire $caissier
*
* @return $this
*/
public function addCaissier(Prestataire $caissier): self
{ {
if (!$this->caissiers->contains($caissier)) { if (!$this->caissiers->contains($caissier)) {
$this->caissiers[] = $caissier; $this->caissiers[] = $caissier;
$caissier->setUser($this);
} }
return $this; return $this;
} }
/** public function removeCaissier(Caissier $caissier): self
* @param Prestataire $caissier
*
* @return $this
*/
public function removeCaissier(Prestataire $caissier): self
{ {
if ($this->caissiers->contains($caissier)) { if ($this->caissiers->removeElement($caissier)) {
$this->caissiers->removeElement($caissier); // set the owning side to null (unless already changed)
if ($caissier->getUser() === $this) {
$caissier->setUser(null);
}
} }
return $this; return $this;
} }
/**
* Set caissier.
*
* @return $this
*/
public function setCaissiers($caissiers): self public function setCaissiers($caissiers): self
{ {
$this->caissiers = $caissiers; $this->caissiers = $caissiers;
......
...@@ -40,20 +40,6 @@ abstract class MoyenEnum ...@@ -40,20 +40,6 @@ abstract class MoyenEnum
} }
/** /**
* Return available type for Comptoir (Vente MLC ou Vente eMLC).
*
* @return array<string>
*/
public static function getAvailableTypesComptoir()
{
return [
self::MOYEN_ESPECE,
self::MOYEN_CHEQUE,
self::MOYEN_AUTRE,
];
}
/**
* Return all available type of moyen. * Return all available type of moyen.
* *
* @return array<string> * @return array<string>
......
...@@ -38,7 +38,7 @@ class LoginListener ...@@ -38,7 +38,7 @@ class LoginListener
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) { if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$this->session->set('_prestagere', $user->getPrestataires()[0]); $this->session->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER', $groupe->getRoles()) && count($user->getCaissiers()) >= 1) { } elseif (in_array('ROLE_CAISSIER', $groupe->getRoles()) && count($user->getCaissiers()) >= 1) {
$this->session->set('_prestagere', $user->getCaissiers()[0]); $this->session->set('_prestagere', $user->getCaissiers()[0]->getPrestataire());
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) { } elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$this->session->set('_comptoirgere', $user->getComptoirsGeres()[0]); $this->session->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) { } elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
......
...@@ -103,7 +103,7 @@ class SwitchUserSubscriber implements EventSubscriberInterface ...@@ -103,7 +103,7 @@ class SwitchUserSubscriber implements EventSubscriberInterface
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) { if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$this->session->set('_prestagere', $user->getPrestataires()[0]); $this->session->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER', $groupe->getRoles()) && count($user->getCaissiers()) >= 1) { } elseif (in_array('ROLE_CAISSIER', $groupe->getRoles()) && count($user->getCaissiers()) >= 1) {
$this->session->set('_prestagere', $user->getCaissiers()[0]); $this->session->set('_prestagere', $user->getCaissiers()[0]->getPrestataire());
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) { } elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$this->session->set('_comptoirgere', $user->getComptoirsGeres()[0]); $this->session->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) { } elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
......
...@@ -82,6 +82,13 @@ class CustomDoctrineORMQuerySourceIterator extends AbstractPropertySourceIterato ...@@ -82,6 +82,13 @@ class CustomDoctrineORMQuerySourceIterator extends AbstractPropertySourceIterato
$firstCotis = $this->cotisationUtils->getFirstCotisationForPresta($presta); $firstCotis = $this->cotisationUtils->getFirstCotisationForPresta($presta);
$firstCotis = is_string($firstCotis) ? new \DateTime( $firstCotis ) : $firstCotis; $firstCotis = is_string($firstCotis) ? new \DateTime( $firstCotis ) : $firstCotis;
$data['Première Cotisation'] = false == $firstCotis ? '' : ($firstCotis->format('d/m/Y')); $data['Première Cotisation'] = false == $firstCotis ? '' : ($firstCotis->format('d/m/Y'));
if ($this->container->getParameter('tav_env')) {
$adresses = [];
foreach ($presta->getGeolocs() as $geoloc) {
$adresses[] = $geoloc ? $geoloc->getFullAddresse() : "";
}
$data['Adresses'] = implode(' - ', $adresses);
}
} elseif (!empty($data['Id']) && !empty($data['Email'])) { } elseif (!empty($data['Id']) && !empty($data['Email'])) {
//adherent //adherent
$adherent = $this->em->getRepository(Adherent::class)->findOneById($data['Id']); $adherent = $this->em->getRepository(Adherent::class)->findOneById($data['Id']);
...@@ -111,6 +118,7 @@ class CustomDoctrineORMQuerySourceIterator extends AbstractPropertySourceIterato ...@@ -111,6 +118,7 @@ class CustomDoctrineORMQuerySourceIterator extends AbstractPropertySourceIterato
if ($this->container->getParameter('ccas_mode')) { if ($this->container->getParameter('ccas_mode')) {
$data['Numéro d\'anonymisation'] = $adherent->getAnonymousToken(); $data['Numéro d\'anonymisation'] = $adherent->getAnonymousToken();
} }
$data["Adresse"] = (string) ($adherent->getGeoloc() ?: '');
} else { } else {
$cotisEnd = $this->cotisationUtils->isCotisationValidForAdherent($adherent); $cotisEnd = $this->cotisationUtils->isCotisationValidForAdherent($adherent);
$cotisEnd = is_string($cotisEnd) ? new \DateTime( $cotisEnd ) : $cotisEnd; $cotisEnd = is_string($cotisEnd) ? new \DateTime( $cotisEnd ) : $cotisEnd;
......
...@@ -5,6 +5,7 @@ namespace App\Form\Type; ...@@ -5,6 +5,7 @@ namespace App\Form\Type;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\DonAdherent; use App\Entity\DonAdherent;
use App\Entity\Prestataire; use App\Entity\Prestataire;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
...@@ -22,10 +23,11 @@ class ComptoirEncaisserDonAdherentFormType extends FluxFormType ...@@ -22,10 +23,11 @@ class ComptoirEncaisserDonAdherentFormType extends FluxFormType
if (empty($this->security) || empty($this->security->getUser())) { if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception('[FORM COMPTOIR ENCAISSEMENT DON ADHERENT] Opération impossible !'); throw new \Exception('[FORM COMPTOIR ENCAISSEMENT DON ADHERENT] Opération impossible !');
} }
$builder $builder
->add('moyen', ChoiceType::class, [ ->add('moyen', ChoiceType::class, [
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(), 'choices' => $this->moyensUtils->getAvailableTypesComptoir(),
'choice_label' => function ($choice) { 'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice); return MoyenEnum::getTypeName($choice);
}, },
......
...@@ -7,35 +7,50 @@ use Symfony\Component\Form\AbstractType; ...@@ -7,35 +7,50 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\GlobalParameter;
class DependentChildFormType extends AbstractType class DependentChildFormType extends AbstractType
{ {
protected $em;
public function __construct(EntityManagerInterface $em) {
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$dependantChildAge = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE);
$builder $builder
->add('olderThanFourteen', ChoiceType::class, array( ->add('olderThanLimitAge', ChoiceType::class, array(
'choices' => [ 'choices' => [
'oui' => true, 'oui' => true,
'non' => false 'non' => false
], ],
'label' => "A-t-il plus de 14 ans ?", 'label' => "A-t-il plus de {$dependantChildAge} ans ?",
'required' => true, 'required' => true,
'expanded' => 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
])
; ;
if ('true' === $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_HOUSEHOLD_USE_SHARED_CUSTODY)) {
$builder
->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',
'oui : je le garde 50 % du temps' => '0.50',
'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) public function configureOptions(OptionsResolver $resolver)
......
...@@ -5,6 +5,7 @@ namespace App\Form\Type; ...@@ -5,6 +5,7 @@ namespace App\Form\Type;
use App\Entity\Flux; use App\Entity\Flux;
use App\Entity\User; use App\Entity\User;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use App\Utils\MoyensUtils;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
...@@ -27,17 +28,20 @@ class FluxFormType extends AbstractType ...@@ -27,17 +28,20 @@ class FluxFormType extends AbstractType
protected $security; protected $security;
protected $container; protected $container;
protected $session; protected $session;
protected $moyensUtils;
public function __construct( public function __construct(
EntityManagerInterface $em, EntityManagerInterface $em,
Security $security, Security $security,
ContainerInterface $container, ContainerInterface $container,
SessionInterface $session SessionInterface $session,
MoyensUtils $moyensUtils
) { ) {
$this->em = $em; $this->em = $em;
$this->security = $security; $this->security = $security;
$this->container = $container; $this->container = $container;
$this->session = $session; $this->session = $session;
$this->moyensUtils = $moyensUtils;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
......
...@@ -4,22 +4,27 @@ namespace App\Form\Type; ...@@ -4,22 +4,27 @@ namespace App\Form\Type;
use App\Entity\Geoloc; use App\Entity\Geoloc;
use App\Entity\Subterritory; use App\Entity\Subterritory;
use App\Entity\GlobalParameter;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType; use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\RouterInterface;
use Doctrine\ORM\EntityManagerInterface;
class GeolocFormType extends AbstractType class GeolocFormType extends AbstractType
{ {
private $router; private $router;
protected $em;
public function __construct(RouterInterface $router) public function __construct(RouterInterface $router, EntityManagerInterface $em)
{ {
$this->router = $router; $this->router = $router;
$this->em = $em;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
...@@ -74,11 +79,29 @@ class GeolocFormType extends AbstractType ...@@ -74,11 +79,29 @@ class GeolocFormType extends AbstractType
; ;
} }
if (true === $options['with_quartier']) { if (true === $options['with_quartier']) {
$builder $quartierListValues = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::GEOLOC_QUARTIER_LIST_VALUES);
->add('quartier', TextType::class, [
'required' => false, if (null !== $quartierListValues && '' !== $quartierListValues) {
]) $quartierListValuesArr = explode(",", $quartierListValues);
; $builder
->add('quartier', ChoiceType::class, [
'choices' => $quartierListValuesArr,
'choice_label' => function ($choice) {
return $choice;
},
'expanded' => false,
'multiple' => false,
'required' => false,
'attr' => ['autocomplete' => 'off']
])
;
} else {
$builder
->add('quartier', TextType::class, [
'required' => false,
])
;
}
} }
if (true === $options['with_subterritory']) { if (true === $options['with_subterritory']) {
$builder $builder
......
...@@ -45,7 +45,7 @@ class PrestataireInfosFormType extends AbstractType ...@@ -45,7 +45,7 @@ class PrestataireInfosFormType extends AbstractType
if ('' !== $caissiers) { if ('' !== $caissiers) {
$caissiers .= ';'; $caissiers .= ';';
} }
$caissiers .= $caissier->getEmail(); $caissiers .= $caissier->getUser()->getEmail();
} }
} }
$builder $builder
......
...@@ -4,6 +4,7 @@ namespace App\Form\Type; ...@@ -4,6 +4,7 @@ namespace App\Form\Type;
use App\Entity\Comptoir; use App\Entity\Comptoir;
use App\Entity\VenteEmlc; use App\Entity\VenteEmlc;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
...@@ -20,10 +21,11 @@ class VenteEmlcFormType extends FluxFormType ...@@ -20,10 +21,11 @@ class VenteEmlcFormType extends FluxFormType
if (empty($this->security) || empty($this->security->getUser())) { if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception('[FORM VENTE EMLC] Opération impossible !'); throw new \Exception('[FORM VENTE EMLC] Opération impossible !');
} }
$builder $builder
->add('moyen', ChoiceType::class, [ ->add('moyen', ChoiceType::class, [
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(), 'choices' => $this->moyensUtils->getAvailableTypesComptoir(),
'choice_label' => function ($choice) { 'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice); return MoyenEnum::getTypeName($choice);
}, },
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Form\Type; namespace App\Form\Type;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum; use App\Enum\MoyenEnum;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
...@@ -13,7 +14,7 @@ class VenteFormType extends TicketFormType ...@@ -13,7 +14,7 @@ class VenteFormType extends TicketFormType
$builder $builder
->add('moyen', ChoiceType::class, [ ->add('moyen', ChoiceType::class, [
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(), 'choices' => $this->moyensUtils->getAvailableTypesComptoir(),
'choice_label' => function ($choice) { 'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice); return MoyenEnum::getTypeName($choice);
}, },
......
...@@ -119,7 +119,7 @@ class AfterLoginRedirection implements AuthenticationSuccessHandlerInterface ...@@ -119,7 +119,7 @@ class AfterLoginRedirection implements AuthenticationSuccessHandlerInterface
if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) { if (in_array('ROLE_PRESTATAIRE', $groupe->getRoles()) && count($user->getPrestataires()) >= 1) {
$this->session->set('_prestagere', $user->getPrestataires()[0]); $this->session->set('_prestagere', $user->getPrestataires()[0]);
} elseif (in_array('ROLE_CAISSIER', $groupe->getRoles()) && count($user->getCaissiers()) >= 1) { } elseif (in_array('ROLE_CAISSIER', $groupe->getRoles()) && count($user->getCaissiers()) >= 1) {
$this->session->set('_prestagere', $user->getCaissiers()[0]); $this->session->set('_prestagere', $user->getCaissiers()[0]->getPrestataire());
} elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) { } elseif (in_array('ROLE_COMPTOIR', $groupe->getRoles()) && count($user->getComptoirsGeres()) >= 1) {
$this->session->set('_comptoirgere', $user->getComptoirsGeres()[0]); $this->session->set('_comptoirgere', $user->getComptoirsGeres()[0]);
} elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) { } elseif ((in_array('ROLE_TRESORIER', $groupe->getRoles()) || in_array('ROLE_CONTACT', $groupe->getRoles()) || in_array('ROLE_GESTION_GROUPE', $groupe->getRoles())) && count($user->getGroupesGeres()) >= 1) {
......
<?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 Version20250411113705 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("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_BASE_AMOUNT', 'Valeur de la part de base dans l\allocation par foyer', '150', '1')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_SECONDARY_AMOUNT', 'Valeur des autres parts dans l\allocation par foyer (e.g. à partir du deuxième adulte, enfants à charge, etc...)', '75', '1')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE', 'Age limite des enfants à charge', '14', '1')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT', 'Si défini, valeur des parts pour les enfants à charge sous la limite d\'age. Si non défini, utilise SSA_HOUSEHOLD_SECONDARY_AMOUNT pour tous les enfants à charge.', null, '0')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_USE_SHARED_CUSTODY', 'Si la valeur est à true, active et prend en compte la garde partagé pour les enfants à charge dans le calcul de l\'allocation', 'true', '0')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT', 'Si une valeur est renseignée, applique la valeur comme plafond de montant d\'allocation dans le calcul', null, '0')");
$this->addSql('ALTER TABLE dependent_child CHANGE older_than_fourteen older_than_limit_age TINYINT(1) NOT NULL');
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_BASE_AMOUNT'");
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_SECONDARY_AMOUNT'");
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE'");
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT'");
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_USE_SHARED_CUSTODY'");
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT'");
$this->addSql('ALTER TABLE dependent_child CHANGE older_than_limit_age older_than_fourteen TINYINT(1) NOT NULL');
// this down() migration is auto-generated, please modify it to your needs
}
}
<?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 Version20250411142610 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("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_COTISATION_MINIMUM', 'Si défini, valeur minimum de cotisation', '10', '0')");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_HOUSEHOLD_COTISATION_MINIMUM'");
// this down() migration is auto-generated, please modify it to your needs
}
}
<?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 Version20250411151039 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("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR', 'Active un set de moyens de paiement disponibles alternatif pour les comptoirs. Par défaut : Espèce, Chèque, Autre. Avec ce paramètre activé : Virement, Espèce, Autre.', 'false', '1')");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR'");
// this down() migration is auto-generated, please modify it to your needs
}
}
<?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 Version20250415103920 extends AbstractMigration
{
public function getDescription() : string
{
return '
For SSA ("tav") projects, configure the presence / absence and content of quartier and subterritory in adherent profile.
At the time this migration is created, subterritory flag has different values in two different project already in production.
This is why we have a rule to decide what should be default value for it.
';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_WITH_QUARTIER', 'Si la valeur est à true, affiche le champ \'Quartier\' dans la fiche Adhérent.', 'true', '0')");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_QUARTIER_LIST_VALUES', 'Si le champ \'Quartier\' est affiché et que ce paramètre est renseigné, affiche le champ sous forme de liste déroulante plutôt que de champ libre. Renseigner les valeurs séparées par une virgule sans espace (ex: Facultés,Hôpitaux,Montpellier Ouest,Gambetta).', '', '0')");
$containerName = trim(file_get_contents('/etc/hostname'));
if (str_contains($containerName, 'ssagironde')) {
$withSubterritoryDefaultValue = 'true';
} else {
$withSubterritoryDefaultValue = 'false';
}
$this->addSql("
INSERT INTO global_parameter (id, name, description, value, mandatory)
VALUES (
UUID(),
'SSA_HOUSEHOLD_WITH_SUBTERRITORY',
'Si la valeur est à true, affiche le champ \'Territoire\' dans la fiche Adhérent.',
'$withSubterritoryDefaultValue',
'0'
)
");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_WITH_QUARTIER'");
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_QUARTIER_LIST_VALUES'");
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_WITH_SUBTERRITORY'");
// this down() migration is auto-generated, please modify it to your needs
}
}
<?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 Version20250417105302 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("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_HOUSEHOLD_COTIS_MINIMUM_BY_SHARE', 'Si la valeur est à true et que SSA_HOUSEHOLD_COTISATION_MINIMUM est défini, active un minimum de cotisation par part plutôt que par foyer. Une part est un montant correspondant à la valeur de SSA_HOUSEHOLD_BASE_AMOUNT, et on calcule le nombre de parts dans le montant d\'allocation prévu (avant application éventuelle de SSA_FORCE_ALLOCATION_AMOUNT ou SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT). Le minimum est alors SSA_HOUSEHOLD_COTISATION_MINIMUM * nb de parts.', null, '0')");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='SSA_HOUSEHOLD_COTIS_MINIMUM_BY_SHARE'");
// this down() migration is auto-generated, please modify it to your needs
}
}
<?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 Version20250418111930 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("UPDATE global_parameter SET name = 'GEOLOC_WITH_QUARTIER' WHERE name = 'SSA_HOUSEHOLD_WITH_QUARTIER'");
$this->addSql("UPDATE global_parameter SET name = 'GEOLOC_QUARTIER_LIST_VALUES' WHERE name = 'SSA_HOUSEHOLD_QUARTIER_LIST_VALUES'");
$this->addSql("UPDATE global_parameter SET name = 'GEOLOC_WITH_SUBTERRITORY' WHERE name = 'SSA_HOUSEHOLD_WITH_SUBTERRITORY'");
}
public function down(Schema $schema) : void
{
$this->addSql("UPDATE global_parameter SET name = 'SSA_HOUSEHOLD_WITH_QUARTIER' WHERE name = 'GEOLOC_WITH_QUARTIER'");
$this->addSql("UPDATE global_parameter SET name = 'SSA_HOUSEHOLD_QUARTIER_LIST_VALUES' WHERE name = 'GEOLOC_QUARTIER_LIST_VALUES'");
$this->addSql("UPDATE global_parameter SET name = 'SSA_HOUSEHOLD_WITH_SUBTERRITORY' WHERE name = 'GEOLOC_WITH_SUBTERRITORY'");
// this down() migration is auto-generated, please modify it to your needs
}
}
<?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 Version20250422095126 extends AbstractMigration
{
public function getDescription() : string
{
return 'Operations related to changing ManyToMany relationship "caissiers" to explicit relation entity "Caissier"';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_caissier DROP FOREIGN KEY FK_FF8E6FC2A76ED395');
$this->addSql('ALTER TABLE user_caissier DROP FOREIGN KEY FK_FF8E6FC2BE3DB2B7');
$this->addSql('ALTER TABLE user_caissier ADD id INT AUTO_INCREMENT NOT NULL, ADD last_transactions_export_datetime DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP PRIMARY KEY, ADD PRIMARY KEY (id)');
$this->addSql('ALTER TABLE user_caissier RENAME TO caissier');
$this->addSql('ALTER TABLE caissier ADD CONSTRAINT FK_1F038BC2A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE caissier ADD CONSTRAINT FK_1F038BC2BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE caissier DROP FOREIGN KEY FK_1F038BC2A76ED395');
$this->addSql('ALTER TABLE caissier DROP FOREIGN KEY FK_1F038BC2BE3DB2B7');
$this->addSql('ALTER TABLE caissier DROP PRIMARY KEY, ADD PRIMARY KEY (prestataire_id, user_id), DROP COLUMN id, DROP COLUMN last_transactions_export_datetime');
$this->addSql('ALTER TABLE caissier RENAME TO user_caissier');
$this->addSql('ALTER TABLE user_caissier ADD CONSTRAINT FK_FF8E6FC2A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE user_caissier ADD CONSTRAINT FK_FF8E6FC2BE3DB2B7 FOREIGN KEY (prestataire_id) REFERENCES prestataire (id)');
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use App\Entity\GlobalParameter;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250502111501 extends AbstractMigration implements ContainerAwareInterface
{
/**
* @var ObjectManager
*/
protected $em;
public function setContainer(ContainerInterface $container = null)
{
$this->em = $container->get('doctrine')->getManager();
}
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
$containerName = trim(file_get_contents('/etc/hostname'));
if (str_contains($containerName, 'casparis20')) {
$defaultValue = 'MOYEN_VIREMENT,MOYEN_ESPECE,MOYEN_AUTRE';
} else {
$defaultValue = 'MOYEN_ESPECE,MOYEN_CHEQUE,MOYEN_AUTRE';
}
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'COMPTOIR_PAYMENT_TYPES', 'Définit la liste des paiements disponible aux comptoirs. Insérer les valeurs désirées dans l\'ordre séparées par une virgule sans espace. Valeurs possibles : MOYEN_CB, MOYEN_ESPECE, MOYEN_CHEQUE, MOYEN_VIREMENT, MOYEN_HELLOASSO, MOYEN_EMLC, MOYEN_MLC, MOYEN_AUTRE.', '$defaultValue', '0')");
$this->addSql("DELETE FROM global_parameter where name='ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR'");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='COMPTOIR_PAYMENT_TYPES'");
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR', 'Active un set de moyens de paiement disponibles alternatif pour les comptoirs. Par défaut : Espèce, Chèque, Autre. Avec ce paramètre activé : Virement, Espèce, Autre.', 'false', '1')");
}
}
<?php
namespace App\Repository;
use App\Entity\Caissier;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Caissier>
*
* @method Caissier|null find($id, $lockMode = null, $lockVersion = null)
* @method Caissier|null findOneBy(array $criteria, array $orderBy = null)
* @method Caissier[] findAll()
* @method Caissier[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CaissierRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Caissier::class);
}
/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function add(Caissier $entity, bool $flush = true): void
{
$this->_em->persist($entity);
if ($flush) {
$this->_em->flush();
}
}
/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function remove(Caissier $entity, bool $flush = true): void
{
$this->_em->remove($entity);
if ($flush) {
$this->_em->flush();
}
}
// /**
// * @return Caissier[] Returns an array of Caissier objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->orderBy('c.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Caissier
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
...@@ -177,19 +177,27 @@ class FluxRepository extends ServiceEntityRepository ...@@ -177,19 +177,27 @@ class FluxRepository extends ServiceEntityRepository
} }
/** /**
* @param Prestataire $presta * @param User $user operator of the flux
* @param bool $onlySameDay * @param Prestataire $presta
* @param string $from Date from which to fetch the flux
* *
* @return Query Returns a query fo finding an array of Flux * @return Query Returns a query fo finding an array of Flux
*/ */
public function getQueryByCaissier(Prestataire $presta, $onlySameDay = true) public function getQueryByCaissier(User $user, Prestataire $presta, $from = true)
{ {
$sqlQuery = "SELECT f.id FROM {$this->tableName} f WHERE ((f.type = 'adherent_prestataire' AND f.prestataire_id = :id) OR (f.type = 'prestataire_prestataire' AND f.prestataire_dest_id = :id))"; $sqlQuery = "SELECT f.id FROM {$this->tableName} f";
if ($onlySameDay) { $sqlQuery .= " WHERE ((f.type = 'adherent_prestataire' AND f.prestataire_id = :pid) OR (f.type = 'prestataire_prestataire' AND f.prestataire_dest_id = :pid))";
$sqlQuery .= ' AND DATE(f.created_at) = CURDATE()'; $sqlQuery .= " AND f.user_id = :cid"; // set operateur
if ($from != null) {
$sqlQuery .= " AND f.created_at >= :from";
} }
$statement = $this->connection->prepare($sqlQuery); $statement = $this->connection->prepare($sqlQuery);
$statement->bindValue(':id', $presta->getId()); $statement->bindValue(':pid', $presta->getId());
$statement->bindValue(':cid', $user->getId());
if ($from != null) {
$statement->bindValue(':from', $from);
}
$statement->execute(); $statement->execute();
$results = $statement->fetchAll(); $results = $statement->fetchAll();
$qb = $this->createQueryBuilder('f'); $qb = $this->createQueryBuilder('f');
......
...@@ -7,6 +7,7 @@ use App\Entity\AchatMonnaieAConfirmerPrestataire; ...@@ -7,6 +7,7 @@ use App\Entity\AchatMonnaieAConfirmerPrestataire;
use App\Entity\AchatMonnaieAdherent; use App\Entity\AchatMonnaieAdherent;
use App\Entity\AchatMonnaiePrestataire; use App\Entity\AchatMonnaiePrestataire;
use App\Entity\Adherent; use App\Entity\Adherent;
use App\Entity\Caissier;
use App\Entity\Comptoir; use App\Entity\Comptoir;
use App\Entity\CotisationAdherent; use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire; use App\Entity\CotisationPrestataire;
...@@ -106,7 +107,7 @@ class AppExtension extends AbstractExtension ...@@ -106,7 +107,7 @@ class AppExtension extends AbstractExtension
new \Twig_SimpleFunction('getPaymentReceiptUrlFromFlux', [$this, 'getPaymentReceiptUrlFromFlux']), new \Twig_SimpleFunction('getPaymentReceiptUrlFromFlux', [$this, 'getPaymentReceiptUrlFromFlux']),
new \Twig_SimpleFunction('getDonType', [$this, 'getDonType']), new \Twig_SimpleFunction('getDonType', [$this, 'getDonType']),
new \Twig_SimpleFunction('getLastTavCotisationForAdherent', [$this, 'getLastTavCotisationForAdherent']), new \Twig_SimpleFunction('getLastTavCotisationForAdherent', [$this, 'getLastTavCotisationForAdherent']),
new \Twig_SimpleFunction('getPrestaLastTransactionsExportDate', [$this, 'getPrestaLastTransactionsExportDate']), new \Twig_SimpleFunction('getCaissierLastTransactionsExportDate', [$this, 'getCaissierLastTransactionsExportDate']),
new \Twig_SimpleFunction('checkExistingRecurringPayment', [$this, 'checkExistingRecurringPayment']), new \Twig_SimpleFunction('checkExistingRecurringPayment', [$this, 'checkExistingRecurringPayment']),
new \Twig_SimpleFunction('parameter', function ($name) { new \Twig_SimpleFunction('parameter', function ($name) {
return $this->container->getParameter($name); return $this->container->getParameter($name);
...@@ -478,7 +479,7 @@ class AppExtension extends AbstractExtension ...@@ -478,7 +479,7 @@ class AppExtension extends AbstractExtension
if ($this->security->isGranted('ROLE_PRESTATAIRE')) { if ($this->security->isGranted('ROLE_PRESTATAIRE')) {
$query = $this->em->getRepository(Flux::class)->getQueryByPrestataire($this->session->get('_prestagere'), $parenttype); $query = $this->em->getRepository(Flux::class)->getQueryByPrestataire($this->session->get('_prestagere'), $parenttype);
} elseif ($this->security->isGranted('ROLE_CAISSIER')) { } elseif ($this->security->isGranted('ROLE_CAISSIER')) {
$query = $this->em->getRepository(Flux::class)->getQueryByCaissier($this->session->get('_prestagere')); $query = $this->em->getRepository(Flux::class)->getQueryByCaissier($user, $this->session->get('_prestagere'));
} }
} elseif (null != $user->getAdherent()) { } elseif (null != $user->getAdherent()) {
$query = $this->em->getRepository(Flux::class)->getQueryByAdherent($user->getAdherent(), $parenttype); $query = $this->em->getRepository(Flux::class)->getQueryByAdherent($user->getAdherent(), $parenttype);
...@@ -549,15 +550,17 @@ class AppExtension extends AbstractExtension ...@@ -549,15 +550,17 @@ class AppExtension extends AbstractExtension
return str_replace('@', '&#64;', $email); return str_replace('@', '&#64;', $email);
} }
public function getPrestaLastTransactionsExportDate(?Adherent $adherent = null) public function getCaissierLastTransactionsExportDate(?Adherent $adherent = null)
{ {
if (!$this->session->has('_prestagere')) { if (!$this->session->has('_prestagere')) {
return null; return null;
} }
$presta = $this->em->getRepository(Prestataire::class)->findOneById($this->session->get('_prestagere')->getId()); $presta = $this->em->getRepository(Prestataire::class)->findOneById($this->session->get('_prestagere')->getId());
$user = $this->security->getUser();
$caissier = $this->em->getRepository(Caissier::class)->findOneBy(['prestataire' => $presta, 'user' => $user]);
$datetime_last_export = $presta->getLastTransactionsExportDatetime(); $datetime_last_export = $caissier->getLastTransactionsExportDatetime();
$res = ""; $res = "";
if (null == $datetime_last_export) { if (null == $datetime_last_export) {
......
<?php
namespace App\Utils;
use App\Entity\GlobalParameter;
use App\Utils\CustomEntityManager;
use App\Enum\MoyenEnum;
class MoyensUtils
{
private $em;
public function __construct(CustomEntityManager $em) {
$this->em = $em;
}
/**
* Return available payment types for Comptoir from configuration param value.
*
* @return array<string>
*/
public function getAvailableTypesComptoir()
{
$paymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::COMPTOIR_PAYMENT_TYPES);
if (null == $paymentTypes) {
return $this->getDefaultAvailableTypesComptoir();
}
$paymentTypesArr = explode(",", $paymentTypes);
try {
$res = array_map(function ($val) {
return constant("App\\Enum\\MoyenEnum::$val");
}, $paymentTypesArr);
} catch (\Exception $e) {
// Error in parameter definition
$res = $this->getDefaultAvailableTypesComptoir();
}
return $res;
}
public function getDefaultAvailableTypesComptoir() {
return [
MoyenEnum::MOYEN_ESPECE,
MoyenEnum::MOYEN_CHEQUE,
MoyenEnum::MOYEN_AUTRE,
];
}
}
\ No newline at end of file
...@@ -171,52 +171,98 @@ class TAVCotisationUtils ...@@ -171,52 +171,98 @@ class TAVCotisationUtils
} }
/** /**
* Second method to calculate allowance: * Calculate & return allowance value in household mode.
* allowance based on user's household.
* *
* Rules are as follow: * Rules are as follow:
* - 150 emlc for the first person in user's household * - [SSA_HOUSEHOLD_BASE_AMOUNT] emlc for the first person in user's household
* - 75 emlc for each other adult * - [SSA_HOUSEHOLD_SECONDARY_AMOUNT] emlc for each other adult
* - 75 emlc amount for each dependant child, with a percentage applied if the child is in shared custody: * - [SSA_HOUSEHOLD_SECONDARY_AMOUNT] emlc for each dependant child above [SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE]
* 25%, 50% or 75% depending on the shared custody arrangement * - if SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT is defined:
* [SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT] emlc for each dependant child under [SSA_HOUSEHOLD_DEPENDANT_CHILD_LIMIT_AGE]
* else
* [SSA_HOUSEHOLD_SECONDARY_AMOUNT] for all dependant child
* - if SSA_HOUSEHOLD_USE_SHARED_CUSTODY is true:
* apply a percentage if the child is in shared custody: 25%, 50% or 75% depending on the shared custody arrangement
*
* @param Adherent $adherent
*/
public function getCalculatedHouseholdAllowanceValue($adherent) {
$adultsCount = $adherent->getHouseholdAdultCount();
if ($adultsCount == null) {
return null;
}
// base allowance, for the first adult
$mlcAllowanceAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_BASE_AMOUNT);
// Get amount for the other houshold members
$mclSecondaryAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_SECONDARY_AMOUNT);
// increment for each other adult in the household
$mlcAllowanceAmount += $mclSecondaryAmount * ($adultsCount - 1);
// increment allowance for each dependant child, depending on the shared custody arrangement
$useSharedCustody = $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_USE_SHARED_CUSTODY);
$childUnderLimitAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT);
$dependentChildren = $adherent->getDependentChildren();
foreach ($dependentChildren as $child) {
$childAllowanceAmount = $mclSecondaryAmount;
// Different value for children under limit age, if activated
if (false === $child->getOlderThanLimitAge() && null !== $childUnderLimitAmount) {
$childAllowanceAmount = (int) $childUnderLimitAmount;
}
// Apply shared custody percentage if activated and set
if ('true' === $useSharedCustody) {
$sharedCustodyPercentage = $child->getSharedCustodyPercentage();
if ($sharedCustodyPercentage != null) {
$childAllowanceAmount = $childAllowanceAmount * $sharedCustodyPercentage;
}
}
$mlcAllowanceAmount += $childAllowanceAmount;
}
return $mlcAllowanceAmount;
}
/**
* Second method to calculate allowance:
* allowance based on user's household.
* *
* Once the full amount is calculated, cap user's balance. * See @getCalculatedHouseholdAllowanceValue() for calculations implentation without verifications
* User account balance is capped at twice the amount previously calculated.
* *
* @param Adherent $adherent (by ref) * @param Adherent $adherent (by ref)
*/ */
public function calculateAllowanceAccordingToHousehold(&$adherent) { public function calculateAllowanceAccordingToHousehold(&$adherent) {
// TODO base amounts to param in .env, or in global params ? // If forced amount activated, set value
$forcedAmount = (int) $this->em->getRepository(GlobalParameter::class) $forcedAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_FORCE_ALLOCATION_AMOUNT); ->val(GlobalParameter::SSA_FORCE_ALLOCATION_AMOUNT);
if($forcedAmount > 0) { if($forcedAmount > 0) {
$adherent->setAllocationAmount($forcedAmount); $adherent->setAllocationAmount($forcedAmount);
return; return;
} }
// base allowance, for one adult // Calculation
$mlcAllowanceAmount = 150; $mlcAllowanceAmount = $this->getCalculatedHouseholdAllowanceValue($adherent);
$adultsCount = $adherent->getHouseholdAdultCount(); // Null returned in case of missing necessary param: exit
if ($adultsCount == null) { if ($mlcAllowanceAmount === null) {
return; return;
} }
// increment for each other adult in the household // Apply cap if activated in configuration
$mlcAllowanceAmount += 75 * ($adultsCount - 1); $maxAllocationAmount = $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT);
// increment allowance for each dependant child, depending on the shared custody arrangement
$dependentChildren = $adherent->getDependentChildren();
foreach ($dependentChildren as $child) {
$childAllowanceAmount = 75;
$sharedCustodyPercentage = $child->getSharedCustodyPercentage(); if (null !== $maxAllocationAmount && 0 !== intval($maxAllocationAmount) && $mlcAllowanceAmount > intval($maxAllocationAmount)) {
if ($sharedCustodyPercentage != null) { $mlcAllowanceAmount = intval($maxAllocationAmount);
$childAllowanceAmount = $childAllowanceAmount * $sharedCustodyPercentage;
}
$mlcAllowanceAmount += $childAllowanceAmount;
} }
$adherent->setAllocationAmount($mlcAllowanceAmount); $adherent->setAllocationAmount($mlcAllowanceAmount);
......
...@@ -27,6 +27,7 @@ Modified for MLC from Sonata package. ...@@ -27,6 +27,7 @@ Modified for MLC from Sonata package.
<head> <head>
<title>{{title|default('Kohinos') }}</title> <title>{{title|default('Kohinos') }}</title>
<meta name="is-tav-env" content="{{ tav_env }}" /> <meta name="is-tav-env" content="{{ tav_env }}" />
<meta name="is-household-based-allowance" content="{{ household_based_allowance }}" />
<meta name="description" content="{{ description|default('Kohinos : Outil de gestion de monnaie locale complémentaire') }}" /> <meta name="description" content="{{ description|default('Kohinos : Outil de gestion de monnaie locale complémentaire') }}" />
<meta name="keywords" content="{{ keywords|default('Kohinos, mlc, mlcc, monnaie locale, monnaies locales') }}" /> <meta name="keywords" content="{{ keywords|default('Kohinos, mlc, mlcc, monnaie locale, monnaies locales') }}" />
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
</div> </div>
{% endfor %} {% endfor %}
{% elseif role == 'ROLE_CAISSIER' %} {% elseif role == 'ROLE_CAISSIER' %}
{% for presta in app.user.caissiers %} {% for caissier in app.user.caissiers %}
<div class='col-6 text-center p-2'> <div class='col-6 text-center p-2'>
<a role="button" class="btn btn-default btn-secondary" href='{{path('presta_choice', {'prestaid' : presta.id, 'usergrpid': group.id})}}'>{{ group.name|trans }} - {{presta}} </a> <a role="button" class="btn btn-default btn-secondary" href='{{path('caissier_choice', {'caissierid' : caissier.id, 'usergrpid': group.id})}}'>{{ group.name|trans }} - {{caissier.prestataire}} </a>
</div> </div>
{% endfor %} {% endfor %}
{% elseif role == 'ROLE_COMPTOIR' %} {% elseif role == 'ROLE_COMPTOIR' %}
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
<i class="fa fa-list-alt mr-4"></i> {{'Transactions'|trans }} <i class="fa fa-list-alt mr-4"></i> {{'Transactions'|trans }}
{% endblock blocktitle %} {% endblock blocktitle %}
{% block blockcontent %} {% block blockcontent %}
{% set datetime_last_export = getPrestaLastTransactionsExportDate() %} {% set datetime_last_export = getCaissierLastTransactionsExportDate() %}
<p>Récupérer le montant total des transactions (hors reconversions) depuis le <b>{{ datetime_last_export }}</b></p> <p>Récupérer le montant total des transactions opérées par ce compte Caissier (hors reconversions) depuis le <b>{{ datetime_last_export }}</b></p>
<a class='btn btn-xs btn-primary mt-2' href='{{ path('get_presta_last_transactions') }}'> <a class='btn btn-xs btn-primary mt-2' href='{{ path('get_caissier_last_transactions') }}'>
{{ 'Exporter'|trans }} {{ 'Exporter'|trans }}
</a> </a>
{% endblock blockcontent %} {% endblock blockcontent %}
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