Refactor code structure for improved readability and maintainability and Commented imported invoice logic on warning

This commit is contained in:
dhanabalan
2025-11-15 20:04:30 +05:30
parent 43ee1a3502
commit 3e41bad7f1
2 changed files with 445 additions and 436 deletions

View File

@@ -269,8 +269,7 @@ class SerialValidationResource extends Resource
->alignCenter() ->alignCenter()
->sortable(), ->sortable(),
]) ])
->headerActions([ ->headerActions([
// Action::make('plant_id') // Action::make('plant_id')
// ->label('Select Plant') // ->label('Select Plant')
// ->form([ // ->form([
@@ -470,10 +469,10 @@ class SerialValidationResource extends Resource
if (!empty($uniqueInvalidCodes)) { if (!empty($uniqueInvalidCodes)) {
Notification::make() Notification::make()
->title('Invalid Item Codes') ->title('Invalid Item Codes')
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes)) ->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) { if ($disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
} }
@@ -492,10 +491,10 @@ class SerialValidationResource extends Resource
} }
else if (!empty($uniqueSerialCodes)) { else if (!empty($uniqueSerialCodes)) {
Notification::make() Notification::make()
->title('Invalid Serial Number') ->title('Invalid Serial Number')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes)) ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueSerialCodes))
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) { if ($disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
} }
@@ -503,10 +502,10 @@ class SerialValidationResource extends Resource
} }
else if (!empty($duplicateSerialCodes)) { else if (!empty($duplicateSerialCodes)) {
Notification::make() Notification::make()
->title('Duplicate Serial Numbers') ->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes)) ->body('The following serial numbers are already exist in imported excel:<br>' . implode(', ', $duplicateSerialCodes))
->danger() ->danger()
->send(); ->send();
if ($disk->exists($path)) { if ($disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
} }
@@ -519,9 +518,9 @@ class SerialValidationResource 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);
} }
return; return;
} }
@@ -589,7 +588,7 @@ class SerialValidationResource extends Resource
} }
else else
{ {
// Save full file path to session // Save full file path to session
session(['uploaded_invoice_path' => $fullPath]); session(['uploaded_invoice_path' => $fullPath]);
Notification::make() Notification::make()
->title('Serial invoice imported successfully.') ->title('Serial invoice imported successfully.')