From e9d483394ccfed5a36f3742171888b3e296c0c9e Mon Sep 17 00:00:00 2001 From: isaacclad Date: Wed, 24 Jun 2026 23:50:52 +0000 Subject: [PATCH] Only ingest online orders for accounts running a POS kitchen Guard ingestExternalOrder: skip (200, no ticket created) when the owner has no restaurant-mode POS location, so pushing from Merchant is harmless for accounts that don't use the POS kitchen. Co-Authored-By: Claude Opus 4.8 --- app/Http/Controllers/Api/KitchenIngestController.php | 5 +++++ app/Services/Pos/PosSaleService.php | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 = [];