Dokumentenzusammenstellung und Vorlagensteuerung (Paket 3, Prozessarchitektur v0.10)
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m59s

Eine Zusammenstellung vor jedem Dokument (Angebot, Bestaetigung, Buchungsunterlagen
extern), Dokumentart je Vorgangsart, Freigaben fuer Vorlagen und Dokumentarten,
Schutz vor unvereinbarten Bedingungen bei Portalbuchungen (E-004), kein doppelter
Versand, Absicherung Hold 0 bis Paket 7, A6-Aufenthaltsbestaetigung vorbereitet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-01 19:44:52 +01:00
1 parent 64248c09fa
commit cf11c8a474
45 files changed
+2385 -144

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Documents;
use App\Enums\DocumentKind;
use App\Models\Tenant;
use App\Support\Settings;
/**
* Which document kinds the landlord has released for guests (tenants.document_releases). A kind that is not released is
* a working draft: it is never sent automatically, and by hand only after an explicit confirmation in the case.
*/
class DocumentReleases
{
public static function isReleased(DocumentKind $kind, ?Tenant $tenant = null): bool
{
$entry = self::entries($tenant)[$kind->value] ?? null;
return is_array($entry) ? (bool) ($entry['released'] ?? false) : $kind->releasedByDefault();
}
/**
* @return array{released: bool, by: ?string, at: ?string}|null the landlord's decision, null when none was made
*/
public static function decision(DocumentKind $kind, ?Tenant $tenant = null): ?array
{
$entry = self::entries($tenant)[$kind->value] ?? null;
return is_array($entry) ? ['released' => (bool) ($entry['released'] ?? false), 'by' => $entry['by'] ?? null, 'at' => $entry['at'] ?? null] : null;
}
/**
* Stores the decision for one kind; an unchanged decision keeps its date and author.
*/
public static function set(DocumentKind $kind, bool $released, string $actor, ?Tenant $tenant = null): void
{
$tenant ??= Settings::tenant();
if ($tenant === null || self::isReleased($kind, $tenant) === $released && self::decision($kind, $tenant) !== null) {
return;
}
$entries = self::entries($tenant);
$entries[$kind->value] = ['released' => $released, 'by' => $actor, 'at' => now()->toIso8601String()];
$tenant->update(['document_releases' => $entries]);
}
/**
* @return array<string, mixed>
*/
private static function entries(?Tenant $tenant): array
{
return (array) (($tenant ?? Settings::tenant())?->document_releases ?? []);
}
}