Commit 0ce5691f by Damien Moulard

Merge branch 'decide-fixed-allocation-amount' into 'develop'

Decide fixed allocation amount

See merge request !136
parents b95ceb37 19be463e
......@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Entity\GlobalParameter;
use App\Utils\CustomEntityManager;
use App\Utils\TAVCotisationUtils;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
......@@ -69,7 +70,14 @@ class AdherentAdminController extends CRUDController
$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($forcedAmount > 0) {
$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"))
->andWhere($qb->expr()->isNotNull("a.cotisationAmount"))
->getQuery()
......
......@@ -60,6 +60,7 @@ class GlobalParameter
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_DISABLE_COTISATION = 'SSA_DISABLE_COTISATION';
const SSA_FORCE_ALLOCATION_AMOUNT = 'SSA_FORCE_ALLOCATION_AMOUNT';
/**
* @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 à l\'entier positif saisi. Saisir 0 pour désactiver. Attention : pour que le montant soit bien pris en compte, veuillez effectuer l\'action \"Recalculer les allocations en fonction du foyer\" sur l\'écran de la liste des adhérents.',
'0',
'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;
use App\Entity\CotisationTavPrelevementCorrectionSolde;
use App\Entity\CotisationTavPrelevementDepassementPlafond;
use App\Entity\CotisationTavReversementCorrectionSolde;
use App\Entity\GlobalParameter;
use App\Entity\Payment;
use App\Entity\Siege;
use App\Entity\Flux;
......@@ -187,6 +188,13 @@ class TAVCotisationUtils
public function calculateAllowanceAccordingToHousehold(&$adherent) {
// 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($forcedAmount > 0) {
$adherent->setAllocationAmount($forcedAmount);
return;
}
// base allowance, for one adult
$mlcAllowanceAmount = 150;
......@@ -224,6 +232,14 @@ class TAVCotisationUtils
* 4+ person: 220 emlc
*/
public function calculateAllowanceAccordingToHouseholdSimplified(&$adherent) {
$forcedAmount = (int) $this->em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_FORCE_ALLOCATION_AMOUNT);
if($forcedAmount > 0) {
$adherent->setAllocationAmount($forcedAmount);
return;
}
$householdCount = $adherent->getHouseholdCount();
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