Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions server/src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -1379,24 +1379,25 @@ public function notifyCompleted()
*
* The process involves the following steps:
* 1. Creating a new Activity instance with the 'completed' code and relevant details.
* 2. Notifying that the order has been completed via `notifyCompleted`.
* 3. Updating the order's activity with the new 'completed' activity through `updateActivity`.
* 2. Updating the order's activity with the new 'completed' activity through `updateActivity`,
* which applies and persists the 'completed' status.
* 3. Notifying that the order has been completed via `notifyCompleted`.
*
* @param Proof|null $proof Optional. Additional proof or details for the activity update.
*
* @return Order the order instance with updated activities, reflecting the completion status
*/
public function complete(?Proof $proof = null): self
{
$this->notifyCompleted();

$doesntHaveCompletedActivity = TrackingStatus::where(['tracking_number_uuid' => $this->tracking_number_uuid, 'code' => 'COMPLETED'])->doesntExist();
if ($doesntHaveCompletedActivity) {
$activity = $this->config()->getCompletedActivity();

return $this->updateActivity($activity, $proof);
$this->updateActivity($activity, $proof);
}

$this->notifyCompleted();

return $this;
}

Expand Down