aureuserp/aureuserp · warning · Exception

manufacturing::system.work-order.impossible-to-plan

Error message

manufacturing::system.work-order.impossible-to-plan

What it means

Thrown by the work-order scheduling routine (WorkOrder.php:690): after scanning the work center and all alternativeWorkCenters via findFirstAvailableSlot($dateStart, $expectedDuration), if no candidate produced a slot ($bestFinishedDate stays null), planning throws manufacturing::system.work-order.impossible-to-plan - there is no capacity for the required duration anywhere in the candidate set.

Source

Thrown at plugins/webkul/manufacturing/src/Models/WorkOrder.php:690

                continue;
            }

            if ($toDate && ($bestFinishedDate === null || Carbon::parse($toDate)->lt($bestFinishedDate))) {
                $bestStartedDate = $fromDate;

                $bestFinishedDate = Carbon::parse($toDate);

                $bestWorkCenter = $workCenter;

                $values = [
                    'work_center_id'    => $workCenter->id,
                    'expected_duration' => $expectedDuration,
                ];
            }
        }

        if ($bestFinishedDate === null) {
            throw new \Exception(__('manufacturing::system.work-order.impossible-to-plan'));
        }

        $leave = CalendarLeave::create([
            'name'          => $this->name,
            'calendar_id'   => $bestWorkCenter->calendar_id,
            'date_from'     => $bestStartedDate,
            'date_to'       => $bestFinishedDate,
            'resource_id'   => $bestWorkCenter->getKey(),
            'resource_type' => $bestWorkCenter->getMorphClass(),
            'time_type'     => 'other',
        ]);

        $values['calendar_leave_id'] = $leave->id;

        $this->update($values);
    }

    public function finish(): void

View on GitHub (pinned to bd7cbeeb0c)

Solutions

  1. Retry planning from a later start date or extend the scheduling horizon
  2. Reduce expected_duration by correcting routing/operation times
  3. Add alternative work centers with free capacity
  4. Clean up stale CalendarLeave blocks and verify calendar hours

Example fix

// before
$workOrder->plan(); // throws when no center has a free slot

// after - degrade gracefully when no slot exists
try {
    $workOrder->plan();
} catch (\Exception $e) {
    Notification::make()
        ->danger()
        ->title(__('manufacturing::system.work-order.impossible-to-plan'))
        ->send();
}
Defensive patterns

Strategy: try-catch

Validate before calling

[$from, $to] = $workOrder->workCenter->findFirstAvailableSlot($dateStart, $workOrder->expected_duration);
$slotExists = $from !== null;

Type guard

function hasAvailableSlotSoon(WorkOrder $workOrder, Carbon $fromDate): bool
{
    $centers = collect([$workOrder->workCenter])->merge($workOrder->workCenter->alternativeWorkCenters);

    return $centers->contains(fn ($wc) => $wc->findFirstAvailableSlot($fromDate, $workOrder->expected_duration)[0] !== null);
}

Try / catch

try {
    $workOrder->plan();
} catch (\Exception $e) {
    // no capacity anywhere - offer later dates or more work centers; no leave was created
    Notification::make()->warning()->title(__('manufacturing::system.work-order.impossible-to-plan'))->send();
}

Prevention

When it happens

Trigger: All candidate work centers are fully booked by existing CalendarLeave reservations; calendar working hours are shorter than expected_duration; dateStart sits beyond defined working days; every findFirstAvailableSlot returned null.

Common situations: Overloaded shop floor; inflated expected_duration from wrong routing times; stale calendar leaves blocking capacity; calendars misconfigured for timezone or working hours; planning far-future dates with no work days defined.

Related errors


AI-assisted analysis of aureuserp/aureuserp@bd7cbeeb0c (2026-08-21). Data as JSON: /api/errors/44b2cff3535359e4. Report an issue: GitHub.