Refactor code structure for improved readability and maintainability and Commented imported invoice logic on warning
This commit is contained in:
@@ -810,6 +810,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($uniqueaplhaMat)) {
|
if (!empty($uniqueaplhaMat)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Material Quantity')
|
->title('Invalid Material Quantity')
|
||||||
@@ -822,6 +823,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($uniqueZeroMat)) {
|
if (!empty($uniqueZeroMat)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Material Quantity')
|
->title('Invalid Material Quantity')
|
||||||
@@ -854,6 +856,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->danger() // This makes the notification red to indicate an error
|
->danger() // This makes the notification red to indicate an error
|
||||||
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
|
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,20 +264,6 @@ 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<br>contains no valid data.')
|
|
||||||
->seconds(2)
|
|
||||||
->send();
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
if ($disk->exists($filePath)) {
|
|
||||||
$disk->delete($filePath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||||
|
|
||||||
if (!empty($uniqueInvalidCodes)) {
|
if (!empty($uniqueInvalidCodes)) {
|
||||||
@@ -287,11 +273,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,11 +290,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,8 +307,23 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->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<br>contains no valid data.')
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
if ($disk->exists($filePath)) {
|
if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
$disk->delete($filePath);
|
||||||
}
|
}
|
||||||
@@ -356,9 +357,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,9 +388,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,9 +414,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,11 +485,10 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
|
$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.");
|
$showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
|
||||||
|
|
||||||
|
|
||||||
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -712,14 +712,13 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$inserted++;
|
$inserted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inserted > 0 || $oldQuan != $newQuan)
|
if ($inserted > 0 || $oldQuan != $newQuan)
|
||||||
{
|
{
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Material invoice successfully updatad.")
|
->title("Material invoice successfully updated.")
|
||||||
->success()
|
->success()
|
||||||
->seconds(1)
|
->seconds(1)
|
||||||
->send();
|
->send();
|
||||||
@@ -754,9 +753,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
}
|
}
|
||||||
@@ -781,9 +780,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
'scanned_quantity'=> $scannedQuantity,
|
'scanned_quantity'=> $scannedQuantity,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
return;
|
return;
|
||||||
@@ -866,7 +865,7 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
$filePath = $directory . '/' . $filename;
|
$filePath = $directory . '/' . $filename;
|
||||||
$fullPath = $disk->path($filePath);
|
$fullPath = $disk->path($filePath);
|
||||||
|
|
||||||
// Check if file exists //$disk->exists($filePath)
|
// Check if file exists //if ($disk->exists($filePath))
|
||||||
if ($fullPath && file_exists($fullPath))
|
if ($fullPath && file_exists($fullPath))
|
||||||
{
|
{
|
||||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||||
@@ -948,21 +947,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<br>contains no valid data.')
|
|
||||||
->seconds(3)
|
|
||||||
->send();
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
|
||||||
$disk->delete($filePath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||||
|
|
||||||
if (!empty($uniqueInvalidCodes)) {
|
if (!empty($uniqueInvalidCodes)) {
|
||||||
@@ -974,10 +958,75 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
// if ($disk->exists($filePath)) {
|
||||||
if ($disk->exists($filePath)) {
|
// $disk->delete($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:<br>" . 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:<br>' . 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:<br>' . 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<br>contains no valid data.')
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
|
// if ($disk->exists($filePath)) {
|
||||||
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,9 +1058,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,9 +1089,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1065,9 +1114,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,62 +1139,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($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:<br>" . 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:<br>' . 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:<br>' . implode(', ', $uniqueDupSerCodes))
|
|
||||||
->danger()
|
|
||||||
->seconds(3)
|
|
||||||
->send();
|
|
||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
|
||||||
$disk->delete($filePath);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1245,9 +1241,10 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
// $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( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
@@ -1273,9 +1270,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
'scanned_quantity'=> $scannedQuantity,
|
'scanned_quantity'=> $scannedQuantity,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
return;
|
return;
|
||||||
@@ -1493,20 +1490,6 @@ 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<br>contains no valid data.')
|
|
||||||
->seconds(2)
|
|
||||||
->send();
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
if ($disk->exists($filePath)) {
|
|
||||||
$disk->delete($filePath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||||
|
|
||||||
if (!empty($uniqueInvalidCodes)) {
|
if (!empty($uniqueInvalidCodes)) {
|
||||||
@@ -1516,11 +1499,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1533,11 +1516,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1552,7 +1535,21 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->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<br>contains no valid data.')
|
||||||
|
->seconds(2)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
if ($disk->exists($filePath)) {
|
if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
$disk->delete($filePath);
|
||||||
}
|
}
|
||||||
@@ -1586,9 +1583,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1616,9 +1613,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1641,9 +1638,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1708,9 +1705,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
|
|
||||||
|
|
||||||
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1855,9 +1852,10 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
// $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( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||||
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
@@ -1882,9 +1880,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
'scanned_quantity'=> $scannedQuantity,
|
'scanned_quantity'=> $scannedQuantity,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
return;
|
return;
|
||||||
@@ -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<br>contains no valid data.')
|
|
||||||
->seconds(3)
|
|
||||||
->send();
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
|
||||||
$disk->delete($filePath);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||||
|
|
||||||
if (!empty($uniqueInvalidCodes)) {
|
if (!empty($uniqueInvalidCodes)) {
|
||||||
@@ -1971,6 +1954,72 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$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:<br>" . 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:<br>' . 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:<br>' . 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<br>contains no valid data.')
|
||||||
|
->seconds(3)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('playWarnSound');
|
||||||
if ($disk->exists($filePath)) {
|
if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
$disk->delete($filePath);
|
||||||
}
|
}
|
||||||
@@ -2014,9 +2063,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2043,11 +2092,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(3)
|
->seconds(3)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2068,11 +2117,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(3)
|
->seconds(3)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2093,62 +2142,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(3)
|
->seconds(3)
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
// if ($disk->exists($filePath)) {
|
||||||
if ($disk->exists($filePath)) {
|
// $disk->delete($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:<br>" . 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:<br>' . 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:<br>' . implode(', ', $uniqueDupSerCodes))
|
|
||||||
->danger()
|
|
||||||
->seconds(3)
|
|
||||||
->send();
|
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
|
||||||
$disk->delete($filePath);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2162,11 +2160,11 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->danger()
|
->danger()
|
||||||
->seconds(3)
|
->seconds(3)
|
||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
$this->dispatch('playWarnSound');
|
||||||
$disk->delete($filePath);
|
// if ($disk->exists($filePath)) {
|
||||||
}
|
// $disk->delete($filePath);
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2230,9 +2228,10 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
|
// $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( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); //$this->invoiceNumber
|
||||||
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
@@ -2258,9 +2257,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
'scanned_quantity'=> $scannedQuantity,
|
'scanned_quantity'=> $scannedQuantity,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
|
||||||
return;
|
return;
|
||||||
@@ -2276,9 +2275,9 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
$this->dispatch('playWarnSound');
|
$this->dispatch('playWarnSound');
|
||||||
|
|
||||||
if ($disk->exists($filePath)) {
|
// if ($disk->exists($filePath)) {
|
||||||
$disk->delete($filePath);
|
// $disk->delete($filePath);
|
||||||
}
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3626,7 +3625,6 @@ class CreateInvoiceValidation extends CreateRecord
|
|||||||
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$filename = $invoiceNumber . '.xlsx';
|
$filename = $invoiceNumber . '.xlsx';
|
||||||
$directory = 'uploads/temp';
|
$directory = 'uploads/temp';
|
||||||
$disk = Storage::disk('local');
|
$disk = Storage::disk('local');
|
||||||
|
|||||||
Reference in New Issue
Block a user