Updated sfg_number validations as optional and check duplcate only if it exist
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 2m48s
Laravel Larastan / larastan (pull_request) Failing after 4m30s

This commit is contained in:
dhanabalan
2025-11-29 12:21:17 +05:30
parent f45bb7b74b
commit d6c7e43715

View File

@@ -633,8 +633,9 @@ class PdfController extends Controller
$plantCode = $request->header('plant-code'); $plantCode = $request->header('plant-code');
$processOrder = $request->header('process-order'); $processOrder = $request->header('process-order');
$data = $request->all();
Log::info('Process Order POST API >>', ['plant-code' => $plantCode, 'process-order' => $processOrder, 'post-data' => $request->all()]); Log::info('Process Order POST API >>', ['plant-code' => $plantCode, 'process-order' => $processOrder, 'post-data' => $data]);
if ($plantCode == null || $plantCode == '' || ! $plantCode) { if ($plantCode == null || $plantCode == '' || ! $plantCode) {
return response()->json([ return response()->json([
@@ -665,8 +666,6 @@ class PdfController extends Controller
$plantId = $plant->id; $plantId = $plant->id;
$data = $request->all();
$itemCode = $data['item_code'] ?? ''; $itemCode = $data['item_code'] ?? '';
$coilNo = $data['coil_number'] ?? ''; $coilNo = $data['coil_number'] ?? '';
$orderQty = $data['order_quantity'] ?? 0; $orderQty = $data['order_quantity'] ?? 0;
@@ -714,12 +713,12 @@ class PdfController extends Controller
], 404); ], 404);
} }
if ($sfgNo == null || $sfgNo == '' || ! $sfgNo) { // if ($sfgNo == null || $sfgNo == '' || ! $sfgNo) {
return response()->json([ // return response()->json([
'status_code' => 'ERROR', // 'status_code' => 'ERROR',
'status_description' => "SFG number can't be empty!", // 'status_description' => "SFG number can't be empty!",
], 404); // ], 404);
} // }
if ($machineId == null || $machineId == '' || ! $machineId) { if ($machineId == null || $machineId == '' || ! $machineId) {
return response()->json([ return response()->json([
@@ -778,6 +777,9 @@ class PdfController extends Controller
], 404); ], 404);
} }
$itemId = $itemPlant->id;
if ($sfgNo != null && $sfgNo != '' && Str::length($sfgNo) > 0 && $sfgNo) {
$existing = ProcessOrder::where('plant_id', $plantId) $existing = ProcessOrder::where('plant_id', $plantId)
->where('sfg_number', $sfgNo) ->where('sfg_number', $sfgNo)
->first(); ->first();
@@ -788,8 +790,9 @@ class PdfController extends Controller
'status_description' => "SFG number '{$sfgNo}' already exist for the plant code '{$plantCode}'!", 'status_description' => "SFG number '{$sfgNo}' already exist for the plant code '{$plantCode}'!",
], 404); ], 404);
} }
} else {
$itemId = $itemPlant->id; $sfgNo = null;
}
$existing = ProcessOrder::where('plant_id', $plantId) $existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)