Fix: Resolve impossible confirmation of uploaded contract
This commit is contained in:
@@ -76,36 +76,39 @@ class CheckController extends AbstractController
|
||||
|
||||
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)
|
||||
->setComment($comment)
|
||||
;
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Das Dokument wurde abgelehnt');
|
||||
$this->logger->info('Reject document', [
|
||||
'document' => $document->getOriginalFilename(),
|
||||
]);
|
||||
|
||||
$transition = Upload::TYPE_CONTRACT === $document->getType() ? 'reject_contract' : 'reject_invoice';
|
||||
$this->workflow->apply($document->getDisposition(), $transition);
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
private function confirmDocument(Upload $document, string $transition, string $status): void
|
||||
{
|
||||
$document->setStatus($status);
|
||||
$this->addFlash('success', 'Das Dokument wurde bestätigt');
|
||||
$this->logger->info('Confirm document', [
|
||||
'document' => $document->getOriginalFilename(),
|
||||
]);
|
||||
|
||||
if (true === $this->workflow->can($document->getDisposition(), $transition)) {
|
||||
$document->setStatus($status);
|
||||
$this->workflow->apply($document->getDisposition(), $transition);
|
||||
$this->entityManager->flush();
|
||||
$this->addFlash('success', 'Das Dokument wurde bestätigt');
|
||||
$this->logger->info('Confirm document', [
|
||||
'document' => $document->getOriginalFilename(),
|
||||
]);
|
||||
} else {
|
||||
$blockers = $this->workflow->buildTransitionBlockerList($document->getDisposition(), $transition);
|
||||
foreach ($blockers as $blocker) {
|
||||
$this->addFlash('error', $blocker->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user