3 Commits

Author SHA1 Message Date
dhanabalan
1073a7cb0b Clear invoice, serial, quantities on change plant 2025-04-19 19:25:19 +05:30
dhanabalan
700f4715f7 Rule 'datetime' removed 2025-04-19 19:24:43 +05:30
dhanabalan
2cec2cb822 Double scanning issue updation 2025-04-19 19:24:15 +05:30
3 changed files with 13 additions and 12 deletions

View File

@@ -18,12 +18,12 @@ class ProductionLineStopImporter extends Importer
->requiredMapping() ->requiredMapping()
->exampleHeader('From DateTime') ->exampleHeader('From DateTime')
->label('From DateTime') ->label('From DateTime')
->rules(['required', 'datetime']), ->rules(['required']),
ImportColumn::make('to_datetime') ImportColumn::make('to_datetime')
->requiredMapping() ->requiredMapping()
->exampleHeader('To DateTime') ->exampleHeader('To DateTime')
->label('To DateTime') ->label('To DateTime')
->rules(['required', 'datetime']), ->rules(['required']),
ImportColumn::make('stop_hour') ImportColumn::make('stop_hour')
->requiredMapping() ->requiredMapping()
->exampleHeader('Stop Hour') ->exampleHeader('Stop Hour')

View File

@@ -31,9 +31,6 @@ use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire; use Livewire\Livewire;
use Str; use Str;
class InvoiceValidationResource extends Resource class InvoiceValidationResource extends Resource
{ {
protected static ?string $model = InvoiceValidation::class; protected static ?string $model = InvoiceValidation::class;
@@ -44,8 +41,6 @@ class InvoiceValidationResource extends Resource
public $invoiceNumber; public $invoiceNumber;
public static function form(Form $form): Form public static function form(Form $form): Form
{ {
return $form return $form
@@ -74,6 +69,10 @@ class InvoiceValidationResource extends Resource
$set('update_invoice', null); $set('update_invoice', null);
// Ensure `linestop_id` is not cleared // Ensure `linestop_id` is not cleared
if (!$plantId) { if (!$plantId) {
$set('invoice_number', null);
$set('serial_number', null);
$set('total_quantity', null);
$set('scanned_quantity', null);
$set('ivPlantError', 'Please select a plant first.'); $set('ivPlantError', 'Please select a plant first.');
return; return;
} }

View File

@@ -1024,8 +1024,9 @@ class CreateInvoiceValidation extends CreateRecord
} }
} }
public function processSerialNumber($serialNumber) public function processSerialNumber($serNo)
{ {
$serialNumber = null;
$plantId = $this->form->getState()['plant_id']; $plantId = $this->form->getState()['plant_id'];
$this->plantId = $plantId; $this->plantId = $plantId;
$invoiceNumber = $this->form->getState()['invoice_number']; $invoiceNumber = $this->form->getState()['invoice_number'];
@@ -1104,7 +1105,7 @@ class CreateInvoiceValidation extends CreateRecord
$itemCode = ''; $itemCode = '';
$batchNumber = ''; $batchNumber = '';
if (preg_match($pattern1, $serialNumber, $matches)) { if (preg_match($pattern1, $serNo, $matches)) {
$itemCode = $matches['item_code']; $itemCode = $matches['item_code'];
$this->currentItemCode = $itemCode; $this->currentItemCode = $itemCode;
$batchNumber = $matches['batch_number']; $batchNumber = $matches['batch_number'];
@@ -1144,7 +1145,7 @@ class CreateInvoiceValidation extends CreateRecord
]); ]);
return; return;
} }
} elseif (preg_match($pattern2, $serialNumber, $matches)) { } elseif (preg_match($pattern2, $serNo, $matches)) {
$itemCode = $matches['item_code']; $itemCode = $matches['item_code'];
$this->currentItemCode = $itemCode; $this->currentItemCode = $itemCode;
$batchNumber = null; // batch_number not present in this pattern $batchNumber = null; // batch_number not present in this pattern
@@ -1187,6 +1188,7 @@ class CreateInvoiceValidation extends CreateRecord
} else { } else {
$itemCode = null; $itemCode = null;
$batchNumber = null; $batchNumber = null;
$serNo = null;
$serialNumber = null; $serialNumber = null;
Notification::make() Notification::make()
@@ -1412,7 +1414,7 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); $this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
} }
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serialNumber, $matches)) { if (!preg_match('/^([a-zA-Z0-9]{6,})\|([a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serNo, $matches)) {
Notification::make() Notification::make()
->danger() ->danger()
->title('Invalid Serial QR Format') ->title('Invalid Serial QR Format')
@@ -1429,7 +1431,7 @@ class CreateInvoiceValidation extends CreateRecord
return; return;
} }
if (preg_match('/^([a-zA-Z0-9]+)\|([a-zA-Z0-9]+(?:\/[MmPpCc]?)?)$/', $serialNumber, $matches)) if (preg_match('/^([a-zA-Z0-9]+)\|([a-zA-Z0-9]+(?:\/[MmPpCc]?)?)$/', $serNo, $matches))
{ {
$itemCode = $matches[1]; $itemCode = $matches[1];
$serialNumber = $matches[2]; $serialNumber = $matches[2];