Skip to content

Commit

Permalink
fix(model): wrong ready state for waiting applications
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenrikur committed Feb 21, 2024
1 parent 7498cd1 commit 3da8b04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public static function sendStatusNotification(Application $application): StatusN
$application->status = ApplicationStatus::TableOffered;
return StatusNotificationResult::Accepted;
} else {
Log::info("Sending on-hold notification for table {$application->table_number} (requested: {$application->table_type_requested} | assigned: {$application->table_type_assigned}) to user {$user->id} for application {$application->id}.");
Log::info("Sending accepted (alternate table) notification for table {$application->table_number} (requested: {$application->table_type_requested} | assigned: {$application->table_type_assigned}) to user {$user->id} for application {$application->id}.");
$assignedTable = $application->assignedTable()->first();
$user->notify(new AlternateTableOfferedNotification($assignedTable->name, $assignedTable->price));
foreach ($application->children()->get() as $child) {
Expand Down
9 changes: 8 additions & 1 deletion app/Models/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,14 @@ public function isReady(): bool
$dealership = $this->parent()->get()->first();
}

if (empty($dealership->table_number) || $dealership->table_type_assigned === null) {
if (empty($dealership->table_number) xor $dealership->table_type_assigned === null) {
return false;
}

if (
$this->status === ApplicationStatus::Waiting
&& (empty($dealership->table_number) || $dealership->table_type_assigned === null)
) {
return false;
}

Expand Down

0 comments on commit 3da8b04

Please sign in to comment.