Ein Eingang fuer alle Kanaele (Paket 4, Prozessarchitektur v0.10)
Portalbuchungen und -anfragen aus Kalender und Mail werden ueber PortalIntake zum Vorgang (nur bei sicherer Erkennung), Dubletten ueber Buchungsnummer, gleiches Portal mit gleichen Naechten und Spiegelung; Unsicheres wird geklaert. Portalstorno und -aenderung als Aufgabe am Vorgang ohne stille Stornierung. Schalter je Kanal (Aus als Standard, Beobachten, Anlegen, Anlegen + weiter), Eingangsprotokoll, Bestandsuebernahme mit Vorschau/Bericht/Ruecknahme, Sperrnachweis in drei Stufen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cf11c8a474
commit
ac9d20b812
29 files changed
+1952
-16
No files matched your search
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Channels\ChannelRegistry;
|
||||
use App\Channels\Contracts\ChannelConnector;
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\ChannelEchoBehavior;
|
||||
use App\Enums\ChannelExportMode;
|
||||
@@ -26,7 +27,7 @@
|
||||
* A sales channel (portal) of a property. Our system leads: occupations are imported from the
|
||||
* channel and every channel gets its own export feed without its own occupations.
|
||||
*/
|
||||
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at', 'payment_tasks_inquiry', 'payment_tasks_reservation', 'contract_template_id', 'contract_template_reservation_id', 'process_overrides'])]
|
||||
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at', 'payment_tasks_inquiry', 'payment_tasks_reservation', 'contract_template_id', 'contract_template_reservation_id', 'process_overrides', 'case_intake'])]
|
||||
#[Hidden(['export_token', 'previous_export_token', 'export_snapshot', 'settings', 'ical_analysis'])]
|
||||
class Channel extends Model
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class Channel extends Model
|
||||
protected $attributes = [
|
||||
'status' => 'setup', 'booking_model' => 'mixed', 'import_enabled' => false,
|
||||
'export_enabled' => false, 'export_mode' => 'test',
|
||||
'echo_behavior' => 'unverified',
|
||||
'echo_behavior' => 'unverified', 'case_intake' => 'off',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
@@ -63,6 +64,7 @@ protected function casts(): array
|
||||
return [
|
||||
'settings' => 'array',
|
||||
'process_overrides' => 'array',
|
||||
'case_intake' => CaseIntakeMode::class,
|
||||
'ical_analysis' => 'encrypted:array',
|
||||
'ical_analyzed_at' => 'immutable_datetime',
|
||||
'ical_rules' => 'array',
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\ChannelTaskAction;
|
||||
use App\Enums\ChannelTaskProof;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\ChannelTaskFactory;
|
||||
@@ -18,7 +19,7 @@
|
||||
* A change that has to be made by hand (or by an external automation) on a portal that
|
||||
* cannot be kept in sync fast enough by calendar feeds, e.g. because of instant booking.
|
||||
*/
|
||||
#[Fillable(['channel_id', 'action', 'starts_on', 'ends_on', 'reason', 'status', 'completed_by', 'completed_at', 'reminded_at', 'automation_sent_at', 'automation_error'])]
|
||||
#[Fillable(['channel_id', 'action', 'starts_on', 'ends_on', 'reason', 'status', 'completed_by', 'completed_at', 'reminded_at', 'automation_sent_at', 'automation_error', 'proof', 'proof_note', 'proof_at', 'proof_by'])]
|
||||
class ChannelTask extends Model
|
||||
{
|
||||
/** @use HasFactory<ChannelTaskFactory> */
|
||||
@@ -39,6 +40,8 @@ protected function casts(): array
|
||||
'completed_at' => 'immutable_datetime',
|
||||
'reminded_at' => 'immutable_datetime',
|
||||
'automation_sent_at' => 'immutable_datetime',
|
||||
'proof' => ChannelTaskProof::class,
|
||||
'proof_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,7 +63,10 @@ protected function open(Builder $query): Builder
|
||||
return $query->where('status', ChannelTaskStatus::Open);
|
||||
}
|
||||
|
||||
public function complete(string $completedBy): void
|
||||
/**
|
||||
* Completes the task with the proof the person can give (at least: the change was made or started).
|
||||
*/
|
||||
public function complete(string $completedBy, ChannelTaskProof $proof = ChannelTaskProof::Initiated, ?string $note = null): void
|
||||
{
|
||||
if ($this->status !== ChannelTaskStatus::Open) {
|
||||
return;
|
||||
@@ -74,9 +80,38 @@ public function complete(string $completedBy): void
|
||||
'status' => ChannelTaskStatus::Done,
|
||||
'completed_by' => $completedBy,
|
||||
'completed_at' => now(),
|
||||
'proof' => $proof,
|
||||
'proof_note' => filled($note) ? trim($note) : null,
|
||||
'proof_at' => now(),
|
||||
'proof_by' => $completedBy,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises the proof of a completed task (e.g. the block was later seen in the portal); never lowers it.
|
||||
*/
|
||||
public function prove(ChannelTaskProof $proof, string $by, ?string $note = null): void
|
||||
{
|
||||
$order = array_flip(array_map(fn (ChannelTaskProof $case): string => $case->value, ChannelTaskProof::cases()));
|
||||
if ($this->status !== ChannelTaskStatus::Done || ($this->proof !== null && $order[$proof->value] <= $order[$this->proof->value])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->update(['proof' => $proof, 'proof_note' => filled($note) ? trim($note) : $this->proof_note, 'proof_at' => now(), 'proof_by' => $by]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The state of the task in plain words, including how far it is proven.
|
||||
*/
|
||||
public function proofLabel(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
ChannelTaskStatus::Open => 'noch offen',
|
||||
ChannelTaskStatus::Dismissed => 'verworfen',
|
||||
ChannelTaskStatus::Done => ($this->proof ?? ChannelTaskProof::Initiated)->getLabel().($this->proof_note ? ' ('.$this->proof_note.')' : ''),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Human readable period, e.g. "14.06.2027 – 21.06.2027".
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* One entry of the intake record: an incoming portal event, what the intake recognised and whether it acted. The same
|
||||
* event with the same result is recorded once (fingerprint), however often the calendar is read or the mail arrives.
|
||||
*/
|
||||
#[Fillable(['channel_id', 'blocked_period_id', 'portal_email_id', 'booking_id', 'fingerprint', 'source', 'mode', 'outcome', 'applied', 'case_type', 'starts_on', 'ends_on', 'reference', 'reasons', 'missing', 'occurred_at'])]
|
||||
class IntakeObservation extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
public const SOURCE_CALENDAR = 'calendar';
|
||||
|
||||
public const SOURCE_MAIL = 'mail';
|
||||
|
||||
public const SOURCE_ADOPTION = 'adoption';
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'mode' => CaseIntakeMode::class,
|
||||
'outcome' => IntakeOutcome::class,
|
||||
'applied' => 'boolean',
|
||||
'starts_on' => 'immutable_date',
|
||||
'ends_on' => 'immutable_date',
|
||||
'reasons' => 'array',
|
||||
'missing' => 'array',
|
||||
'occurred_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Channel, $this> */
|
||||
public function channel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Channel::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Booking, $this> */
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<BlockedPeriod, $this> */
|
||||
public function blockedPeriod(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BlockedPeriod::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function sourceLabel(): string
|
||||
{
|
||||
return match ($this->source) {
|
||||
self::SOURCE_MAIL => 'Portal-E-Mail',
|
||||
self::SOURCE_ADOPTION => 'Bestandsübernahme',
|
||||
default => 'Portalkalender',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user