Separate unit placements from shift duty assignments.
Deploy Ladill Care / deploy (push) Successful in 30s
Deploy Ladill Care / deploy (push) Successful in 30s
Roster no longer writes temporary staff assignments; unit assignment UI drops shift fields and labels clarify the two workflows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,7 +7,6 @@ use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\RosterEntry;
|
||||
use App\Models\Shift;
|
||||
use App\Models\StaffAssignment;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
@@ -114,7 +113,6 @@ class RosterService
|
||||
string $ownerRef,
|
||||
?string $actorRef = null,
|
||||
?string $notes = null,
|
||||
bool $linkAssignment = true,
|
||||
): RosterEntry {
|
||||
if ((int) $shift->organization_id !== (int) $unit->organization_id
|
||||
|| (int) $member->organization_id !== (int) $unit->organization_id) {
|
||||
@@ -138,32 +136,13 @@ class RosterService
|
||||
]);
|
||||
}
|
||||
|
||||
$assignmentId = null;
|
||||
if ($linkAssignment) {
|
||||
$assignment = StaffAssignment::create([
|
||||
'owner_ref' => $ownerRef,
|
||||
'organization_id' => $unit->organization_id,
|
||||
'member_id' => $member->id,
|
||||
'department_id' => $unit->department_id,
|
||||
'care_unit_id' => $unit->id,
|
||||
'kind' => 'temporary',
|
||||
'assignment_role' => null,
|
||||
'shift_code' => $shift->code,
|
||||
'starts_on' => $date,
|
||||
'ends_on' => $date,
|
||||
'status' => 'active',
|
||||
'notes' => $notes ?? 'Duty roster',
|
||||
]);
|
||||
$assignmentId = $assignment->id;
|
||||
}
|
||||
|
||||
if ($existing) {
|
||||
if ($existing->trashed()) {
|
||||
$existing->restore();
|
||||
}
|
||||
$existing->update([
|
||||
'status' => RosterEntry::STATUS_SCHEDULED,
|
||||
'staff_assignment_id' => $assignmentId,
|
||||
'staff_assignment_id' => null,
|
||||
'notes' => $notes,
|
||||
'created_by' => $actorRef,
|
||||
]);
|
||||
@@ -177,7 +156,7 @@ class RosterService
|
||||
'member_id' => $member->id,
|
||||
'duty_date' => $date,
|
||||
'status' => RosterEntry::STATUS_SCHEDULED,
|
||||
'staff_assignment_id' => $assignmentId,
|
||||
'staff_assignment_id' => null,
|
||||
'notes' => $notes,
|
||||
'created_by' => $actorRef,
|
||||
]);
|
||||
@@ -202,13 +181,6 @@ class RosterService
|
||||
|
||||
$entry->update(['status' => RosterEntry::STATUS_CANCELLED]);
|
||||
|
||||
if ($entry->staff_assignment_id) {
|
||||
StaffAssignment::query()->where('id', $entry->staff_assignment_id)->update([
|
||||
'status' => 'ended',
|
||||
'ends_on' => $entry->duty_date,
|
||||
]);
|
||||
}
|
||||
|
||||
// Soft-delete so the unique (unit, shift, member, date) can be reused.
|
||||
$entry->delete();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user