feat: financial data check for teamers, improved enforced checks logic

addresses #869at5rtp
This commit is contained in:
Björn Fromme
2026-08-10 18:06:25 +02:00
parent fd5d478a5c
commit 388ecf9603
22 changed files with 1196 additions and 195 deletions
@@ -0,0 +1,62 @@
<?php
namespace App\Controller\Teamer\Check;
use App\Entity\Teamer;
use App\Entity\User;
use App\Form\FinancialDataType;
use App\Model\FinancialDataDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class FinancialDataController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger,
) {
}
#[Route('/teamer/check/financial-data', name: 'app_teamer_check_financial_data')]
#[IsGranted('ROLE_TEAMER')]
public function index(Request $request): Response
{
/** @var User $user */
$user = $this->getUser();
$teamer = $user->getTeamer();
if (null === $teamer) {
$teamer = new Teamer();
$user->setTeamer($teamer);
$this->entityManager->persist($teamer);
$this->entityManager->flush();
}
$formData = FinancialDataDto::fromTeamer($teamer);
$form = $this->createForm(FinancialDataType::class, $formData);
$form->handleRequest($request);
if (true === $form->isSubmitted() && true === $form->isValid()) {
$formData->applyTo($teamer);
$this->entityManager->flush();
$this->addFlash('success', 'Deine Angaben wurden gespeichert.');
$this->logger->info('Submit teamer financial data', [
'teamer_id' => $teamer->getId(),
'teamer_name' => (string) $teamer,
]);
return $this->redirectToRoute('app_teamer_index');
}
return $this->render('teamer/check/financial_data.html.twig', [
'form' => $form->createView(),
'teamer' => $teamer,
]);
}
}
@@ -0,0 +1,65 @@
<?php
namespace App\Controller\Teamer\Check;
use App\Entity\Teamer;
use App\Entity\User;
use App\Form\PersonalDataConfirmationType;
use App\Model\PersonalDataConfirmationDto;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class PersonalDataController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly ValidatorInterface $validator,
private readonly LoggerInterface $logger,
) {
}
#[Route('/teamer/check/personal-data', name: 'app_teamer_check_personal_data')]
#[IsGranted('ROLE_TEAMER')]
public function index(Request $request): Response
{
/** @var User $user */
$user = $this->getUser();
$teamer = $user->getTeamer();
if (null === $teamer) {
$teamer = new Teamer();
$user->setTeamer($teamer);
$this->entityManager->persist($teamer);
$this->entityManager->flush();
}
$form = $this->createForm(PersonalDataConfirmationType::class, new PersonalDataConfirmationDto());
$form->handleRequest($request);
if (true === $form->isSubmitted() && true === $form->isValid()) {
$teamer->setDataVerifiedAt(new \DateTimeImmutable());
$this->entityManager->flush();
$this->addFlash('success', 'Vielen Dank, deine Daten wurden bestätigt.');
$this->logger->info('Confirm teamer personal data', [
'teamer_id' => $teamer->getId(),
'teamer_name' => (string) $teamer,
]);
return $this->redirectToRoute('app_teamer_index');
}
return $this->render('teamer/check/personal_data.html.twig', [
'form' => $form->createView(),
'teamer' => $teamer,
// surfaced as a hint only, deliberately not blocking the confirmation
'errors' => $this->validator->validate($teamer, null, ['profile_preflight']),
]);
}
}
@@ -9,7 +9,6 @@ use App\Entity\Upload;
use App\Entity\User;
use App\Form\TeamerProfileType;
use App\Model\UploadSessionDto;
use App\RequiredTeamerCheck\PersonalDataVerificationRequiredCheck;
use App\Service\Upload\UploadHandler;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
@@ -28,7 +27,6 @@ class IndexController extends AbstractController
private readonly ApiClient $apiClient,
private readonly UploadHandler $uploadHandler,
private readonly LoggerInterface $logger,
private readonly PersonalDataVerificationRequiredCheck $personalDataVerificationRequiredCheck,
) {
}
@@ -55,12 +53,8 @@ class IndexController extends AbstractController
// Validate teamer data to show missing data right away
$errors = $this->validator->validate($teamer, null, ['profile_preflight']);
$verificationMode = true === $this->personalDataVerificationRequiredCheck->appliesTo($user)
&& false === $this->personalDataVerificationRequiredCheck->isSatisfied($user);
$form = $this->createForm(TeamerProfileType::class, $teamer, [
'upload_session' => $uploadSession,
'verification_mode' => $verificationMode,
]);
$form->handleRequest($request);
@@ -72,9 +66,9 @@ class IndexController extends AbstractController
} catch (ApiClientException $e) {
}
if (true === $verificationMode) {
$teamer->setDataVerifiedAt(new \DateTimeImmutable());
}
// Saving the full profile form is a stronger statement than ticking the
// confirmation box, so it clears the verification check too.
$teamer->setDataVerifiedAt(new \DateTimeImmutable());
$this->entityManager->flush();
@@ -91,7 +85,6 @@ class IndexController extends AbstractController
'form' => $form->createView(),
'teamer' => $teamer,
'errors' => $errors,
'verification_mode' => $verificationMode,
]);
}