feat: additional receipts as attachments to teamer invoices

addresses #869dv97u9
This commit is contained in:
fromme committed 2026-09-09 11:10:57 +02:00
1 parent 16d847137d
commit 52926ec6cc
29 files changed
+682 -23

No files matched your search

@@ -89,7 +89,7 @@ class DocumentUploadController extends AbstractController
$uploadSession = $this->uploadHandler->getUploadSession();
$upload = Upload::fromUploadDto(
$uploadSession->getUploads()->first(),
$uploadSession->getUploadsByType($type)->first(),
$teamer->getUser(),
$type
);
@@ -113,7 +113,7 @@ class DocumentUploadController extends AbstractController
$this->entityManager->flush();
$this->uploadHandler->moveUploadSessionFilesFromOrphanage($type, $uploadSession);
$this->uploadHandler->destroyUploadSession();
$this->uploadHandler->removeUploadSessionUploadsByType($type);
if (true === $this->featureManager->isActive('sanitize_uploads')) {
$this->uploadHandler->ensurePdf($upload);
@@ -94,6 +94,9 @@ class CheckController extends AbstractController
return $this->render('administrative/document/modal_check.html.twig', [
'document' => $document,
'form' => $form->createView(),
'receipts' => Upload::TYPE_INVOICE === $document->getType()
? $document->getDisposition()?->getDocumentsByType(Upload::TYPE_RECEIPT)
: null,
]);
}
@@ -117,6 +120,25 @@ class CheckController extends AbstractController
$this->entityManager->flush();
}
private function removeReceipts(Upload $document): void
{
$receipts = $document->getDisposition()?->getDocumentsByType(Upload::TYPE_RECEIPT);
if (null === $receipts || 0 === $receipts->count()) {
return;
}
foreach ($receipts as $receipt) {
$this->entityManager->remove($receipt);
}
$this->logger->info('Delete receipts of accepted invoice', [
'document_id' => $document->getId(),
'disposition_id' => $document->getDisposition()->getId(),
'count' => $receipts->count(),
]);
}
private function confirmDocument(Upload $document, string $transition, string $status, DocumentCheckDto $formData): void
{
/** @var User $user */
@@ -147,6 +169,14 @@ class CheckController extends AbstractController
if (true === $this->workflow->can($document->getDisposition(), $transition)) {
$this->workflow->apply($document->getDisposition(), $transition);
// Belege only have to survive until the Honorarnote is accepted. Removing them here
// and not before the guard means a blocked confirmation - which still persists the
// new document status below - cannot destroy the evidence for an invoice that was in
// fact not approved. DeleteUploadListener removes the files from disk on preRemove.
if (Upload::TYPE_INVOICE === $document->getType() && Upload::STATUS_PAID === $status) {
$this->removeReceipts($document);
}
} else {
$blockers = $this->workflow->buildTransitionBlockerList($document->getDisposition(), $transition);
foreach ($blockers as $blocker) {
@@ -32,10 +32,10 @@ class ReplaceController extends AbstractController
if (true === $request->isMethod('POST') && 0 < $uploadSession->getCount()) {
/** @var User $user */
$user = $this->getUser();
Upload::fromUploadDto($uploadSession->getUploads()->first(), $user, Upload::TYPE_DOCUMENT, $upload);
Upload::fromUploadDto($uploadSession->getUploadsByType(Upload::TYPE_DOCUMENT)->first(), $user, Upload::TYPE_DOCUMENT, $upload);
$this->entityManager->flush();
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_DOCUMENT, $uploadSession);
$this->uploadHandler->destroyUploadSession();
$this->uploadHandler->removeUploadSessionUploadsByType(Upload::TYPE_DOCUMENT);
}
$filenameBefore = $upload->getOriginalFilename();
@@ -39,14 +39,14 @@ class UploadController extends AbstractController
if (true === $request->isMethod('POST') && 0 < $uploadSession->getCount()) {
/** @var User $user */
$user = $this->getUser();
foreach ($uploadSession->getUploads() as $upload) {
foreach ($uploadSession->getUploadsByType(Upload::TYPE_DOCUMENT) as $upload) {
$document = Upload::fromUploadDto($upload, $user, Upload::TYPE_DOCUMENT);
$uploadedDocuments[] = $document;
$this->entityManager->persist($document);
}
$this->entityManager->flush();
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_DOCUMENT, $uploadSession);
$this->uploadHandler->destroyUploadSession();
$this->uploadHandler->removeUploadSessionUploadsByType(Upload::TYPE_DOCUMENT);
}
if ($form->isSubmitted() && $form->isValid()) {