From 8356fc858d2c96ca5699346d93e44c684f4cec32 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sun, 2 Nov 2025 15:37:57 +0530 Subject: [PATCH] Clear invoice number and refresh invoice data on serial number processing! --- .../Pages/CreateSerialValidation.php | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php b/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php index 80197d4..4aa6994 100644 --- a/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php +++ b/app/Filament/Resources/SerialValidationResource/Pages/CreateSerialValidation.php @@ -2322,6 +2322,10 @@ class CreateSerialValidation extends CreateRecord $this->dispatch('playWarnSound'); + $this->invoiceNumber = ''; + + $this->dispatch('refreshEmptyInvoice', invoiceNumber: $this->invoiceNumber, plantId: $plantId); + $this->form->fill([ 'plant_id' => $plantId, 'invoice_number' => null, @@ -2360,8 +2364,12 @@ class CreateSerialValidation extends CreateRecord ->seconds(2) ->send(); + $this->invoiceNumber = ''; + $this->dispatch('play-warn-sound'); + $this->dispatch('refreshEmptyInvoice', invoiceNumber: $this->invoiceNumber, plantId: $plantId); + $this->form->fill([ 'plant_id' => $plantId, 'invoice_number' => null, @@ -2398,9 +2406,11 @@ class CreateSerialValidation extends CreateRecord $this->dispatch('playWarnSound'); + // $this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId); + $this->form->fill([ 'plant_id' => $plantId, - 'invoice_number' => null, + 'invoice_number' => $invoiceNumber, 'serial_number' => null, 'total_quantity' => $totQuan, 'update_invoice' => false, @@ -2413,12 +2423,6 @@ class CreateSerialValidation extends CreateRecord // $hasPumpQr = $record->stickerMasterRelation->tube_sticker_pump ?? null; // $hasPumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null; - - // if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr) - // { - - // } - $hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null; $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null; $hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null; @@ -2550,14 +2554,6 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); - // $invoiceNumber = $this->form->getState()['invoice_number']; - // $this->invoiceNumber = $invoiceNumber; - - - - // $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') - // $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - if($totQuan == $scannedQuantity) { Notification::make() @@ -2568,7 +2564,6 @@ class CreateSerialValidation extends CreateRecord ->send(); $this->dispatch('playNotificationSound'); - $filename = $invoiceNumber . '.xlsx'; $directory = 'uploads/temp'; $disk = Storage::disk('local'); @@ -2608,6 +2603,8 @@ class CreateSerialValidation extends CreateRecord $this->dispatch('playWarnSound'); + $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); + $this->form->fill([ 'plant_id' => $plantId, 'invoice_number' => $invoiceNumber, @@ -2628,6 +2625,8 @@ class CreateSerialValidation extends CreateRecord ->send(); $this->dispatch('playWarnSound'); + $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); + $this->form->fill([ 'plant_id' => $plantId, 'invoice_number' => $invoiceNumber, @@ -2642,7 +2641,6 @@ class CreateSerialValidation extends CreateRecord $packCnt = 1; $scanCnt = 1; $record->pump_scanned_status = 1; - // if($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr)) if($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) { $packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt; @@ -2707,7 +2705,6 @@ class CreateSerialValidation extends CreateRecord else { $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - // $this->refreshInvoiceTable(); } return; } @@ -2723,9 +2720,7 @@ class CreateSerialValidation extends CreateRecord if (!$hasCapacitorQr) { Notification::make() - // ->title('Unknown: Capacitor QR') ->title('Missing: Panel Box Code') - // ->body("Panel Box Code is not available for Item Code : '$itemCode'.") ->body("Scanned 'Item Code' doesn't have 'Panel Box Code' to proceed!") ->danger() ->seconds(2) @@ -2768,15 +2763,10 @@ class CreateSerialValidation extends CreateRecord return; } - //hereToUpdate - //$this->dispatch('openCapacitorModal'); $this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId); $scannedQuantity = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); - // $invoiceNumber = $this->form->getState()['invoice_number']; - // $this->invoiceNumber = $invoiceNumber; - $totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); $scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') @@ -2791,7 +2781,6 @@ class CreateSerialValidation extends CreateRecord 'scanned_quantity'=> $scannedQuantity, ]); $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - // $this->refreshInvoiceTable(); return; } elseif ($isMarkPs) @@ -2931,23 +2920,10 @@ class CreateSerialValidation extends CreateRecord else { $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); - // $this->refreshInvoiceTable(); } return; } } - - // $invoiceNumber = $this->form->getState()['invoice_number']; - // $this->invoiceNumber = $invoiceNumber; - - // $totQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count(); - // $scanSQuan = SerialValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count(); - // $totMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '') - // $scanMQuan = SerialValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); - - //.. - - } public function getHeading(): string