Commit bd02beeb by Yvon Kerdoncuff

add param to decide fixed allocation amount and use it in recalculations

parent c73e439b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\GlobalParameter;
use App\Utils\CustomEntityManager; use App\Utils\CustomEntityManager;
use App\Utils\TAVCotisationUtils; use App\Utils\TAVCotisationUtils;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
...@@ -69,7 +70,14 @@ class AdherentAdminController extends CRUDController ...@@ -69,7 +70,14 @@ class AdherentAdminController extends CRUDController
$qb = $this->em->getRepository(Adherent::class)->createQueryBuilder('a'); $qb = $this->em->getRepository(Adherent::class)->createQueryBuilder('a');
if ($this->getParameter('simplified_household_based_allowance')) { $forcedAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_FORCE_ALLOCATION_AMOUNT);
if(is_int($forcedAmount)) {
$adherents = $qb->getQuery()->getResult();
foreach ($adherents as $adherent) {
$adherent->setAllocationAmount($forcedAmount);
}
} else if ($this->getParameter('simplified_household_based_allowance')) {
$adherents = $qb->where($qb->expr()->isNotNull("a.householdCount")) $adherents = $qb->where($qb->expr()->isNotNull("a.householdCount"))
->andWhere($qb->expr()->isNotNull("a.cotisationAmount")) ->andWhere($qb->expr()->isNotNull("a.cotisationAmount"))
->getQuery() ->getQuery()
......
...@@ -60,6 +60,7 @@ class GlobalParameter ...@@ -60,6 +60,7 @@ class GlobalParameter
const ACTIVATE_ADHERENTS_BALANCE_CEILING = 'ACTIVATE_ADHERENTS_BALANCE_CEILING'; const ACTIVATE_ADHERENTS_BALANCE_CEILING = 'ACTIVATE_ADHERENTS_BALANCE_CEILING';
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';
/** /**
* @var \Ramsey\Uuid\UuidInterface * @var \Ramsey\Uuid\UuidInterface
* *
......
<?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 Version20250317150730 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_FORCE_ALLOCATION_AMOUNT',
'Le montant d\'allocation est forcé égal au nombre entier saisi. Effacer pour désactiver.',
'',
'0'
)
");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='SSA_FORCE_ALLOCATION_AMOUNT'");
// this down() migration is auto-generated, please modify it to your needs
}
}
...@@ -6,6 +6,7 @@ use App\Entity\Adherent; ...@@ -6,6 +6,7 @@ use App\Entity\Adherent;
use App\Entity\CotisationTavPrelevementCorrectionSolde; use App\Entity\CotisationTavPrelevementCorrectionSolde;
use App\Entity\CotisationTavPrelevementDepassementPlafond; use App\Entity\CotisationTavPrelevementDepassementPlafond;
use App\Entity\CotisationTavReversementCorrectionSolde; use App\Entity\CotisationTavReversementCorrectionSolde;
use App\Entity\GlobalParameter;
use App\Entity\Payment; use App\Entity\Payment;
use App\Entity\Siege; use App\Entity\Siege;
use App\Entity\Flux; use App\Entity\Flux;
...@@ -187,6 +188,13 @@ class TAVCotisationUtils ...@@ -187,6 +188,13 @@ class TAVCotisationUtils
public function calculateAllowanceAccordingToHousehold(&$adherent) { public function calculateAllowanceAccordingToHousehold(&$adherent) {
// TODO base amounts to param in .env, or in global params ? // TODO base amounts to param in .env, or in global params ?
$forcedAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_FORCE_ALLOCATION_AMOUNT);
if(is_int($forcedAmount)) {
$adherent->setAllocationAmount($forcedAmount);
return;
}
// base allowance, for one adult // base allowance, for one adult
$mlcAllowanceAmount = 150; $mlcAllowanceAmount = 150;
...@@ -224,6 +232,14 @@ class TAVCotisationUtils ...@@ -224,6 +232,14 @@ class TAVCotisationUtils
* 4+ person: 220 emlc * 4+ person: 220 emlc
*/ */
public function calculateAllowanceAccordingToHouseholdSimplified(&$adherent) { public function calculateAllowanceAccordingToHouseholdSimplified(&$adherent) {
$forcedAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_FORCE_ALLOCATION_AMOUNT);
if(is_int($forcedAmount)) {
$adherent->setAllocationAmount($forcedAmount);
return;
}
$householdCount = $adherent->getHouseholdCount(); $householdCount = $adherent->getHouseholdCount();
if (is_null($householdCount) || $householdCount == 0) { if (is_null($householdCount) || $householdCount == 0) {
......
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