feat: special agreements for disposition
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controller\Administrative\Document;
|
||||
|
||||
use App\Controller\Traits\ReturnUrlTrait;
|
||||
use App\Entity\Upload;
|
||||
use App\Event\DocumentRejectedEvent;
|
||||
use App\Form\DocumentCheckType;
|
||||
@@ -20,6 +21,8 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class CheckController extends AbstractController
|
||||
{
|
||||
use ReturnUrlTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
#[Target('disposition')]
|
||||
@@ -42,14 +45,15 @@ class CheckController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
switch ($formData->getStatus()) {
|
||||
case Upload::STATUS_CHECKED:
|
||||
$this->confirmDocument($document, 'confirm_contract', Upload::STATUS_CHECKED);
|
||||
$this->confirmDocument($document, 'confirm_contract', Upload::STATUS_CHECKED, $formData);
|
||||
break;
|
||||
case Upload::STATUS_PAID:
|
||||
$this->confirmDocument($document, 'confirm_invoice', Upload::STATUS_PAID);
|
||||
$this->confirmDocument($document, 'confirm_invoice', Upload::STATUS_PAID, $formData);
|
||||
break;
|
||||
case Upload::STATUS_REJECTED:
|
||||
$this->rejectDocument($document, $formData->getComment());
|
||||
$this->eventDispatcher->dispatch(new DocumentRejectedEvent($formData), DocumentRejectedEvent::NAME);
|
||||
break;
|
||||
default:
|
||||
$document
|
||||
->setStatus($formData->getStatus())
|
||||
@@ -65,7 +69,9 @@ class CheckController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
return new HxRedirectResponse($this->generateUrl('app_administrative_document_index'));
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_administrative_document_index');
|
||||
|
||||
return new HxRedirectResponse($returnUrl);
|
||||
}
|
||||
|
||||
return $this->render('administrative/document/modal_check.html.twig', [
|
||||
@@ -94,7 +100,7 @@ class CheckController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
private function confirmDocument(Upload $document, string $transition, string $status): void
|
||||
private function confirmDocument(Upload $document, string $transition, string $status, DocumentCheckDto $formData): void
|
||||
{
|
||||
$document->setStatus($status);
|
||||
$this->addFlash('success', 'Das Dokument wurde bestätigt');
|
||||
@@ -113,6 +119,10 @@ class CheckController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
if (Upload::TYPE_INVOICE === $document->getType()) {
|
||||
$document->getDisposition()->setSpecialAgreements($formData->getSpecialAgreements());
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user