Commit f9011a4e by Yvon Kerdoncuff

Merge branch '7920-alternate-comptoir-payment-types' into 'develop'

7920 alternate comptoir payment types

See merge request !141
parents 5a776250 aae688ed
...@@ -68,6 +68,8 @@ class GlobalParameter ...@@ -68,6 +68,8 @@ class GlobalParameter
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'; const SSA_HOUSEHOLD_COTISATION_MINIMUM = 'SSA_HOUSEHOLD_COTISATION_MINIMUM';
const ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR = 'ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR';
/** /**
* @var \Ramsey\Uuid\UuidInterface * @var \Ramsey\Uuid\UuidInterface
* *
...@@ -137,7 +139,7 @@ class GlobalParameter ...@@ -137,7 +139,7 @@ class GlobalParameter
return $this->value; return $this->value;
} }
public function setValue(?string $value): self public function setValue(string $value): self
{ {
$this->value = $value; $this->value = $value;
......
...@@ -40,7 +40,7 @@ abstract class MoyenEnum ...@@ -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> * @return array<string>
*/ */
...@@ -54,6 +54,21 @@ abstract class MoyenEnum ...@@ -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 all available type of moyen.
* *
* @return array<string> * @return array<string>
......
...@@ -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,12 @@ class ComptoirEncaisserDonAdherentFormType extends FluxFormType ...@@ -22,10 +23,12 @@ 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 !');
} }
$alternatePaymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR);
$builder $builder
->add('moyen', ChoiceType::class, [ ->add('moyen', ChoiceType::class, [
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(), 'choices' => ('true' === $alternatePaymentTypes) ? MoyenEnum::getAlternateAvailableTypesComptoir() : MoyenEnum::getAvailableTypesComptoir(),
'choice_label' => function ($choice) { 'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($choice); return MoyenEnum::getTypeName($choice);
}, },
......
...@@ -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,12 @@ class VenteEmlcFormType extends FluxFormType ...@@ -20,10 +21,12 @@ 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 !');
} }
$alternatePaymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR);
$builder $builder
->add('moyen', ChoiceType::class, [ ->add('moyen', ChoiceType::class, [
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(), 'choices' => ('true' === $alternatePaymentTypes) ? MoyenEnum::getAlternateAvailableTypesComptoir() : MoyenEnum::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;
...@@ -10,10 +11,11 @@ class VenteFormType extends TicketFormType ...@@ -10,10 +11,11 @@ class VenteFormType extends TicketFormType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$alternatePaymentTypes = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::ALTERNATE_AVAILABLE_PAYMENT_TYPES_COMPTOIR);
$builder $builder
->add('moyen', ChoiceType::class, [ ->add('moyen', ChoiceType::class, [
'required' => true, 'required' => true,
'choices' => MoyenEnum::getAvailableTypesComptoir(), 'choices' => ('true' === $alternatePaymentTypes) ? MoyenEnum::getAlternateAvailableTypesComptoir() : MoyenEnum::getAvailableTypesComptoir(),
'choice_label' => function ($choice) { 'choice_label' => function ($choice) {
return MoyenEnum::getTypeName($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. 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
}
}
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