Commit e03379b1 by Damien Moulard

add param to set or not a cotisation minimum

parent c447632f
...@@ -329,11 +329,11 @@ class AdherentAdmin extends AbstractAdmin ...@@ -329,11 +329,11 @@ class AdherentAdmin extends AbstractAdmin
$maxAllocationAmount = $em->getRepository(GlobalParameter::class) $maxAllocationAmount = $em->getRepository(GlobalParameter::class)
->val(GlobalParameter::SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT); ->val(GlobalParameter::SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT);
if (null !== $maxAllocationAmount && '' !== $maxAllocationAmount) { $allowanceCalculationLimitationMsg = (null !== $maxAllocationAmount) ? " dans la limite de {$maxAllocationAmount} {$mlc}" : '';
$allowanceCalculationLimitationMsg = " dans la limite de {$maxAllocationAmount} {$mlc}";
} else { $minCotisationAmount = $em->getRepository(GlobalParameter::class)
$allowanceCalculationLimitationMsg = ''; ->val(GlobalParameter::SSA_HOUSEHOLD_COTISATION_MINIMUM);
} $minCotisationMsg = (null !== $minCotisationAmount) ? "Montant minimum : {$minCotisationAmount}€ par foyer." : '';
// Add cotisation info // Add cotisation info
$formMapper $formMapper
...@@ -344,7 +344,7 @@ class AdherentAdmin extends AbstractAdmin ...@@ -344,7 +344,7 @@ 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, [
...@@ -559,15 +559,12 @@ class AdherentAdmin extends AbstractAdmin ...@@ -559,15 +559,12 @@ 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 && $adherent->getCotisationAmount() < (int) $minCotisationAmount) {
$event->getForm()->get('cotisationAmount')->addError(new FormError('Champ invalide'));
if ($adherent->getCotisationAmount() < $minCotisationAmount) {
$event->getForm()->get('cotisationAmount')->addError(new FormError('Le montant minimum est de ' . $minCotisationAmount . '€ (selon les données du foyer indiquées)'));
}
} }
// try to fix balance if required // try to fix balance if required
......
...@@ -67,6 +67,7 @@ class GlobalParameter ...@@ -67,6 +67,7 @@ class GlobalParameter
const SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT = 'SSA_HOUSEHOLD_DEPENDANT_CHILD_UNDER_LIMIT_AMOUNT'; 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_USE_SHARED_CUSTODY = 'SSA_HOUSEHOLD_USE_SHARED_CUSTODY';
const SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT = 'SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT'; const SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT = 'SSA_HOUSEHOLD_MAX_ALLOCATION_AMOUNT';
const SSA_HOUSEHOLD_COTISATION_MINIMUM = 'SSA_HOUSEHOLD_COTISATION_MINIMUM';
/** /**
* @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 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
}
}
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