From c7391b113f69f8580b4001128802996cd57bb057 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 20 Nov 2025 18:08:52 +0530 Subject: [PATCH] Refactor invoice processing to reset form fields after completion --- .../Pages/CreateInvoiceValidation.php | 109 +++++++++++++----- 1 file changed, 81 insertions(+), 28 deletions(-) diff --git a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php index 15e9ff4..312ae30 100644 --- a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php +++ b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php @@ -171,6 +171,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false); } else @@ -829,7 +839,7 @@ class CreateInvoiceValidation extends CreateRecord { Notification::make() ->title("Completed: Serial Invoice") - ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed.!") + ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed..!") ->warning() ->seconds(3) ->send(); @@ -845,6 +855,16 @@ class CreateInvoiceValidation extends CreateRecord $disk->delete($filePath); } $this->dispatch('playNotificationSound'); + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true); } else @@ -2388,15 +2408,6 @@ class CreateInvoiceValidation extends CreateRecord ->send(); $this->dispatch('playNotificationSound'); - $this->form->fill([ - 'plant_id' => $plantId, - 'invoice_number' => $invoiceNumber, - 'serial_number' => null, - 'total_quantity' => $totQuan, - 'update_invoice' => false, - 'scanned_quantity'=> $scanMQuan, - ]); - $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; $disk = Storage::disk('local'); @@ -2406,6 +2417,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false); return; } @@ -3139,15 +3160,6 @@ class CreateInvoiceValidation extends CreateRecord $this->dispatch('playNotificationSound'); - $this->form->fill([ - 'plant_id' => $plantId, - 'invoice_number' => $invoiceNumber, - 'serial_number' => null, - 'total_quantity' => $totQuan, - 'update_invoice' => false, - 'scanned_quantity'=> $scannedMQuantity, - ]); - $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; $disk = Storage::disk('local'); @@ -3157,6 +3169,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false); } else @@ -3186,15 +3208,6 @@ class CreateInvoiceValidation extends CreateRecord $this->dispatch('playNotificationSound'); - $this->form->fill([ - 'plant_id' => $plantId, - 'invoice_number' => $invoiceNumber, - 'serial_number' => null, - 'total_quantity' => $totQuan, - 'update_invoice' => false, - 'scanned_quantity'=> $scanSQuan, - ]); - $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; $disk = Storage::disk('local'); @@ -3204,6 +3217,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true); return; } @@ -3640,6 +3663,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true); } else @@ -3806,6 +3839,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true); } else @@ -4074,6 +4117,16 @@ class CreateInvoiceValidation extends CreateRecord //$fullPath = $disk->path($filePath); $disk->delete($filePath); } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => null, + 'serial_number' => null, + 'total_quantity' => 0, + 'update_invoice' => false, + 'scanned_quantity'=> 0 + ]); + $this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true); } else