Merge pull request 'Added pipeline format logic in panel box validation' (#1519) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 23s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 23s
Reviewed-on: #1519
This commit was merged in pull request #1519.
This commit is contained in:
@@ -291,6 +291,10 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
if ($state && str_contains($state, '|'))
|
||||
{
|
||||
$splits = explode('|', $state);
|
||||
$iCode = trim($splits[0]);
|
||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
if (strpos($state, '|') == false) {
|
||||
$set('validationError', 'Scan valid QR code. (Ex: Item_Code|Serial_Number)');
|
||||
$set('part_validation_type', null);
|
||||
@@ -331,18 +335,16 @@ class PanelBoxValidationResource extends Resource
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$existInMasterPo = PanelGrMaster::where('document_number', $pOrder)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$existInMasterPo){
|
||||
Notification::make()
|
||||
->title('Panel GR Record')
|
||||
->body("Production Order (Or) Doc No'{$pOrder}' not found against plant code '{$plaCode}' in Panel Gr master.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
if($existInMasterPo){
|
||||
|
||||
$serialPart = substr($sNumber, -10);
|
||||
|
||||
$serialNumber = substr($serialPart, 0, 4) . '/'
|
||||
. substr($serialPart, 4, 6);
|
||||
|
||||
$iId = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
@@ -376,15 +378,6 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
// else if($existInMaster->supplier_number != $supplier){
|
||||
// Notification::make()
|
||||
// ->title('Panel GR Found')
|
||||
// ->body("Supplier code not match for Production Order (Or) Doc No'{$pOrder}' and Item '{$iCode}'.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// $set('item_id', null);
|
||||
// return;
|
||||
// }
|
||||
else if($existInMaster->quantity == '' || $existInMaster->quantity == null){
|
||||
Notification::make()
|
||||
->title('Panel GR Found')
|
||||
@@ -426,55 +419,33 @@ class PanelBoxValidationResource extends Resource
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
$set('item_id', $iCode);
|
||||
$set('serial_number', $serialNumber);
|
||||
$set('validationError', null);
|
||||
}
|
||||
}
|
||||
if (str_contains($state, '|')) {
|
||||
else{
|
||||
$existInMasterProdOrder = ProductionOrder::where('production_order', $pOrder)->where('plant_id', $plantId)->first();
|
||||
|
||||
$parts = array_map('trim', explode('|', $state));
|
||||
|
||||
if (count($parts) != 2) {
|
||||
if(!$existInMasterProdOrder && !$existInMasterPo){
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body('Expected format: ItemCode|SerialNumber')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$itemCode = $parts[0];
|
||||
$serialNumber = $parts[1];
|
||||
|
||||
if($serialNumber == '' || $serialNumber == null){
|
||||
Notification::make()
|
||||
->title('Unknown Serial number')
|
||||
->body("Serial number can't be empty!")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
elseif (! ctype_alnum($serialNumber)) {
|
||||
$set('validationError', 'Serial Number should contain alpha-numeric values.');
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$existInMasterPo = PanelGrMaster::where('document_number', $pOrder)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$existInMasterPo){
|
||||
Notification::make()
|
||||
->title('Panel GR Record')
|
||||
->body("Production Order (Or) Doc No'{$pOrder}' not found against plant code '{$plaCode}' in Panel Gr master.")
|
||||
->title('Production Order Not Found')
|
||||
->body("Production Order (Or) Doc No'{$pOrder}' not found against plant code '{$plaCode}' in both production order and Panel Gr master.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
$itemCode = $iCode;
|
||||
$supplier = substr($sNumber, 0, -10);
|
||||
|
||||
$serialPart = substr($sNumber, -10);
|
||||
|
||||
$serialNumber = substr($serialPart, 0, 4) . '/'
|
||||
. substr($serialPart, 4, 6);
|
||||
|
||||
$iId = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$iId){
|
||||
@@ -484,54 +455,7 @@ class PanelBoxValidationResource extends Resource
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
|
||||
$existInMaster = PanelGrMaster::where('document_number', $pOrder)->where('item_id', $iId->id)->where('plant_id', $plantId)->first();
|
||||
|
||||
if(!$existInMaster){
|
||||
Notification::make()
|
||||
->title('Panel GR Record Not Found')
|
||||
->body("No Panel GR record found for Production Order (Or) Doc No'{$pOrder}' and for Item '{$itemCode}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
else if($existInMaster->supplier_number == '' || $existInMaster->supplier_number == null){
|
||||
Notification::make()
|
||||
->title('Panel GR Found')
|
||||
->body("Supplier Number cannot be empty Panel GR record found for Production Order '{$pOrder}' and Item '{$itemCode}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
// else if($existInMaster->supplier_number != $supplier){
|
||||
// Notification::make()
|
||||
// ->title('Panel GR Found')
|
||||
// ->body("Supplier code not match for Production Order (Or) Doc No'{$pOrder}' and Item '{$iCode}'.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// $set('item_id', null);
|
||||
// return;
|
||||
// }
|
||||
else if($existInMaster->quantity == '' || $existInMaster->quantity == null){
|
||||
Notification::make()
|
||||
->title('Panel GR Found')
|
||||
->body("Quantity cannot be empty Panel GR record found for Production Order '{$pOrder}' and Item '{$itemCode}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
return;
|
||||
}
|
||||
else if($existInMaster->invoice_number == '' || $existInMaster->invoice_number == null){
|
||||
Notification::make()
|
||||
->title('Panel GR Found')
|
||||
->body("Invoice Number cannot be empty Panel GR record found for Production Order '{$pOrder}' and Item '{$itemCode}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -544,22 +468,86 @@ class PanelBoxValidationResource extends Resource
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
$panelExistsInvoice = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('panel_box_serial_number', $serialNumber)
|
||||
->where('panel_box_supplier', $supplier)
|
||||
->first();
|
||||
|
||||
if ($panelExistsInvoice) {
|
||||
Notification::make()
|
||||
->title('Duplicate Panel Box Serial Number')
|
||||
->body("Duplicate panel already exists.<br>Panel Box Code: $itemCode, Serial Number: $serialNumber, Supplier Number: $supplier against invoice Number: $panelExistsInvoice->invoice_number")
|
||||
->danger()
|
||||
->seconds(4)
|
||||
->send();
|
||||
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
// if($plantCode != $supplier){
|
||||
// Notification::make()
|
||||
// ->title('Supplier Mismatch')
|
||||
// ->body("Supplier code '$supplier' mismatch with selected plant code '$plantCode'.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// $set('item_id', null);
|
||||
// $set('serial_exists', false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ($existInMasterProdOrder->item_id != $iId->id) {
|
||||
$itemCodePOrd = Item::where('id', $existInMasterProdOrder->item_id)->value('code');
|
||||
|
||||
Notification::make()
|
||||
->title('Panel Box Code Mismatch')
|
||||
->body("Scanned Panel Box Code '$itemCode' not matched with produciton order item code '$itemCodePOrd'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
if($existInMasterProdOrder->quantity == '' || $existInMasterProdOrder->quantity == null){
|
||||
Notification::make()
|
||||
->title('Production Order Found')
|
||||
->body("Quantity cannot be empty in production order '{$pOrder}' and Item '{$itemCode}'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
$existQuanInPanel = PanelBoxValidation::where('plant_id', $plantId)->where('production_order', $pOrder)->where('sticker_master_id', $sticker->id)->count();
|
||||
|
||||
if ($existQuanInPanel >= (int) $existInMaster->quantity) {
|
||||
if ($existQuanInPanel >= (int) $existInMasterProdOrder->quantity) {
|
||||
Notification::make()
|
||||
->title('Quantity Completed')
|
||||
->body("Panel box quantity '{$existQuanInPanel}' exceeds the available quantity '{$existInMaster->quantity}' in Panel GR Master for Production Order '{$pOrder}' and Item '{$itemCode}'.")
|
||||
->body("Panel box quantity '{$existQuanInPanel}' exceeds the available quantity '{$existInMasterProdOrder->quantity}' for Production Order '{$pOrder}' and Item '{$itemCode}' in production order table.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
|
||||
$set('item_id', $iCode);
|
||||
$set('serial_number', $serialNumber);
|
||||
$set('validationError', null);
|
||||
|
||||
}
|
||||
if (str_contains($state, '/'))
|
||||
}
|
||||
else if (str_contains($state, '/'))
|
||||
{
|
||||
$parts = explode('/', $state);
|
||||
|
||||
@@ -794,18 +782,18 @@ class PanelBoxValidationResource extends Resource
|
||||
return;
|
||||
}
|
||||
|
||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||
|
||||
if($plantCode != $supplier){
|
||||
Notification::make()
|
||||
->title('Supplier Mismatch')
|
||||
->body("Supplier code '$supplier' mismatch with selected plant code '$plantCode'.")
|
||||
->danger()
|
||||
->send();
|
||||
$set('item_id', null);
|
||||
$set('serial_exists', false);
|
||||
return;
|
||||
}
|
||||
// if($plantCode != $supplier){
|
||||
// Notification::make()
|
||||
// ->title('Supplier Mismatch')
|
||||
// ->body("Supplier code '$supplier' mismatch with selected plant code '$plantCode'.")
|
||||
// ->danger()
|
||||
// ->send();
|
||||
// $set('item_id', null);
|
||||
// $set('serial_exists', false);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ($existInMasterProdOrder->item_id != $iId->id) {
|
||||
$itemCodePOrd = Item::where('id', $existInMasterProdOrder->item_id)->value('code');
|
||||
|
||||
Reference in New Issue
Block a user