Updated quantity exceed validation against process order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled

This commit is contained in:
dhanabalan
2026-03-13 14:54:11 +05:30
parent 5aa2e7a871
commit 58b801b8e2

View File

@@ -728,6 +728,17 @@ class PdfController extends Controller
], 404);
}
if ($scrapQty == null || $scrapQty == '') {
$scrapQty = 0;
}
if ($rework == null || $rework == '' || ! $rework) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework value can't be empty!",
], 404);
}
$line = Line::where('name', $lineName)->first();
if (! $line) {
@@ -895,20 +906,6 @@ class PdfController extends Controller
$total = $alreadyReceived + $receivedQty;
if ($total > $orderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Received quantity should not exceed order quantity! Order Qty = {$orderQty}, Already Received Qty = {$alreadyReceived}, Trying to Insert Qty = {$receivedQty}",
], 404);
}
if ($rework == null || $rework == '' || ! $rework) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework value can't be empty!",
], 404);
}
if ($rework != 'Yes' && $rework != 'No') {
return response()->json([
'status_code' => 'ERROR',
@@ -949,6 +946,13 @@ class PdfController extends Controller
], 404);
}
if ($total > $orderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Received quantity should not exceed order quantity! Order Qty = {$orderQty}, Already Received Qty = {$alreadyReceived}, Trying to Insert Qty = {$receivedQty}",
], 404);
}
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
@@ -994,7 +998,7 @@ class PdfController extends Controller
]);
}
} else {
if ($coilNo >= 1) {
if ($coilNo > 1) {
$prevCoilNo = (string) ($coilNo - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
@@ -1004,7 +1008,7 @@ class PdfController extends Controller
if (! $existPrevCoil) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Previouse coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404);
}
}
@@ -1022,6 +1026,19 @@ class PdfController extends Controller
], 404);
}
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('item_id', $itemId)
->where('coil_number', $coilNo)
->first();
if ($existPrevCoil->received_quantity < $receivedQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Rework received quantity should not exceed exist received quantity! Exist Received Qty = {$existPrevCoil->received_quantity}, Trying to Insert Qty = {$receivedQty}",
], 404);
}
$updated = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineNamePlantId)
@@ -1070,7 +1087,7 @@ class PdfController extends Controller
], 404);
}
if ($coilNo >= 1) {
if ($coilNo > 1) {
$prevCoilNo = (string) ($coilNo - 1);
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
@@ -1080,11 +1097,18 @@ class PdfController extends Controller
if (! $existPrevCoil) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Previouse coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
], 404);
}
}
if ($total > $orderQty) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Received quantity should not exceed order quantity! Order Qty = {$orderQty}, Already Received Qty = {$alreadyReceived}, Trying to Insert Qty = {$receivedQty}",
], 404);
}
ProcessOrder::Create(
[
'plant_id' => $plantId,