diff --git a/app/Filament/Resources/InvoiceValidationResource.php b/app/Filament/Resources/InvoiceValidationResource.php index eab23e1..4da5c3b 100644 --- a/app/Filament/Resources/InvoiceValidationResource.php +++ b/app/Filament/Resources/InvoiceValidationResource.php @@ -61,6 +61,7 @@ class InvoiceValidationResource extends Resource Section::make('') ->schema([ Forms\Components\Select::make('plant_id') + ->label('Plant Name') ->relationship('plant', 'name') ->required() // ->preload() @@ -323,7 +324,7 @@ class InvoiceValidationResource extends Resource ->alignCenter() ->numeric(), Tables\Columns\TextColumn::make('plant.name') - ->label('Plant') + ->label('Plant Name') ->alignCenter() ->sortable(), Tables\Columns\TextColumn::make('created_by') @@ -381,7 +382,7 @@ class InvoiceValidationResource extends Resource return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) ->searchable() - ->label('Select Plant') + ->label('Search by Plant Name') ->required() ->default(function () { return optional(InvoiceValidation::latest()->first())->plant_id; @@ -404,7 +405,7 @@ class InvoiceValidationResource extends Resource ->reactive(), FileUpload::make('invoice_serial_number') - ->label('Invoice Serial Number') + ->label('Choose Serial Invoice') ->required() ->acceptedFileTypes([ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', @@ -732,7 +733,7 @@ class InvoiceValidationResource extends Resource return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) ->searchable() - ->label('Select Plant') + ->label('Search by Plant Name') ->required() ->default(function () { return optional(InvoiceValidation::latest()->first())->plant_id; @@ -755,7 +756,7 @@ class InvoiceValidationResource extends Resource ->reactive(), FileUpload::make('invoice_material') - ->label('Invoice Material') + ->label('Choose Material Invoice') ->required() ->acceptedFileTypes([ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', diff --git a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php index 61fe91d..cfc84e3 100644 --- a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php +++ b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php @@ -10,6 +10,8 @@ use App\Models\InvoiceValidation; use App\Models\Item; use App\Models\Plant; use App\Models\StickerMaster; +use App\Models\WireMasterPacking; +use DB; use Filament\Facades\Filament; use Filament\Notifications\Notification; use Filament\Pages\Concerns\ExposesTableToWidgets; @@ -174,17 +176,15 @@ class CreateInvoiceValidation extends CreateRecord } if (isset($matches[1])) { - $invoiceNumber = $matches[1]; + $invoiceNumber = strtoupper($matches[1]); } + } else { + $invoiceNumber = strtoupper($invoiceNumber); } - // dd($invoiceNumber); - - // .. - $updateStatus = $this->form->getState()['update_invoice'] ?? null; - $this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber; + $this->invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])) ?? $invoiceNumber; $invoiceType = null; // $this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber; @@ -2317,7 +2317,7 @@ class CreateInvoiceValidation extends CreateRecord protected function refreshInvoiceTable() { $this->plantId = $this->form->getState()['plant_id'] ?? ''; - $this->invoiceNumber = $this->form->getState()['invoice_number'] ?? ''; + $this->invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])) ?? ''; if (! empty($this->invoiceNumber)) { $hasInvoice = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->first(); @@ -2378,7 +2378,7 @@ class CreateInvoiceValidation extends CreateRecord $serialNumber = null; $plantId = $this->form->getState()['plant_id']; $this->plantId = $plantId; - $invoiceNumber = $this->form->getState()['invoice_number']; + $invoiceNumber = strtoupper(trim($this->form->getState()['invoice_number'])); $this->invoiceNumber = $invoiceNumber; $plant = Plant::find($plantId); @@ -2455,14 +2455,65 @@ class CreateInvoiceValidation extends CreateRecord $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); } + $pattern0 = '/^(?[^|]+)\|(?[^|]+)\|(?[^|]+)\|(?[0-9]+(?:\.[0-9]+)?)kg$/i'; $pattern1 = '/^(?[^|]+)\|(?[^|]+)\|(?[^|]+)\|(?[^|]+)\/(?.+)$/i'; $pattern2 = '/^(?[^|]+)\|(?[^|]+)\|(?[^|]+)\|(?.+)$/i'; $pattern3 = '/^(?[^|]+)\|(?[^|]+)-(?.+)$/i'; + $pattern4 = '/^MP-(?.+)$/i'; $itemCode = ''; $batchNumber = ''; $curScanQty = ''; + $wirePallet = ''; + $curMaterialQty = ''; + $curMaterialSer = ''; - if (preg_match($pattern1, $serNo, $matches)) { + if (preg_match($pattern0, $serNo, $matches)) { + $itemCode = $matches['item_code']; + $this->currentItemCode = $itemCode; + $curScanQty = $matches['batch_quantity']; + $serialNumber = $matches['batch_id'].'-'.$matches['batch_count']; + $serNo = null; + + if (empty($matches['batch_id']) || ! $matches['batch_id']) { + Notification::make() + ->danger() + ->title('Invalid Material QR Format') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->seconds(2) + ->send(); + $this->dispatch('playWarnSound'); + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => $invoiceNumber, + 'serial_number' => null, + 'total_quantity' => $totQuan, + 'update_invoice' => false, + 'scanned_quantity' => $scanMQuan, + ]); + + return; + } elseif (empty($matches['batch_count']) || ! $matches['batch_count']) { + Notification::make() + ->danger() + ->title('Invalid Material QR Format') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->seconds(2) + ->send(); + $this->dispatch('playWarnSound'); + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => $invoiceNumber, + 'serial_number' => null, + 'total_quantity' => $totQuan, + 'update_invoice' => false, + 'scanned_quantity' => $scanMQuan, + ]); + + return; + } + } elseif (preg_match($pattern1, $serNo, $matches)) { $itemCode = $matches['item_code']; $this->currentItemCode = $itemCode; $batchNumber = $matches['batch_number']; @@ -2470,11 +2521,45 @@ class CreateInvoiceValidation extends CreateRecord $curScanQty = $matches['batch_quantity']; $serNo = null; - if (empty($matches['batch_id']) || ! $matches['batch_id']) { + if (empty($matches['batch_number']) || ! $matches['batch_number']) { Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->seconds(2) + ->send(); + $this->dispatch('playWarnSound'); + + // .Mail + + // $mailData = $this->getMail(); + // $mPlantName = $mailData['plant_name']; + // $emails = $mailData['emails']; + // $mInvoiceType = 'Material'; + + // if (! empty($emails)) { + // Mail::to($emails)->send( + // new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') + // ); + // } else { + // \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); + // } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => $invoiceNumber, + 'serial_number' => null, + 'total_quantity' => $totQuan, + 'update_invoice' => false, + 'scanned_quantity' => $scanMQuan, + ]); + + return; + } elseif (empty($matches['batch_id']) || ! $matches['batch_id']) { + Notification::make() + ->danger() + ->title('Invalid Material QR Format') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2508,42 +2593,7 @@ class CreateInvoiceValidation extends CreateRecord Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') - ->seconds(2) - ->send(); - $this->dispatch('playWarnSound'); - - // .Mail - - // $mailData = $this->getMail(); - // $mPlantName = $mailData['plant_name']; - // $emails = $mailData['emails']; - // $mInvoiceType = 'Material'; - - // if (! empty($emails)) { - // // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); - // Mail::to($emails)->send( - // new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') - // ); - // } else { - // \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); - // } - - $this->form->fill([ - 'plant_id' => $plantId, - 'invoice_number' => $invoiceNumber, - 'serial_number' => null, - 'total_quantity' => $totQuan, - 'update_invoice' => false, - 'scanned_quantity' => $scanMQuan, - ]); - - return; - } elseif (! is_numeric($curScanQty)) { - Notification::make() - ->danger() - ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2580,13 +2630,48 @@ class CreateInvoiceValidation extends CreateRecord $this->currentItemCode = $itemCode; $batchNumber = $matches['batch_number']; $serialNumber = $matches['batch_id'].'-'.$matches['batch_count']; + $curMaterialSer = $matches['batch_number'].'-'.$matches['batch_id']; + $curMaterialQty = $matches['batch_count']; $serNo = null; - if (empty($matches['batch_id']) || ! $matches['batch_id']) { + if (empty($matches['batch_number']) || ! $matches['batch_number']) { Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->seconds(2) + ->send(); + $this->dispatch('playWarnSound'); + // .Mail + + // $mailData = $this->getMail(); + // $mPlantName = $mailData['plant_name']; + // $emails = $mailData['emails']; + // $mInvoiceType = 'Material'; + + // if (! empty($emails)) { + // Mail::to($emails)->send( + // new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat') + // ); + // } else { + // \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); + // } + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => $invoiceNumber, + 'serial_number' => null, + 'total_quantity' => $totQuan, + 'update_invoice' => false, + 'scanned_quantity' => $scanMQuan, + ]); + + return; + } elseif (empty($matches['batch_id']) || ! $matches['batch_id']) { + Notification::make() + ->danger() + ->title('Invalid Material QR Format') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2619,7 +2704,7 @@ class CreateInvoiceValidation extends CreateRecord Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2659,7 +2744,7 @@ class CreateInvoiceValidation extends CreateRecord Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2693,7 +2778,7 @@ class CreateInvoiceValidation extends CreateRecord Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2723,6 +2808,294 @@ class CreateInvoiceValidation extends CreateRecord return; } + } elseif (preg_match($pattern4, $serNo, $matches)) { + $wirePallet = 'MP-'.$matches['code']; + $wirePattern = '/^MP-(?\d+)$/i'; + + if (! preg_match($wirePattern, $serNo, $matches)) { + Notification::make() + ->title('Invalid Master Packing QR Format') + ->body("Scan valid Master Packing QR code proceed!
Sample format : 'MP-2601001'") + ->danger() + ->seconds(1) + ->send(); + + return; + } + + $wireMaster = WireMasterPacking::where('plant_id', $plantId)->where('wire_packing_number', $wirePallet)->first(); + + if (! $wireMaster) { + Notification::make() + ->title('Master Pallet Not Found') + ->body("No record found for this Master Packing QR $wirePallet") + ->danger() + ->seconds(2) + ->send(); + + return; + } + + $wireItemCodes = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id') + ->where('wire_master_packings.plant_id', $plantId) + ->where('wire_master_packings.wire_packing_number', $wirePallet) + ->pluck('items.code') + ->unique() + ->toArray(); + + $invoiceItemCodes = InvoiceValidation::join( + 'sticker_masters', + 'sticker_masters.id', + '=', + 'invoice_validations.sticker_master_id' + ) + ->join( + 'items', + 'items.id', + '=', + 'sticker_masters.item_id' + ) + ->where('invoice_validations.plant_id', $plantId) + ->where('invoice_validations.invoice_number', $this->invoiceNumber) + ->pluck('items.code') + ->unique() + ->toArray(); + + $missedCodes = array_diff($wireItemCodes, $invoiceItemCodes); + + if (! empty($missedCodes)) { + + Notification::make() + ->title('Items Missing in Invoice') + ->body('Item codes are missing in invoice: '.implode(', ', $missedCodes)) + ->danger() + ->seconds(3) + ->send(); + + return; + } + + $duplicateSerial = []; + $weightExceeded = []; + $processedItems = []; + $invalidMaterialItems = []; + + $wireItems1 = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id') + ->where('wire_master_packings.plant_id', $plantId) + ->where('wire_master_packings.wire_packing_number', $wirePallet) + ->select( + 'items.code as item_code', + 'wire_master_packings.process_order', + DB::raw('SUM(wire_master_packings.weight::numeric) as pallet_weight') + ) + ->groupBy('items.code', 'wire_master_packings.process_order') + ->get(); + + foreach ($wireItems1 as $wireItem) { + $processOrder = $wireItem->process_order; + $palletWeight = $wireItem->pallet_weight; + $itemCode = $wireItem->item_code; + + $processedItems[] = $itemCode; + + $duplicate = InvoiceValidation::where('plant_id', $this->plantId) + ->where('invoice_number', $this->invoiceNumber) + ->where('serial_number', $processOrder) + ->exists(); + + if ($duplicate) { + $duplicateSerial[] = $processOrder; + + continue; + } + + $materialType = StickerMaster::where('item_id', function ($q) use ($itemCode) { + $q->select('id')->from('items')->where('code', $itemCode); + })->value('material_type'); + + if ($materialType != 3) { + if (! in_array($itemCode, $invalidMaterialItems)) { + $invalidMaterialItems[] = $itemCode; + } + } + + $scannedQty = InvoiceValidation::join('sticker_masters', 'sticker_masters.id', '=', 'invoice_validations.sticker_master_id') + ->join('items', 'items.id', '=', 'sticker_masters.item_id') + ->where('invoice_validations.plant_id', $plantId) + ->where('invoice_validations.invoice_number', $this->invoiceNumber) + ->where('items.code', $itemCode) + ->sum(DB::raw('invoice_validations.quantity::numeric')); + + if ($palletWeight > $scannedQty) { + $weightExceeded[] = $itemCode; + } + } + + if (! empty($invalidMaterialItems)) { + $uniqueInvalidItems = array_unique($invalidMaterialItems); + Notification::make() + ->title('Invalid Material Type') + ->body(implode(', ', $uniqueInvalidItems)."
Invalid material type found for the invoice '$invoiceNumber'.") + ->danger() + ->seconds(4) + ->send(); + + return; + } elseif (! empty($weightExceeded)) { + Notification::make() + ->title('Item Code Limit') + ->body(implode(', ', $weightExceeded)."
Master pallet weight exceeds the remaining quantity in invoice '$invoiceNumber'.") + ->danger() + ->seconds(4) + ->send(); + + return; + } elseif (! empty($duplicateSerial)) { + Notification::make() + ->title('Duplicate Serial Number') + ->body(implode(', ', $duplicateSerial)."
Duplicate Serial numbers found for the invoice '$invoiceNumber'.") + ->danger() + ->seconds(4) + ->send(); + + return; + } + + $itemExceeded = []; + + $invoiceRows = InvoiceValidation::where('plant_id', $plantId) + ->where('invoice_number', $invoiceNumber) + ->whereNull('serial_number') + ->get(); + + $palletItems = WireMasterPacking::where('wire_master_packings.plant_id', $plantId) + ->where('wire_master_packings.wire_packing_number', $wirePallet) + ->join('items', 'items.id', '=', 'wire_master_packings.item_id') + ->select( + 'items.code as item_code', + DB::raw('SUM(wire_master_packings.weight::numeric) as pallet_weight') + ) + ->groupBy('items.code') + ->get(); + + foreach ($invoiceRows as $row) { + $itemCode = $row->stickerMaster->item->code ?? null; + + if (! $itemCode) { + continue; + } + + $pallet = $palletItems->firstWhere('item_code', $itemCode); + $palletWeight = $pallet->pallet_weight ?? 0; + + $remainingQty = $row->quantity; + + if ($palletWeight > $remainingQty) { + $itemExceeded[] = $itemCode; + } + } + + $items = implode(', ', $itemExceeded); + + if (! empty($itemExceeded)) { + Notification::make() + ->title('Item Code Limit') + ->body("Pallet weight exceeds remaining quantity for invoice number '$invoiceNumber'for below item codes
$items") + ->danger() + ->seconds(5) + ->send(); + + return; + } + + $wireItems = WireMasterPacking::join('items', 'items.id', '=', 'wire_master_packings.item_id') + ->where('wire_master_packings.wire_packing_number', $wirePallet) + ->select( + 'items.code as item_code', + 'wire_master_packings.process_order', + 'wire_master_packings.weight as pallet_weight' + // DB::raw('(wire_master_packings.weight::numeric) as pallet_weight') + ) + ->get(); + + foreach ($wireItems as $wireItem) { + + $itemCode = $wireItem->item_code; + $palletWeight = $wireItem->pallet_weight; + $processOrder = $wireItem->process_order; + + if (! $processOrder || $palletWeight <= 0) { + continue; + } + + $records = InvoiceValidation::join('sticker_masters', 'sticker_masters.id', '=', 'invoice_validations.sticker_master_id') + ->join('items', 'items.id', '=', 'sticker_masters.item_id') + ->where('invoice_validations.invoice_number', $invoiceNumber) + ->where('invoice_validations.plant_id', $plantId) + ->where('items.code', $itemCode) + ->whereNull('invoice_validations.serial_number') + ->where('invoice_validations.quantity', '>', 0) + ->orderBy('invoice_validations.created_at') + ->select('invoice_validations.*') + ->get(); + + if ($records->isEmpty()) { + continue; + } + + foreach ($records as $record) { + + if ($palletWeight <= 0) { + break; + } + + $usedQty = min($record->quantity, $palletWeight); + + $record->quantity -= $usedQty; + + if ($usedQty == $record->quantity + $usedQty) { + $record->serial_number = $processOrder; + $record->quantity = $palletWeight; + $record->save(); + } else { + $record->save(); + + InvoiceValidation::create([ + 'sticker_master_id' => $record->sticker_master_id, + 'plant_id' => $plantId, + 'invoice_number' => $invoiceNumber, + 'serial_number' => $processOrder, + 'quantity' => $usedQty, + 'operator_id' => $operatorName, + 'created_by' => $operatorName, + 'updated_by' => $operatorName, + ]); + } + + $palletWeight -= $usedQty; + + // if ($record->quantity <= 0) { + // $records->forget($key); + // } + } + } + + $this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId); + + $totQuan = InvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count(); + + $scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count(); + + $this->form->fill([ + 'plant_id' => $plantId, + 'invoice_number' => $invoiceNumber, + 'serial_number' => null, + 'total_quantity' => $totQuan, + 'update_invoice' => false, + 'scanned_quantity' => $scanMQuan, + ]); + + return; } else { $itemCode = null; $this->currentItemCode = ''; @@ -2733,7 +3106,7 @@ class CreateInvoiceValidation extends CreateRecord Notification::make() ->danger() ->title('Invalid Material QR Format') - ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') + ->body('Scan valid Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1') ->seconds(1) ->send(); @@ -2866,6 +3239,12 @@ class CreateInvoiceValidation extends CreateRecord $hasQuanTyp = ($record->material_type == 3) ? true : false; + if ($hasQuanTyp && $curMaterialSer && $curMaterialQty) { + $batchNumber = null; + $serialNumber = $curMaterialSer; + $curScanQty = $curMaterialQty; + } + $record = InvoiceValidation::where('invoice_number', $invoiceNumber) ->where('plant_id', $plantId) ->whereHas('stickerMasterRelation.item', function ($query) use ($itemCode) { @@ -2948,7 +3327,7 @@ class CreateInvoiceValidation extends CreateRecord Notification::make() ->danger() ->title('Invalid Quantity Material QR Format') - ->body('Scan valid Quantity Material QR code proceed!
Ex:123456|12345|12345678|1/1') + ->body('Scan valid Quantity Material QR code to proceed!
Sample formats are:
123456|123456789|001|5kg (or)
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1') ->seconds(2) ->send(); $this->dispatch('playWarnSound'); @@ -2994,8 +3373,8 @@ class CreateInvoiceValidation extends CreateRecord $record->serial_number = $serialNumber; $record->batch_number = $batchNumber; $record->operator_id = $operatorName; - // $record->updated_by = $operatorName; - // $record->updated_at = now(); + $record->updated_by = $operatorName; + $record->updated_at = now(); $record->save(); // InvoiceValidation::create([ @@ -3231,7 +3610,6 @@ class CreateInvoiceValidation extends CreateRecord } $record = InvoiceValidation::where('serial_number', $serialNumber)->where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first(); - // $invoiceNumber = $this->form->getState()['invoice_number']; if (! $record) { Notification::make()