Feat: Assign potential comment to upload for later use

This commit is contained in:
Björn Fromme
2023-10-14 16:55:08 +02:00
parent 194cd4e59d
commit 80990c9edc
2 changed files with 22 additions and 3 deletions
@@ -57,7 +57,7 @@ class CheckController extends AbstractController
$this->confirmDocument($document, 'confirm_invoice', Upload::STATUS_PAID);
break;
case Upload::STATUS_REJECTED:
$this->rejectDocument($document);
$this->rejectDocument($document, $formData->getComment());
$this->eventDispatcher->dispatch(new DocumentRejectedEvent($formData), DocumentRejectedEvent::NAME);
}
@@ -73,11 +73,14 @@ class CheckController extends AbstractController
return $this->json($response);
}
private function rejectDocument(Upload $document): void
private function rejectDocument(Upload $document, string $comment = null): void
{
$transition = Upload::TYPE_CONTRACT === $document->getType() ? 'reject_contract' : 'reject_invoice';
$this->workflow->apply($document->getDisposition(), $transition);
$document->setStatus(Upload::STATUS_REJECTED);
$document
->setStatus(Upload::STATUS_REJECTED)
->setComment($comment)
;
$this->entityManager->flush();
$this->addFlash('success', 'Das Dokument wurde abgelehnt');
+16
View File
@@ -6,6 +6,7 @@ use App\Entity\Traits\BlameableEntity;
use App\Entity\Traits\TimestampableEntity;
use App\Model\UploadDto;
use App\Repository\UploadRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
@@ -61,6 +62,9 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
#[ORM\ManyToOne(inversedBy: 'documents')]
private ?Disposition $disposition = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $comment = null;
public function __construct()
{
$this->uuid = Uuid::v4();
@@ -198,4 +202,16 @@ class Upload implements BlameableEntityInterface, TimestampableEntityInterface
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): static
{
$this->comment = $comment;
return $this;
}
}