diff --git a/services/nginx/app/routes/ordersRoute.php b/services/nginx/app/routes/ordersRoute.php index 584e91ac..64717a7c 100644 --- a/services/nginx/app/routes/ordersRoute.php +++ b/services/nginx/app/routes/ordersRoute.php @@ -237,7 +237,7 @@ class ordersRoute $order->setPendingHandheldIndicator(); } // Log the incident - (new logs_o())->add('orders', $data['department_id'], 1, $user->id, 'ADD_ORDER', 'Successfully added an order (ID: ' . $data['department_id'] . ')'); + (new logs_o())->add('orders', $data['department_id'], 1, $user->id, 'ADD_ORDER', 'Successfully added an order (ID: ' . (int)$order->id . ')'); // Return a success message, containing the orders array $response->success($order->asArray()); } else { diff --git a/services/nginx/app/tests/Unit/Orders/OrdersAddRouteCreateLogWiringTest.php b/services/nginx/app/tests/Unit/Orders/OrdersAddRouteCreateLogWiringTest.php new file mode 100644 index 00000000..d91ac4fd --- /dev/null +++ b/services/nginx/app/tests/Unit/Orders/OrdersAddRouteCreateLogWiringTest.php @@ -0,0 +1,17 @@ +not->toBeFalse(); + + // The POST /orders handler must log the id of the order that was just + // persisted by addArray(), not the department id from the request body. + // Without this, the audit trail for the "check-in creates 0-orders" bug + // is useless — every successful create logs the wrong identifier. + expect($content)->toContain("'Successfully added an order (ID: ' . (int)\$order->id . ')'"); + + // Guard against the previous copy/paste regression reappearing. + expect($content)->not->toContain("'Successfully added an order (ID: ' . \$data['department_id'] . ')'"); +});