Commit fc9d8658 by Damien Moulard

add param to activate an alternate set of payment types available to comptoirs

parent 3b0eeba8
......@@ -61,6 +61,8 @@ 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_DISABLE_COTISATION = 'SSA_DISABLE_COTISATION';
const SSA_FORCE_ALLOCATION_AMOUNT = 'SSA_FORCE_ALLOCATION_AMOUNT';
const ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR = 'ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR';
/**
* @var \Ramsey\Uuid\UuidInterface
*
......
......@@ -40,7 +40,7 @@ abstract class MoyenEnum
}
/**
* Return available type for Comptoir (Vente MLC ou Vente eMLC).
* Return available type for Comptoir.
*
* @return array<string>
*/
......@@ -54,6 +54,21 @@ abstract class MoyenEnum
}
/**
* Return another set of available types for Comptoir.
* For Comptoirs not accepting checks
*
* @return array<string>
*/
public static function getAlternateAvailableTypesComptoir()
{
return [
self::MOYEN_VIREMENT,
self::MOYEN_ESPECE,
self::MOYEN_AUTRE,
];
}
/**
* Return all available type of moyen.
*
* @return array<string>
......
......@@ -5,6 +5,7 @@ namespace App\Form\Type;
use App\Entity\Adherent;
use App\Entity\DonAdherent;
use App\Entity\Prestataire;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
......@@ -22,10 +23,12 @@ class ComptoirEncaisserDonAdherentFormType extends FluxFormType
if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception('[FORM COMPTOIR ENCAISSEMENT DON ADHERENT] Opération impossible !');
}
$alternatePaymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR);
$builder
->add('moyen', ChoiceType::class, [
'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(),
'choices' => ('true' === $alternatePaymentTypes) ? MoyenEnum::getAlternateAvailableTypesComptoir() : MoyenEnum::getAvailableTypesComptoir(),
'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice);
},
......
......@@ -4,6 +4,7 @@ namespace App\Form\Type;
use App\Entity\Comptoir;
use App\Entity\VenteEmlc;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
......@@ -20,10 +21,12 @@ class VenteEmlcFormType extends FluxFormType
if (empty($this->security) || empty($this->security->getUser())) {
throw new \Exception('[FORM VENTE EMLC] Opération impossible !');
}
$alternatePaymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR);
$builder
->add('moyen', ChoiceType::class, [
'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(),
'choices' => ('true' === $alternatePaymentTypes) ? MoyenEnum::getAlternateAvailableTypesComptoir() : MoyenEnum::getAvailableTypesComptoir(),
'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice);
},
......
......@@ -2,6 +2,7 @@
namespace App\Form\Type;
use App\Entity\GlobalParameter;
use App\Enum\MoyenEnum;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
......@@ -10,10 +11,11 @@ class VenteFormType extends TicketFormType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$alternatePaymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR);
$builder
->add('moyen', ChoiceType::class, [
'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(),
'choices' => ('true' === $alternatePaymentTypes) ? MoyenEnum::getAlternateAvailableTypesComptoir() : MoyenEnum::getAvailableTypesComptoir(),
'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice);
},
......
<?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.', 'false', '1')");
}
public function down(Schema $schema) : void
{
$this->addSql("DELETE FROM global_parameter where name='SSA_DISABLE_COTISATION'");
// 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