feat: page admin tarification + TarificationService + champs PriceAutomatic

src/Entity/PriceAutomatic.php:
- type: ajout contrainte unique pour eviter les doublons
- monthPrice: decimal(10,2) default 0.00, prix mensuel recurrent
- period: smallint default 1, duree de la periode en mois
  (1=mensuel, 3=trimestriel, 12=annuel)
- stripeId: string nullable, ID du Stripe Price pour le paiement unique
- stripeAbonnementId: string nullable, ID du Stripe Price pour l'abonnement

src/Service/TarificationService.php (nouveau):
- Constante DEFAULT_PRICES avec 16 tarifs par defaut:
  esyweb_business (500€ + 100€/mois), esyweb_premium (3200€ + 100€/mois),
  ecommerce_business (999€ + 150€/mois), ecommerce_premium (5110€ + 150€/mois),
  esymail (50€ + 30€/mois), esymailer (50€ + 30€/mois),
  esydefender_pro (50€ + 60€/mois periode 3), esymeet (50€ + 30€/mois),
  esytchat (50€ + 15€/mois), esycreator (500€ + 100€/mois periode 3),
  ndd_depot (20€), ndd_renouvellement (20€/an), ndd_gestion (30€/an),
  ndd_reactivation (50€), formation_pack10h (500€), formation_heure (70€)
- ensureDefaultPrices(): verifie les tarifs existants, cree ceux manquants
- getAll(), getByType(), getDefaultTypes()

src/Controller/Admin/TarificationController.php (nouveau):
- Route /admin/tarification, ROLE_ROOT
- index(): appelle ensureDefaultPrices() pour creer les tarifs manquants
  automatiquement a chaque visite, affiche tous les tarifs editables
- edit(): met a jour titre, description, prixHt, monthPrice, period,
  stripeId, stripeAbonnementId via formulaire POST

templates/admin/tarification/index.html.twig (nouveau):
- Liste de tous les tarifs sous forme de cards glassmorphism
- Header dark avec titre, type (badge) et prix
- Formulaire d'edition inline: titre, prix unique, prix mensuel,
  periode (select 1/2/3/6/12 mois), Stripe Price ID unique,
  Stripe Price ID abonnement, description (textarea)
- Bouton enregistrer par tarif

templates/admin/_layout.html.twig:
- Ajout lien "Tarification" dans la sidebar Super Admin avec icone dollar

migrations/Version20260402204223.php:
- Ajout colonnes month_price, period, stripe_id, stripe_abonnement_id
  sur price_automatic + index unique sur type

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-02 22:42:43 +02:00
parent 8136475356
commit 32aa5b0d78
6 changed files with 410 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?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 Version20260402204223 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('ALTER TABLE price_automatic ADD month_price NUMERIC(10, 2) DEFAULT \'0.00\' NOT NULL');
$this->addSql('ALTER TABLE price_automatic ADD period SMALLINT DEFAULT 1 NOT NULL');
$this->addSql('ALTER TABLE price_automatic ADD stripe_id VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE price_automatic ADD stripe_abonnement_id VARCHAR(255) DEFAULT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_FAD167EC8CDE5729 ON price_automatic (type)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_FAD167EC8CDE5729');
$this->addSql('ALTER TABLE price_automatic DROP month_price');
$this->addSql('ALTER TABLE price_automatic DROP period');
$this->addSql('ALTER TABLE price_automatic DROP stripe_id');
$this->addSql('ALTER TABLE price_automatic DROP stripe_abonnement_id');
}
}