Merge pull request 'Updated sfg_number validations as optional and check duplcate only if it exist' (#20) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s

Reviewed-on: #20
This commit was merged in pull request #20.
This commit is contained in:
2025-11-29 06:52:08 +00:00

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,19 +777,23 @@ class PdfController extends Controller
], 404); ], 404);
} }
$existing = ProcessOrder::where('plant_id', $plantId)
->where('sfg_number', $sfgNo)
->first();
if ($existing) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "SFG number '{$sfgNo}' already exist for the plant code '{$plantCode}'!",
], 404);
}
$itemId = $itemPlant->id; $itemId = $itemPlant->id;
if ($sfgNo != null && $sfgNo != '' && Str::length($sfgNo) > 0 && $sfgNo) {
$existing = ProcessOrder::where('plant_id', $plantId)
->where('sfg_number', $sfgNo)
->first();
if ($existing) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "SFG number '{$sfgNo}' already exist for the plant code '{$plantCode}'!",
], 404);
}
} else {
$sfgNo = null;
}
$existing = ProcessOrder::where('plant_id', $plantId) $existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder) ->where('process_order', $processOrder)
->where('item_id', '!=', $itemId) ->where('item_id', '!=', $itemId)