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

+69 -2
View File
@@ -12,13 +12,23 @@
* A version of contract texts for offers (e.g. conditions demanded by a portal). The texts replace the website
* texts of the same meaning when an offer is made; the offer then freezes a copy. A version that has been used in
* an offer is never edited – a new version is created instead.
*
* A version goes to guests automatically only when it is released; for bookings already binding on a portal it must in
* addition be confirmed as reproducing only what guests accept there (E-004). Both statements belong to the text: they
* lapse when the text changes, and a new version starts without them.
*/
#[Fillable(['name', 'version', 'texts', 'body', 'annex_title', 'annex_body', 'cancellation_policy_id', 'annex_ids', 'notes'])]
#[Fillable(['name', 'version', 'texts', 'body', 'annex_title', 'annex_body', 'cancellation_policy_id', 'annex_ids', 'notes', 'released_at', 'released_by', 'portal_terms_confirmed_at', 'portal_terms_confirmed_by'])]
class ContractTemplate extends Model
{
use BelongsToTenant;
/** Form/storage key => website text key it replaces in an offer. */
/** Attributes whose change makes the release and the portal confirmation lapse. */
/** Whether the statements were given for the pending save (then a text change does not withdraw them). */
private bool $statementsApplied = false;
private const CONTENT = ['texts', 'body', 'annex_title', 'annex_body', 'cancellation_policy_id', 'annex_ids'];
public const TEXTS = [
'intro' => 'contract.intro',
'terms' => 'contract.terms',
@@ -35,7 +45,64 @@ class ContractTemplate extends Model
*/
protected function casts(): array
{
return ['texts' => 'array', 'version' => 'integer', 'annex_ids' => 'array'];
return ['texts' => 'array', 'version' => 'integer', 'annex_ids' => 'array', 'released_at' => 'datetime', 'portal_terms_confirmed_at' => 'datetime'];
}
protected static function booted(): void
{
static::saved(function (ContractTemplate $template): void {
$template->statementsApplied = false;
});
static::saving(function (ContractTemplate $template): void {
if ($template->exists && $template->isDirty(self::CONTENT) && ! $template->statementsApplied) {
if (! $template->isDirty('released_at')) {
$template->released_at = null;
$template->released_by = null;
}
if (! $template->isDirty('portal_terms_confirmed_at')) {
$template->portal_terms_confirmed_at = null;
$template->portal_terms_confirmed_by = null;
}
}
});
}
/**
* Records the landlord's statements on the (possibly just changed) text: a statement is renewed when it is given for
* a changed text, kept when nothing changed and withdrawn when it is not given.
*/
public function applyStatements(bool $released, bool $portalTerms, string $actor): self
{
$changed = $this->isDirty(self::CONTENT);
$this->statementsApplied = true;
if (! $released) {
$this->forceFill(['released_at' => null, 'released_by' => null]);
} elseif ($changed || ! $this->isReleased()) {
$this->forceFill(['released_at' => now(), 'released_by' => $actor]);
}
if (! $portalTerms) {
$this->forceFill(['portal_terms_confirmed_at' => null, 'portal_terms_confirmed_by' => null]);
} elseif ($changed || ! $this->confirmsPortalTerms()) {
$this->forceFill(['portal_terms_confirmed_at' => now(), 'portal_terms_confirmed_by' => $actor]);
}
return $this;
}
public function isReleased(): bool
{
return $this->released_at !== null;
}
/**
* Whether the landlord confirmed that this version only reproduces the terms guests accept when booking on a portal.
*/
public function confirmsPortalTerms(): bool
{
return $this->portal_terms_confirmed_at !== null;
}
/**