Skip to content

Commit

Permalink
patch tracker order progress calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Oct 15, 2024
1 parent eb1ec09 commit 4dc7c8f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions server/src/Support/OrderTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4dc7c8f

Please sign in to comment.