feat: smart re-assignment with cancellation source tracking
Add cancelled_by, cancellation_source (organiser|volunteer|system), and cancelled_at columns to shift_assignments. Cancel flow now records who cancelled and why. Assign flow reactivates existing cancelled/rejected records instead of creating duplicates, preventing UNIQUE constraint violations. Assignable-persons endpoint returns previous_assignment data for contextual UI indicators. Frontend shows cancellation source labels, previous assignment history in assign dialog, and "Opnieuw toewijzen" buttons with volunteer-cancelled confirmation dialogs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CancellationSource;
|
||||
use App\Enums\ShiftAssignmentStatus;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
||||
@@ -29,6 +30,9 @@ final class ShiftAssignment extends Model
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'rejection_reason',
|
||||
'cancelled_by',
|
||||
'cancellation_source',
|
||||
'cancelled_at',
|
||||
'hours_expected',
|
||||
'hours_completed',
|
||||
'checked_in_at',
|
||||
@@ -39,9 +43,11 @@ final class ShiftAssignment extends Model
|
||||
{
|
||||
return [
|
||||
'status' => ShiftAssignmentStatus::class,
|
||||
'cancellation_source' => CancellationSource::class,
|
||||
'auto_approved' => 'boolean',
|
||||
'assigned_at' => 'datetime',
|
||||
'approved_at' => 'datetime',
|
||||
'cancelled_at' => 'datetime',
|
||||
'checked_in_at' => 'datetime',
|
||||
'checked_out_at' => 'datetime',
|
||||
'hours_expected' => 'decimal:2',
|
||||
@@ -74,6 +80,11 @@ final class ShiftAssignment extends Model
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
public function cancelledByUser(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'cancelled_by');
|
||||
}
|
||||
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->whereIn('status', [
|
||||
|
||||
Reference in New Issue
Block a user