Added pipeline format logic in panel box validation #1519
@@ -291,6 +291,10 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
if ($state && str_contains($state, '|'))
|
if ($state && str_contains($state, '|'))
|
||||||
{
|
{
|
||||||
|
$splits = explode('|', $state);
|
||||||
|
$iCode = trim($splits[0]);
|
||||||
|
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||||
|
|
||||||
if (strpos($state, '|') == false) {
|
if (strpos($state, '|') == false) {
|
||||||
$set('validationError', 'Scan valid QR code. (Ex: Item_Code|Serial_Number)');
|
$set('validationError', 'Scan valid QR code. (Ex: Item_Code|Serial_Number)');
|
||||||
$set('part_validation_type', null);
|
$set('part_validation_type', null);
|
||||||
@@ -331,18 +335,16 @@ class PanelBoxValidationResource extends Resource
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$existInMasterPo = PanelGrMaster::where('document_number', $pOrder)->where('plant_id', $plantId)->first();
|
$existInMasterPo = PanelGrMaster::where('document_number', $pOrder)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
if(!$existInMasterPo){
|
if($existInMasterPo){
|
||||||
Notification::make()
|
|
||||||
->title('Panel GR Record')
|
$serialPart = substr($sNumber, -10);
|
||||||
->body("Production Order (Or) Doc No'{$pOrder}' not found against plant code '{$plaCode}' in Panel Gr master.")
|
|
||||||
->danger()
|
$serialNumber = substr($serialPart, 0, 4) . '/'
|
||||||
->send();
|
. substr($serialPart, 4, 6);
|
||||||
$set('item_id', null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$iId = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
$iId = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
@@ -376,15 +378,6 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
return;
|
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){
|
else if($existInMaster->quantity == '' || $existInMaster->quantity == null){
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Panel GR Found')
|
->title('Panel GR Found')
|
||||||
@@ -426,55 +419,33 @@ class PanelBoxValidationResource extends Resource
|
|||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
$set('item_id', $iCode);
|
||||||
|
$set('serial_number', $serialNumber);
|
||||||
$set('validationError', null);
|
$set('validationError', null);
|
||||||
}
|
}
|
||||||
}
|
else{
|
||||||
if (str_contains($state, '|')) {
|
$existInMasterProdOrder = ProductionOrder::where('production_order', $pOrder)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
$parts = array_map('trim', explode('|', $state));
|
if(!$existInMasterProdOrder && !$existInMasterPo){
|
||||||
|
|
||||||
if (count($parts) != 2) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid QR Format')
|
->title('Production Order Not Found')
|
||||||
->body('Expected format: ItemCode|SerialNumber')
|
->body("Production Order (Or) Doc No'{$pOrder}' not found against plant code '{$plaCode}' in both production order and Panel Gr master.")
|
||||||
->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.")
|
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
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();
|
$iId = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
if(!$iId){
|
if(!$iId){
|
||||||
@@ -484,54 +455,7 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
return;
|
$set('serial_exists', false);
|
||||||
}
|
|
||||||
|
|
||||||
$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);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,22 +468,86 @@ class PanelBoxValidationResource extends Resource
|
|||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$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();
|
$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()
|
Notification::make()
|
||||||
->title('Quantity Completed')
|
->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()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
|
$set('serial_exists', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$set('item_id', $iCode);
|
||||||
|
$set('serial_number', $serialNumber);
|
||||||
|
$set('validationError', null);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (str_contains($state, '/'))
|
}
|
||||||
|
else if (str_contains($state, '/'))
|
||||||
{
|
{
|
||||||
$parts = explode('/', $state);
|
$parts = explode('/', $state);
|
||||||
|
|
||||||
@@ -794,18 +782,18 @@ class PanelBoxValidationResource extends Resource
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
if($plantCode != $supplier){
|
// if($plantCode != $supplier){
|
||||||
Notification::make()
|
// Notification::make()
|
||||||
->title('Supplier Mismatch')
|
// ->title('Supplier Mismatch')
|
||||||
->body("Supplier code '$supplier' mismatch with selected plant code '$plantCode'.")
|
// ->body("Supplier code '$supplier' mismatch with selected plant code '$plantCode'.")
|
||||||
->danger()
|
// ->danger()
|
||||||
->send();
|
// ->send();
|
||||||
$set('item_id', null);
|
// $set('item_id', null);
|
||||||
$set('serial_exists', false);
|
// $set('serial_exists', false);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ($existInMasterProdOrder->item_id != $iId->id) {
|
if ($existInMasterProdOrder->item_id != $iId->id) {
|
||||||
$itemCodePOrd = Item::where('id', $existInMasterProdOrder->item_id)->value('code');
|
$itemCodePOrd = Item::where('id', $existInMasterProdOrder->item_id)->value('code');
|
||||||
|
|||||||
Reference in New Issue
Block a user