From 43ee1a3502200bb9035d564015134a0ad50fc977 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 15 Nov 2025 19:27:48 +0530 Subject: [PATCH] Refactor code structure for improved readability and maintainability and Commented imported invoice logic on warning --- .../Resources/InvoiceValidationResource.php | 97 +-- .../Pages/CreateInvoiceValidation.php | 698 +++++++++--------- 2 files changed, 398 insertions(+), 397 deletions(-) diff --git a/app/Filament/Resources/InvoiceValidationResource.php b/app/Filament/Resources/InvoiceValidationResource.php index 55d45bf..3940b81 100644 --- a/app/Filament/Resources/InvoiceValidationResource.php +++ b/app/Filament/Resources/InvoiceValidationResource.php @@ -491,10 +491,10 @@ class InvoiceValidationResource extends Resource if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->send(); + ->title('Invalid Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } @@ -513,10 +513,10 @@ class InvoiceValidationResource extends Resource } else if (!empty($uniqueSerialCodes)) { Notification::make() - ->title('Invalid Serial Number') - ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) - ->danger() - ->send(); + ->title('Invalid Serial Number') + ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueSerialCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } @@ -524,10 +524,10 @@ class InvoiceValidationResource extends Resource } else if (!empty($duplicateSerialCodes)) { Notification::make() - ->title('Duplicate Serial Numbers') - ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) - ->danger() - ->send(); + ->title('Duplicate Serial Numbers') + ->body('The following serial numbers are already exist in imported excel:
' . implode(', ', $duplicateSerialCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } @@ -540,9 +540,9 @@ class InvoiceValidationResource extends Resource ->danger() // This makes the notification red to indicate an error ->body('Uploaded Excel sheet is empty or
contains no valid data.') ->send(); - if ($disk->exists($path)) { - $disk->delete($path); - } + if ($disk->exists($path)) { + $disk->delete($path); + } return; } @@ -610,7 +610,7 @@ class InvoiceValidationResource extends Resource } else { - // Save full file path to session + // Save full file path to session session(['uploaded_invoice_path' => $fullPath]); Notification::make() ->title('Serial invoice imported successfully.') @@ -800,16 +800,17 @@ class InvoiceValidationResource extends Resource if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->send(); + ->title('Invalid Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); } return; } + if (!empty($uniqueaplhaMat)) { Notification::make() ->title('Invalid Material Quantity') @@ -822,6 +823,7 @@ class InvoiceValidationResource extends Resource } return; } + if (!empty($uniqueZeroMat)) { Notification::make() ->title('Invalid Material Quantity') @@ -837,8 +839,8 @@ class InvoiceValidationResource extends Resource if (!empty($uniqueEmptyMat)) { Notification::make() - ->title('Missing Material Quantity') - ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueEmptyMat)) + ->title('Missing Material Quantity') + ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueEmptyMat)) ->danger() ->send(); @@ -854,23 +856,24 @@ class InvoiceValidationResource extends Resource ->danger() // This makes the notification red to indicate an error ->body('Uploaded Excel sheet is empty or
contains no valid data.') ->send(); - if ($disk->exists($path)) { - $disk->delete($path); - } + + if ($disk->exists($path)) { + $disk->delete($path); + } return; } - $uniqueCodes = array_unique($materialCodes); + $uniqueCodes = array_unique($materialCodes); - $matchedItems = StickerMaster::with('item') - ->whereHas('item', function ($query) use ($uniqueCodes) { - $query->whereIn('code', $uniqueCodes); - }) - ->get(); + $matchedItems = StickerMaster::with('item') + ->whereHas('item', function ($query) use ($uniqueCodes) { + $query->whereIn('code', $uniqueCodes); + }) + ->get(); - $matchedCodes = $matchedItems->pluck('item.code')->toArray(); + $matchedCodes = $matchedItems->pluck('item.code')->toArray(); - $missingCodes = array_diff($uniqueCodes, $matchedCodes); + $missingCodes = array_diff($uniqueCodes, $matchedCodes); if (!empty($missingCodes)) { @@ -893,18 +896,18 @@ class InvoiceValidationResource extends Resource } $invalidCodes = $matchedItems - ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid - ->pluck('item.code') - ->toArray(); + ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid + ->pluck('item.code') + ->toArray(); if (count($invalidCodes) > 10) { $invalidCodes = array_unique($invalidCodes); Notification::make() - ->title('Invalid item codes found') - ->body('' . count($invalidCodes) . 'invalid item codes found have serial number.') - ->danger() - ->send(); + ->title('Invalid item codes found') + ->body('' . count($invalidCodes) . 'invalid item codes found have serial number.') + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); @@ -915,10 +918,10 @@ class InvoiceValidationResource extends Resource { $invalidCodes = array_unique($invalidCodes); Notification::make() - ->title('Invalid item codes found') - ->body('Serial invoice Item Codes found : ' . implode(', ', $invalidCodes)) - ->danger() - ->send(); + ->title('Invalid item codes found') + ->body('Serial invoice Item Codes found : ' . implode(', ', $invalidCodes)) + ->danger() + ->send(); if ($disk->exists($path)) { $disk->delete($path); @@ -996,9 +999,9 @@ class InvoiceValidationResource extends Resource // Save full file path to session session(['uploaded_material_invoice' => $fullPath]); Notification::make() - ->title('Material invoice imported successfully.') - ->success() - ->send(); + ->title('Material invoice imported successfully.') + ->success() + ->send(); } } diff --git a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php index 7dd3b6b..0a796a6 100644 --- a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php +++ b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php @@ -142,7 +142,7 @@ class CreateInvoiceValidation extends CreateRecord $totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') $scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - if($totMQuan > 0) + if ($totMQuan > 0) { $this->form->fill([ 'plant_id' => $plantId, @@ -185,7 +185,7 @@ class CreateInvoiceValidation extends CreateRecord // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - if($updateStatus == '1') + if ($updateStatus == '1') { //'Material invoice update in progress...'; $filename = $invoiceNumber . '.xlsx'; @@ -199,7 +199,7 @@ class CreateInvoiceValidation extends CreateRecord // Now you can read/process the file here $rows = Excel::toArray(null, $fullPath)[0]; - if((count($rows) - 1) <= 0) + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Records Not Found') @@ -234,7 +234,7 @@ class CreateInvoiceValidation extends CreateRecord } if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; } @@ -243,11 +243,11 @@ class CreateInvoiceValidation extends CreateRecord if (empty($materialQuantity)) { $missingQuantities[] = $materialCode; } - else if(!is_numeric($materialQuantity)) + else if (!is_numeric($materialQuantity)) { $invalidMatQuan[] = $materialCode; } - else if($materialQuantity == 0) + else if ($materialQuantity == 0) { $invalidMatQuan[] = $materialCode; } @@ -264,34 +264,20 @@ class CreateInvoiceValidation extends CreateRecord } } - if (!$validRowsFound) { - Notification::make() - ->title('Invalid Material Invoice') - ->danger() // This makes the notification red to indicate an error - ->body('Uploaded Excel sheet is empty or
contains no valid data.') - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - $uniqueInvalidCodes = array_unique($invalidMatCodes); if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(2) + ->send(); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -304,11 +290,11 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(2) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -321,8 +307,23 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(2) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + if (!$validRowsFound) { + Notification::make() + ->title('Invalid Material Invoice') + ->danger() // This makes the notification red to indicate an error + ->body('Uploaded Excel sheet is empty or
contains no valid data.') + ->seconds(2) + ->send(); + + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -356,9 +357,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -387,9 +388,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -413,9 +414,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -452,9 +453,9 @@ class CreateInvoiceValidation extends CreateRecord if ($totalExcelQty == 0) { $zeroQtyCodes[] = $code; - } elseif (!is_numeric($totalExcelQty)) { + } else if (!is_numeric($totalExcelQty)) { $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too - } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { + } else if ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { $notDivisibleCodes[] = $code; } } @@ -484,11 +485,10 @@ class CreateInvoiceValidation extends CreateRecord $showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':"); $showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity."); - if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } else @@ -654,11 +654,11 @@ class CreateInvoiceValidation extends CreateRecord // 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0 // 0 > 0 - if($existEmpQty > 0) // update + if ($existEmpQty > 0) // update { // 3 = 6 // 5 = 5 // 0 = 3 // 8 = 9 // 0 = 5 - if($existEmpQty == $newInsQty) { continue; } + if ($existEmpQty == $newInsQty) { continue; } // $existEmpRecQty->delete(); $existEmpRecQty->update([ 'quantity' => $newInsQty, @@ -687,10 +687,10 @@ class CreateInvoiceValidation extends CreateRecord $newInsQty = $totalExcelQty - $existComQty; // 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0 - if($existEmpQty > 0) // update + if ($existEmpQty > 0) // update { // 3 = 2 // 5 = 4 // 0 = -1 // 8 = 7 - if($existEmpQty == $newInsQty) { continue; } + if ($existEmpQty == $newInsQty) { continue; } // $existEmpRecQty->delete(); $existEmpRecQty->update([ 'quantity' => $newInsQty, @@ -712,14 +712,13 @@ class CreateInvoiceValidation extends CreateRecord $inserted++; } } - } } if ($inserted > 0 || $oldQuan != $newQuan) { Notification::make() - ->title("Material invoice successfully updatad.") + ->title("Material invoice successfully updated.") ->success() ->seconds(1) ->send(); @@ -754,9 +753,9 @@ class CreateInvoiceValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); } @@ -781,9 +780,9 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; @@ -858,7 +857,7 @@ class CreateInvoiceValidation extends CreateRecord $this->dispatch('playNotificationSound'); $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - if($updateStatus == '1') + if ($updateStatus == '1') { $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; @@ -866,7 +865,7 @@ class CreateInvoiceValidation extends CreateRecord $filePath = $directory . '/' . $filename; $fullPath = $disk->path($filePath); - // Check if file exists //$disk->exists($filePath) + // Check if file exists //if ($disk->exists($filePath)) if ($fullPath && file_exists($fullPath)) { // /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx @@ -875,7 +874,7 @@ class CreateInvoiceValidation extends CreateRecord // Now you can read/process the file here $rows = Excel::toArray(null, $fullPath)[0]; - if((count($rows) - 1) <= 0) + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Records Not Found') @@ -913,17 +912,17 @@ class CreateInvoiceValidation extends CreateRecord if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; continue; } else { - if(empty($serialNumber)) { + if (empty($serialNumber)) { $missingSerials[] = $materialCode; } - else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) + else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) { $invalidSerCodes[] = $serialNumber; } @@ -948,6 +947,74 @@ class CreateInvoiceValidation extends CreateRecord } } + $uniqueInvalidCodes = array_unique($invalidMatCodes); + + if (!empty($uniqueInvalidCodes)) { + Notification::make() + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueMissingSerials = array_unique($missingSerials); + + if (!empty($uniqueMissingSerials)) { + Notification::make() + ->title('Missing Serial Numbers') + ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueInvalidSerCodes = array_unique($invalidSerCodes); + + if (!empty($uniqueInvalidSerCodes)) { + Notification::make() + ->title('Invalid Serial Numbers') + ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueDupSerCodes = array_unique($duplicateSerials); + + if (!empty($uniqueDupSerCodes)) { + Notification::make() + ->title('Duplicate Serial Numbers') + ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) + ->danger() + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + if (!$validRowsFound) { Notification::make() ->title('Invalid Serial Invoice') @@ -955,29 +1022,11 @@ class CreateInvoiceValidation extends CreateRecord ->body('Uploaded excel sheet is empty or
contains no valid data.') ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidCodes = array_unique($invalidMatCodes); - - if (!empty($uniqueInvalidCodes)) { - Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(3) - ->send(); $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1009,9 +1058,9 @@ class CreateInvoiceValidation extends CreateRecord $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1040,9 +1089,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1065,9 +1114,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1090,62 +1139,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueMissingSerials = array_unique($missingSerials); - - if (!empty($uniqueMissingSerials)) { - Notification::make() - ->title('Missing Serial Numbers') - ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) - ->danger() - ->seconds(3) - ->send(); - - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidSerCodes = array_unique($invalidSerCodes); - - if (!empty($uniqueInvalidSerCodes)) { - Notification::make() - ->title('Invalid Serial Numbers') - ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) - ->danger() - ->seconds(3) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueDupSerCodes = array_unique($duplicateSerials); - - if (!empty($uniqueDupSerCodes)) { - Notification::make() - ->title('Duplicate Serial Numbers') - ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) - ->danger() - ->seconds(3) - ->send(); - - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1188,7 +1184,7 @@ class CreateInvoiceValidation extends CreateRecord $sNoExist = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->exists(); //->pluck('serial_number') - if($sNoExist) { continue; } + if ($sNoExist) { continue; } $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) { $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode @@ -1245,9 +1241,10 @@ class CreateInvoiceValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); @@ -1273,9 +1270,9 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; @@ -1385,7 +1382,7 @@ class CreateInvoiceValidation extends CreateRecord // // Get the rows // $rows = $excelImport->getRows(); - if((count($rows) - 1) <= 0) + if ((count($rows) - 1) <= 0) { Notification::make() ->title('Records Not Found') @@ -1409,7 +1406,7 @@ class CreateInvoiceValidation extends CreateRecord $materialCode = trim($row[0]); if (!empty($materialCode)) { - if(Str::length($materialCode) < 6) + if (Str::length($materialCode) < 6) { continue; } @@ -1418,9 +1415,9 @@ class CreateInvoiceValidation extends CreateRecord $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) { $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode }); - if($sticker->exists()) + if ($sticker->exists()) { - if($sticker->first()->material_type && !empty($sticker->first()->material_type)) + if ($sticker->first()->material_type && !empty($sticker->first()->material_type)) { $invoiceType = "M"; break; @@ -1443,7 +1440,7 @@ class CreateInvoiceValidation extends CreateRecord } } - if($invoiceType == 'M') + if ($invoiceType == 'M') { $invalidMatCodes = []; $materialCodes = []; @@ -1463,7 +1460,7 @@ class CreateInvoiceValidation extends CreateRecord } if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; } @@ -1472,11 +1469,11 @@ class CreateInvoiceValidation extends CreateRecord if (empty($materialQuantity)) { $missingQuantities[] = $materialCode; } - else if(!is_numeric($materialQuantity)) + else if (!is_numeric($materialQuantity)) { $invalidMatQuan[] = $materialCode; } - else if($materialQuantity == 0) + else if ($materialQuantity == 0) { $invalidMatQuan[] = $materialCode; } @@ -1493,34 +1490,20 @@ class CreateInvoiceValidation extends CreateRecord } } - if (!$validRowsFound) { - Notification::make() - ->title('Invalid Material Invoice') - ->danger() // This makes the notification red to indicate an error - ->body('Uploaded Excel sheet is empty or
contains no valid data.') - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - $uniqueInvalidCodes = array_unique($invalidMatCodes); if (!empty($uniqueInvalidCodes)) { Notification::make() - ->title('Invalid: Item Codes') - ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) - ->danger() - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); + ->title('Invalid: Item Codes') + ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes)) + ->danger() + ->seconds(2) + ->send(); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1533,11 +1516,11 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(2) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1551,8 +1534,22 @@ class CreateInvoiceValidation extends CreateRecord ->seconds(2) ->send(); - $this->dispatch('playWarnSound'); + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + if (!$validRowsFound) { + Notification::make() + ->title('Invalid Material Invoice') + ->danger() // This makes the notification red to indicate an error + ->body('Uploaded Excel sheet is empty or
contains no valid data.') + ->seconds(2) + ->send(); + + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -1586,9 +1583,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1616,9 +1613,9 @@ class CreateInvoiceValidation extends CreateRecord ->seconds(2) ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1641,9 +1638,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -1679,9 +1676,9 @@ class CreateInvoiceValidation extends CreateRecord if ($totalExcelQty == 0) { $zeroQtyCodes[] = $code; - } elseif (!is_numeric($totalExcelQty)) { + } else if (!is_numeric($totalExcelQty)) { $nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too - } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { + } else if ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) { $notDivisibleCodes[] = $code; } } @@ -1708,9 +1705,9 @@ class CreateInvoiceValidation extends CreateRecord if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } else @@ -1855,9 +1852,10 @@ class CreateInvoiceValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); @@ -1882,16 +1880,16 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; } } } - else if($invoiceType == 'S') + else if ($invoiceType == 'S') { $invalidMatCodes = []; $materialCodes = []; @@ -1913,17 +1911,17 @@ class CreateInvoiceValidation extends CreateRecord } if (!empty($materialCode)) { - if(Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) + if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode)) { $invalidMatCodes[] = $materialCode; continue; } else { - if(empty($serialNumber)) { + if (empty($serialNumber)) { $missingSerials[] = $materialCode; } - else if(Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) + else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber)) { $invalidSerCodes[] = $serialNumber; } @@ -1945,21 +1943,6 @@ class CreateInvoiceValidation extends CreateRecord } } - if (!$validRowsFound) { - Notification::make() - ->title('Invalid Serial Invoice') - ->danger() // This makes the notification red to indicate an error - ->body('Uploaded excel sheet is empty or
contains no valid data.') - ->seconds(3) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - $uniqueInvalidCodes = array_unique($invalidMatCodes); if (!empty($uniqueInvalidCodes)) { @@ -1971,6 +1954,72 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueMissingSerials = array_unique($missingSerials); + + if (!empty($uniqueMissingSerials)) { + Notification::make() + ->title('Missing Serial Numbers') + ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) + ->danger() + ->seconds(3) + ->send(); + $this->dispatch('playWarnSound'); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueInvalidSerCodes = array_unique($invalidSerCodes); + + if (!empty($uniqueInvalidSerCodes)) { + Notification::make() + ->title('Invalid Serial Numbers') + ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) + ->danger() + ->seconds(3) + ->send(); + $this->dispatch('playWarnSound'); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + $uniqueDupSerCodes = array_unique($duplicateSerials); + + if (!empty($uniqueDupSerCodes)) { + Notification::make() + ->title('Duplicate Serial Numbers') + ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) + ->danger() + ->seconds(3) + ->send(); + $this->dispatch('playWarnSound'); + + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + return; + } + + if (!$validRowsFound) { + Notification::make() + ->title('Invalid Serial Invoice') + ->danger() // This makes the notification red to indicate an error + ->body('Uploaded excel sheet is empty or
contains no valid data.') + ->seconds(3) + ->send(); + + $this->dispatch('playWarnSound'); if ($disk->exists($filePath)) { $disk->delete($filePath); } @@ -2014,9 +2063,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2043,11 +2092,11 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2068,11 +2117,11 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2093,62 +2142,11 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueMissingSerials = array_unique($missingSerials); - - if (!empty($uniqueMissingSerials)) { - Notification::make() - ->title('Missing Serial Numbers') - ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials)) - ->danger() - ->seconds(3) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueInvalidSerCodes = array_unique($invalidSerCodes); - - if (!empty($uniqueInvalidSerCodes)) { - Notification::make() - ->title('Invalid Serial Numbers') - ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes)) - ->danger() - ->seconds(3) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } - return; - } - - $uniqueDupSerCodes = array_unique($duplicateSerials); - - if (!empty($uniqueDupSerCodes)) { - Notification::make() - ->title('Duplicate Serial Numbers') - ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes)) - ->danger() - ->seconds(3) - ->send(); - $this->dispatch('playWarnSound'); - - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2162,11 +2160,11 @@ class CreateInvoiceValidation extends CreateRecord ->danger() ->seconds(3) ->send(); - $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + $this->dispatch('playWarnSound'); + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } @@ -2230,9 +2228,10 @@ class CreateInvoiceValidation extends CreateRecord } else { - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } + // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null; // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); @@ -2258,9 +2257,9 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); return; @@ -2276,9 +2275,9 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); - if ($disk->exists($filePath)) { - $disk->delete($filePath); - } + // if ($disk->exists($filePath)) { + // $disk->delete($filePath); + // } return; } } @@ -2355,7 +2354,7 @@ class CreateInvoiceValidation extends CreateRecord $totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') $scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - if($totQuan <= 0) + if ($totQuan <= 0) { Notification::make() ->title('Invoice Not Found') @@ -2440,7 +2439,7 @@ class CreateInvoiceValidation extends CreateRecord $curScanQty = $matches['batch_quantity']; $serNo = null; - if(empty($matches['batch_id']) || !$matches['batch_id']) + if (empty($matches['batch_id']) || !$matches['batch_id']) { Notification::make() ->danger() @@ -2478,7 +2477,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - elseif (empty($matches['batch_count']) || !$matches['batch_count']) + else if (empty($matches['batch_count']) || !$matches['batch_count']) { Notification::make() ->danger() @@ -2518,7 +2517,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - elseif(!is_numeric($curScanQty)) + else if (!is_numeric($curScanQty)) { Notification::make() ->danger() @@ -2558,14 +2557,14 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - } elseif (preg_match($pattern2, $serNo, $matches)) { + } else if (preg_match($pattern2, $serNo, $matches)) { $itemCode = $matches['item_code']; $this->currentItemCode = $itemCode; $batchNumber = $matches['batch_number']; $serialNumber = $matches['batch_id'] . '-' . $matches['batch_count']; $serNo = null; - if(empty($matches['batch_id']) || !$matches['batch_id']) + if (empty($matches['batch_id']) || !$matches['batch_id']) { Notification::make() ->danger() @@ -2602,7 +2601,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - elseif (empty($matches['batch_count']) || !$matches['batch_count']) + else if (empty($matches['batch_count']) || !$matches['batch_count']) { Notification::make() ->danger() @@ -2638,14 +2637,14 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - } elseif (preg_match($pattern3, $serNo, $matches)) { + } else if (preg_match($pattern3, $serNo, $matches)) { $itemCode = $matches['item_code']; $this->currentItemCode = $itemCode; $batchNumber = null; // batch_number not present in this pattern $serialNumber = $matches['batch_id'] . '-' . $matches['batch_count']; $serNo = null; - if(empty($matches['batch_id']) || !$matches['batch_id']) + if (empty($matches['batch_id']) || !$matches['batch_id']) { Notification::make() ->danger() @@ -2683,7 +2682,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - elseif (empty($matches['batch_count']) || !$matches['batch_count']) + else if (empty($matches['batch_count']) || !$matches['batch_count']) { Notification::make() ->danger() @@ -2996,9 +2995,9 @@ class CreateInvoiceValidation extends CreateRecord return; } - if($hasQuanTyp) + if ($hasQuanTyp) { - if(!is_numeric($curScanQty)) + if (!is_numeric($curScanQty)) { Notification::make() ->danger() @@ -3024,7 +3023,7 @@ class CreateInvoiceValidation extends CreateRecord $curExistQty = $record->quantity; // $curScanQty = 2; - if($curExistQty > $curScanQty) // 5 > 2 + if ($curExistQty > $curScanQty) // 5 > 2 { $record->quantity = $curExistQty - $curScanQty; // 5 - 2 $record->operator_id = $operatorName; @@ -3042,7 +3041,7 @@ class CreateInvoiceValidation extends CreateRecord 'operator_id'=> $operatorName, ]); } - else if($curExistQty == $curScanQty) // 2 = 2 + else if ($curExistQty == $curScanQty) // 2 = 2 { // $record->delete(); $record->serial_number = $serialNumber; @@ -3083,7 +3082,7 @@ class CreateInvoiceValidation extends CreateRecord } else { - if(str_contains($serialNumber, '|')) + if (str_contains($serialNumber, '|')) { $itemCode = null; $this->currentItemCode = ''; @@ -3112,7 +3111,7 @@ class CreateInvoiceValidation extends CreateRecord } $record->serial_number = $serialNumber; - // if($batchNumber && !empty($batchNumber)) {} + // if ($batchNumber && !empty($batchNumber)) {} $record->batch_number = $batchNumber; // $record->updated_at = now(); $record->operator_id = $operatorName; @@ -3130,7 +3129,7 @@ class CreateInvoiceValidation extends CreateRecord $scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - if($totQuan == $scannedMQuantity) + if ($totQuan == $scannedMQuantity) { Notification::make() ->title('Completed: Material Invoice') @@ -3517,7 +3516,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - else if($hadMotorQr == $hasMotorQr) + else if ($hadMotorQr == $hasMotorQr) { Notification::make() ->title('Duplicate: Motor QR') @@ -3560,8 +3559,8 @@ class CreateInvoiceValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->motor_scanned_status = 1; - //if($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr) - if($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) + //if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr) + if ($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) { $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt; @@ -3571,7 +3570,7 @@ class CreateInvoiceValidation extends CreateRecord $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; - if($packCnt == $scanCnt) + if ($packCnt == $scanCnt) { $record->scanned_status = 'Scanned'; } @@ -3600,7 +3599,7 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if($totQuan == $scannedQuantity) + if ($totQuan == $scannedQuantity) { Notification::make() ->title('Completed: Serial Invoice') @@ -3626,7 +3625,6 @@ class CreateInvoiceValidation extends CreateRecord \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); } - $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; $disk = Storage::disk('local'); @@ -3684,7 +3682,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - else if($hadPumpQr == $hasPumpQr) + else if ($hadPumpQr == $hasPumpQr) { Notification::make() ->title('Duplicate: Pump QR') @@ -3725,8 +3723,8 @@ class CreateInvoiceValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->pump_scanned_status = 1; - // if($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) - if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) + // if ($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) + if ($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) { $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt; @@ -3736,7 +3734,7 @@ class CreateInvoiceValidation extends CreateRecord $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; - if($packCnt == $scanCnt) + if ($packCnt == $scanCnt) { $record->scanned_status = 'Scanned'; } @@ -3765,7 +3763,7 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if($totQuan == $scannedQuantity) + if ($totQuan == $scannedQuantity) { Notification::make() ->title('Completed: Serial Invoice') @@ -3811,7 +3809,7 @@ class CreateInvoiceValidation extends CreateRecord } return; } - elseif ($isMarkC) { + else if ($isMarkC) { if (!$hasCapacitorQr) { Notification::make() @@ -3852,7 +3850,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - else if($hadCapacitorQr == '1' && $hasCapacitorQr) + else if ($hadCapacitorQr == '1' && $hasCapacitorQr) { Notification::make() ->title('Duplicate: Capacitor QR') @@ -3911,7 +3909,7 @@ class CreateInvoiceValidation extends CreateRecord return; } - elseif ($isMarkPs) + else if ($isMarkPs) { if (!$hasPumpSetQr) { @@ -3951,7 +3949,7 @@ class CreateInvoiceValidation extends CreateRecord ]); return; } - else if($hadPumpSetQr == $hasPumpSetQr) + else if ($hadPumpSetQr == $hasPumpSetQr) { Notification::make() ->title('Duplicate: Pump Set QR') @@ -3993,8 +3991,8 @@ class CreateInvoiceValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->scanned_status_set = 1; - // if($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) - if($hasMotorQr || $hasPumpQr || $hasCapacitorQr) + // if ($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) + if ($hasMotorQr || $hasPumpQr || $hasCapacitorQr) { $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; $packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt; @@ -4004,7 +4002,7 @@ class CreateInvoiceValidation extends CreateRecord $scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt; $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt; - if($packCnt == $scanCnt) + if ($packCnt == $scanCnt) { $record->scanned_status = 'Scanned'; } @@ -4033,7 +4031,7 @@ class CreateInvoiceValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - if($totQuan == $scannedQuantity) + if ($totQuan == $scannedQuantity) { Notification::make() ->title('Completed: Serial Invoice')