{"record":{"id":"44b2cff3535359e4","repo":"aureuserp/aureuserp","slug":"manufacturing-system-work-order-impossible-to-pla","errorCode":null,"errorMessage":"manufacturing::system.work-order.impossible-to-plan","messagePattern":"manufacturing::system\\.work-order\\.impossible-to-plan","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"plugins/webkul/manufacturing/src/Models/WorkOrder.php","lineNumber":690,"sourceCode":"                continue;\n            }\n\n            if ($toDate && ($bestFinishedDate === null || Carbon::parse($toDate)->lt($bestFinishedDate))) {\n                $bestStartedDate = $fromDate;\n\n                $bestFinishedDate = Carbon::parse($toDate);\n\n                $bestWorkCenter = $workCenter;\n\n                $values = [\n                    'work_center_id'    => $workCenter->id,\n                    'expected_duration' => $expectedDuration,\n                ];\n            }\n        }\n\n        if ($bestFinishedDate === null) {\n            throw new \\Exception(__('manufacturing::system.work-order.impossible-to-plan'));\n        }\n\n        $leave = CalendarLeave::create([\n            'name'          => $this->name,\n            'calendar_id'   => $bestWorkCenter->calendar_id,\n            'date_from'     => $bestStartedDate,\n            'date_to'       => $bestFinishedDate,\n            'resource_id'   => $bestWorkCenter->getKey(),\n            'resource_type' => $bestWorkCenter->getMorphClass(),\n            'time_type'     => 'other',\n        ]);\n\n        $values['calendar_leave_id'] = $leave->id;\n\n        $this->update($values);\n    }\n\n    public function finish(): void","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/aureuserp/aureuserp/blob/bd7cbeeb0c620985dfd9b88c56be7f3ea86be6b4/plugins/webkul/manufacturing/src/Models/WorkOrder.php#L672-L708","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry planning from a later start date or extend the scheduling horizon","Reduce expected_duration by correcting routing/operation times","Add alternative work centers with free capacity","Clean up stale CalendarLeave blocks and verify calendar hours"],"exampleFix":"// before\n$workOrder->plan(); // throws when no center has a free slot\n\n// after - degrade gracefully when no slot exists\ntry {\n    $workOrder->plan();\n} catch (\\Exception $e) {\n    Notification::make()\n        ->danger()\n        ->title(__('manufacturing::system.work-order.impossible-to-plan'))\n        ->send();\n}","handlingStrategy":"try-catch","validationCode":"[$from, $to] = $workOrder->workCenter->findFirstAvailableSlot($dateStart, $workOrder->expected_duration);\n$slotExists = $from !== null;","typeGuard":"function hasAvailableSlotSoon(WorkOrder $workOrder, Carbon $fromDate): bool\n{\n    $centers = collect([$workOrder->workCenter])->merge($workOrder->workCenter->alternativeWorkCenters);\n\n    return $centers->contains(fn ($wc) => $wc->findFirstAvailableSlot($fromDate, $workOrder->expected_duration)[0] !== null);\n}","tryCatchPattern":"try {\n    $workOrder->plan();\n} catch (\\Exception $e) {\n    // no capacity anywhere - offer later dates or more work centers; no leave was created\n    Notification::make()->warning()->title(__('manufacturing::system.work-order.impossible-to-plan'))->send();\n}","preventionTips":["Keep calendars and working hours realistic","Prune stale CalendarLeave reservations","Maintain alternative work centers with spare capacity","Sanity-check expected_duration values on routings"],"tags":["manufacturing","scheduling","capacity-planning","calendar"],"backgroundTag":"no-schedule-slot-available","analyzedSha":"bd7cbeeb0c620985dfd9b88c56be7f3ea86be6b4","analyzedAt":"2026-08-21T06:41:00.338Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}