Added serial_number minimum length should be 9 digit and notification display duration and updated validations

This commit is contained in:
dhanabalan
2025-07-09 19:35:39 +05:30
parent eb2b857aa7
commit 4ac1823e5b
2 changed files with 234 additions and 41 deletions

View File

@@ -86,6 +86,7 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->label('Scan Pallet No')
->required( fn ($get) => $get('rework_type') == 'pallet')
->readOnly(fn ($get) => $get('rework_type') == 'invoice')
->minLength(10)
->reactive()
->readOnly(fn (callable $get) => (!$get('plant') || !$get('rework_type') || ($get('rework_type') == 'invoice' && !$get('invoice_number')) || $get('scan_serial_no')))
->extraAttributes([
@@ -93,8 +94,9 @@ class ReworkLocatorInvoiceValidationResource extends Resource
]),
Forms\Components\TextInput::make('scan_serial_no')
->label('Scan Serial No')
->reactive()
->readOnly(fn (callable $get) => (!$get('plant') || !$get('rework_type') || ($get('rework_type') == 'invoice' && !$get('invoice_number')) || ($get('rework_type') == 'invoice' && $get('scan_pallet_no')) || ($get('rework_type') == 'pallet' && !$get('scan_pallet_no'))))
->minLength(9)
->reactive()
->extraAttributes([
'wire:keydown.enter' => 'processSno($event.target.value)',
]),
@@ -145,21 +147,21 @@ class ReworkLocatorInvoiceValidationResource extends Resource
$invoiceNumber = $get('invoice_number');
$rows = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
->where('plant_id', $plantId)
->get();
->where('plant_id', $plantId)
->get();
$notCompletedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
->where('plant_id', $plantId)
->where(function($query) {
$query->whereNull('scanned_status')
->orWhere('scanned_status', '');
})
->count();
->where('plant_id', $plantId)
->where(function($query) {
$query->whereNull('scanned_status')
->orWhere('scanned_status', '');
})
->count();
$isScanningComplete = true;
foreach ($rows as $row)
{
if ($row->scanned_status !== 'Scanned') {
if ($row->scanned_status != 'Scanned') {
$isScanningComplete = false;
break;
}
@@ -168,9 +170,12 @@ class ReworkLocatorInvoiceValidationResource extends Resource
if (!$isScanningComplete)
{
Notification::make()
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
->danger()
->send();
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
->danger()
->duration(1200)
->send();
$set('invoice_number', null);
$set('update_invoice', null);
return;
}
}),
@@ -184,24 +189,16 @@ class ReworkLocatorInvoiceValidationResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get, $livewire) {
$plantId = $get('plant');
$invoiceNumber = $get('invoice_number');
$palletNumber = $get('scan_pallet_no');
$rows = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
->where('plant_id', $plantId)
->get();
$notCompletedCount = LocatorInvoiceValidation::where('invoice_number', $invoiceNumber)
->where('plant_id', $plantId)
->where(function($query) {
$query->whereNull('scanned_status')
->orWhere('scanned_status', '');
})
->count();
$rows = PalletValidation::where('pallet_number', $palletNumber)
->where('plant_id', $plantId)
->get();
$isScanningComplete = true;
foreach ($rows as $row)
{
if ($row->scanned_status !== 'Scanned') {
if ($row->pallet_status != 'Completed') {
$isScanningComplete = false;
break;
}
@@ -210,9 +207,12 @@ class ReworkLocatorInvoiceValidationResource extends Resource
if (!$isScanningComplete)
{
Notification::make()
->title("Scanned invoice number: '$invoiceNumber' does not completed the scanning process!<br>Has '$notCompletedCount' pending serial number to scan!<br>Please, scan the valid completed invoice number to proceed...")
->danger()
->send();
->title("Scanned pallet number '$palletNumber' does not completed the master packing!<br>Please, scan the valid completed pallet number to proceed...")
->danger()
->duration(1200)
->send();
$set('scan_pallet_no', null);
$set('update_pallet', null);
return;
}
}),