From 4dc7c8f30dc18eb9dd82fdab5be7e0734c234529 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 15 Oct 2024 17:30:48 +0800 Subject: [PATCH] patch tracker order progress calculation --- server/src/Support/OrderTracker.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/server/src/Support/OrderTracker.php b/server/src/Support/OrderTracker.php index c3939897..eb6b061a 100644 --- a/server/src/Support/OrderTracker.php +++ b/server/src/Support/OrderTracker.php @@ -77,14 +77,10 @@ public function getOrderProgressPercentage(): int|float { $totalDistance = $this->getTotalDistance(); $completedDistance = $this->getCompletedDistance(); - - if ($totalDistance === -1 || $completedDistance === -1) { - return 0; - } + $cannotUseDistance = $totalDistance == -1 || $completedDistance == -1 || $completedDistance === 0; // Get order percentage by activity if distance-based progress is not available - $shouldCalculateProgressByActivity = empty($completedDistance) && $this->order->status !== 'created'; - if ($shouldCalculateProgressByActivity) { + if ($cannotUseDistance) { /** @var Collection $activities */ $activities = $this->order->orderConfig ? $this->order->orderConfig->activities() : collect(); $totalActivity = $activities->count();