diff --git a/app/Http/Controllers/Api/KitchenIngestController.php b/app/Http/Controllers/Api/KitchenIngestController.php index 88b7bbe..c1bb927 100644 --- a/app/Http/Controllers/Api/KitchenIngestController.php +++ b/app/Http/Controllers/Api/KitchenIngestController.php @@ -39,6 +39,11 @@ class KitchenIngestController extends Controller return response()->json(['message' => $e->getMessage()], 422); } + // Owner doesn't run a POS kitchen — accept and ignore. + if ($sale === null) { + return response()->json(['skipped' => true], 200); + } + return response()->json(['id' => $sale->id, 'reference' => $sale->reference], 201); } diff --git a/app/Services/Pos/PosSaleService.php b/app/Services/Pos/PosSaleService.php index 23b7ecb..3caf6c5 100644 --- a/app/Services/Pos/PosSaleService.php +++ b/app/Services/Pos/PosSaleService.php @@ -376,7 +376,7 @@ class PosSaleService * * @param array{owner: string, reference: string, customer_name?: ?string, items: list} $data */ - public function ingestExternalOrder(array $data): PosSale + public function ingestExternalOrder(array $data): ?PosSale { $owner = (string) $data['owner']; $reference = (string) $data['reference']; @@ -387,6 +387,11 @@ class PosSaleService } $location = PosLocation::owned($owner)->first(); + + // Only surface online orders for accounts that actually run a POS kitchen. + if (! $location || ! $location->isRestaurant()) { + return null; + } $currency = strtoupper((string) ($location?->currency ?? config('pos.default_currency', 'GHS'))); $lines = [];