Files
fewo-stommer/app/Process/FactContribution.php
T
LarsandClaude Opus 5.5 ccac78a6c9 v0.11 U2: Angebots-Gate, gemeinsamer Fakteneingang mit Herkunft
- CaseRequirements: Vor einem eigenen verbindlichen Angebot und vor der
  verbindlichen Bestätigung eines Buchungswunsches müssen Vor- und
  Nachname, E-Mail, vollständige Anschrift mit Land, Personenzahl und
  Zeitraum vorliegen – harter Blocker, auch von Hand (G2a, B3). Die
  Auskunft unter Vorbehalt bleibt ohne dieses Gate.
- ContributeCaseFacts (S5): jede Angabe mit Herkunft und Ergebnis in
  case_facts; fehlend → übernommen, gleich → bestätigt, abweichend vom
  Gast → Prüfaufgabe (Kartei bleibt), Vermieterin maßgeblich, Zeitraum und
  Personen → Änderungswunsch; idempotent; danach einmal CaseAutomation.
- ProvideGuestContact und Webformular nutzen den Fakteneingang.
- Land als ISO-Code mit „Deutschland“ als änderbarem Formularstandard;
  guests.country ohne stillen Standardwert (B4).
- Testdaten bestehender Tests um Anschriften ergänzt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:07:18 +01:00

56 lines
1.7 KiB
PHP

<?php
namespace App\Process;
use App\Models\CaseFact;
/**
* What became of the details given for a case in one contribution (v0.11, S5).
*/
final class FactContribution
{
/**
* @param list<CaseFact> $facts recorded facts (duplicates of an earlier contribution are not recorded again)
*/
public function __construct(public readonly array $facts = []) {}
/**
* @return list<string> field keys with the given outcome
*/
public function fields(string $outcome): array
{
return array_values(array_map(fn (CaseFact $fact): string => $fact->field, array_filter($this->facts, fn (CaseFact $fact): bool => $fact->outcome === $outcome)));
}
public function anyApplied(): bool
{
return $this->fields(CaseFact::APPLIED) !== [];
}
public function needsReview(): bool
{
return $this->fields(CaseFact::CONFLICT) !== [] || $this->fields(CaseFact::CHANGE_REQUEST) !== [];
}
public function isEmpty(): bool
{
return $this->facts === [];
}
/**
* Plain words for the landlord, e.g. for a notification.
*/
public function summary(): string
{
$parts = [];
foreach ([CaseFact::APPLIED => 'übernommen', CaseFact::CONFIRMED => 'bestätigt', CaseFact::CONFLICT => 'weichen ab (zur Prüfung)', CaseFact::CHANGE_REQUEST => 'Änderungswunsch (zur Prüfung)', CaseFact::REJECTED => 'nicht verwendbar'] as $outcome => $label) {
$fields = $this->fields($outcome);
if ($fields !== []) {
$parts[] = implode(', ', CaseRequirements::labels($fields)).' '.$label;
}
}
return $parts === [] ? 'Keine neuen Angaben.' : implode(' · ', $parts);
}
}