Changed logic in cycle count page and added stock count in export page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled

This commit is contained in:
dhanabalan
2026-03-11 13:02:18 +05:30
parent 0b5b0b8dd4
commit 41d158877e
3 changed files with 341 additions and 59 deletions

View File

@@ -612,18 +612,34 @@ class CycleCount extends Page
// $remainingStock = $stock->quantity - $currentScanned;
if($stock->scanned_status == 'Scanned'){
Notification::make()
->title('Completed')
->body("Already Completed the scanning process for the location '$location', item code '$this->itemCode' and doc no '$this->docNo against plant code $plantCode.")
->warning()
->title('Duplicate Serial Number')
->body("Serial number '$this->sNo' has already been scanned in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update')
->button()
->dispatch('confirmDuplicateUpdate', [
'plantId' => $plantId,
'location' => $location,
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'docNo' => $this->docNo,
'quantity' => $this->quantity
]),
])
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
@@ -887,7 +903,7 @@ class CycleCount extends Page
Notification::make()
->title('Unknown Location')
->body("location '$location' not found in stock data master for the type SFG")
->body("location '$location' not found in stock data master for the type SFG.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
@@ -946,7 +962,7 @@ class CycleCount extends Page
Notification::make()
->title('Unknown Location')
->body("location '$location' not found in stock data master for the type SFG against plant code '$plantCode'.")
->body("location '$location' not found in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
@@ -1003,7 +1019,7 @@ class CycleCount extends Page
if ($existingInOtherLocation) {
Notification::make()
->title('Serial Number : Not In Stock')
->body("Serial number '{$this->sNo}' already exists against plant code '$plantCode' in not in stock table.")
->body("Serial number '{$this->sNo}' already exists against plant code '$plantCode' in not in stock table.")
->danger()
->send();
@@ -1019,7 +1035,7 @@ class CycleCount extends Page
Notification::make()
->title('Unknown Serial Number')
->body('Scanned serial number not found in stock data master for the type SFG')
->body('Scanned serial number not found in stock data master for the type SFG.<br>Do you want to update in not in stock table?')
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
@@ -1075,7 +1091,7 @@ class CycleCount extends Page
Notification::make()
->title('Unknown Serial Number')
->body("Scanned serial number not found in stock data master for the type SFG against plant code '$plantCode'")
->body("Scanned serial number not found in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1129,7 +1145,7 @@ class CycleCount extends Page
Notification::make()
->title('Invalid Location')
->body("Serial number '$this->sNo' does not belong to location '$location' for the type SFG against plant code '$plantCode'.")
->body("Serial number '$this->sNo' does not belong to location '$location' for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1183,7 +1199,7 @@ class CycleCount extends Page
Notification::make()
->title('Invalid Item Code')
->body("Serial number '$this->sNo' does not belong to item code '$this->itemCode' for the type SFG against plant code '$plantCode'.")
->body("Serial number '$this->sNo' does not belong to item code '$this->itemCode' for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1239,7 +1255,7 @@ class CycleCount extends Page
Notification::make()
->title('Invalid Batch')
->body("Serial number '$this->sNo' does not belong to batch '$this->batch' for the type SFG against plant code '$plantCode'.")
->body("Serial number '$this->sNo' does not belong to batch '$this->batch' for the type SFG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm_update')
@@ -1357,18 +1373,32 @@ class CycleCount extends Page
if($serial->scanned_status == 'Scanned'){
Notification::make()
->warning()
->title('Completed')
->body("Already completed the scanning process Serial number '$this->sNo' for the type SFG against plant code '$plantCode'.")
->seconds(3)
->title('Duplicate Serial Number')
->body("Serial number '$this->sNo' has already been scanned in stock data master for the type SFG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update')
->button()
->dispatch('confirmDuplicateUpdate', [
'plantId' => $plantId,
'location' => $location,
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'docNo' => $this->docNo,
'quantity' => $this->quantity
]),
])
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
@@ -1383,10 +1413,10 @@ class CycleCount extends Page
]);
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
$this->dispatch('refreshSfgNonData', location: $location, plantId: $plantId, serialNumber: $this->sNo, itemCode: $this->itemCode);
@@ -1430,7 +1460,7 @@ class CycleCount extends Page
if (! $record) {
Notification::make()
->title('<b><span style="color:red;">Serial Number Not Found<br>Serial \''.$serialNumber.'\' not found in database for choosed plant.</span></b>')
->title("Serial number '$serialNumber' not found in stock data table<br>Update 'Stock Data' table or Scan the valid 'Serial Number QR' data to proceed...")
->danger()
->seconds(3)
->send();
@@ -1499,6 +1529,123 @@ class CycleCount extends Page
$stickerMasterId = $stickerMaster->id;
$locationExist = StockDataMaster::where('location', $location)
->where('type', '0')
->first();
if(!$locationExist){
$existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo)
->first();
if ($existingInOtherLocation) {
Notification::make()
->title('Serial Number : Not In Stock')
->body("Serial number '{$this->sNo}' already exists against plant code '$plantCode' in not in stock table.")
->danger()
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
Notification::make()
->title('Unknown Location')
->body("location '$location' not found in stock data master for the type FG.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update')
->button()
->dispatch('confirmSerialUpdate', [
'plantId' => $plantId,
'location' => $location,
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'docNo' => $this->docNo,
'quantity' => $this->quantity
]),
])
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
$locationAgaPlant = StockDataMaster::where('plant_id', $plantId)
->where('location', $location)
->where('type', '0')
->first();
if(!$locationAgaPlant){
$existingInOtherLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo)
->first();
if ($existingInOtherLocation) {
Notification::make()
->title('Serial Number : Not In Stock')
->body("Serial number '{$this->sNo}' already exists against plant code '$plantCode' in not in stock table.")
->danger()
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
Notification::make()
->title('Unknown Location')
->body("location '$location' not found in stock data master for the type FG against plant code '$plantCode'.<br>Do you want to update in not in stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update')
->button()
->dispatch('confirmSerialUpdate', [
'plantId' => $plantId,
'location' => $location,
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'docNo' => $this->docNo,
'quantity' => $this->quantity
]),
])
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
$record = StockDataMaster::where('serial_number', $serialNumber)
->where('plant_id', $plantId)
->where('type', '0')
@@ -1509,7 +1656,30 @@ class CycleCount extends Page
->first();
if (! $record) {
$message = "serial number not found '$serialNumber' for the type FG against item code '$itemCode' and plant code '$plantCode'";
$sNoExistLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo)
->where('type', '0')
->first();
if ($sNoExistLocation) {
Notification::make()
->title('Serial Number : Not In Stock')
->body("Serial number '{$this->sNo}' already exists for the type FG against plant code '$plantCode' in not in stock table.")
->danger()
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
$message = "serial number not found '$serialNumber' for the type FG against item code '$itemCode' and plant code '$plantCode'<br>Do you want to update in not in stock table";
Notification::make()
->title('Invalid Item Code')
->body($message)
@@ -1537,23 +1707,93 @@ class CycleCount extends Page
return;
}
$serialRecord = StockDataMaster::where('serial_number', $serialNumber)
->where('plant_id', $plantId)
->where('type', '0')
->with('stickerMasterRelation.item')
->first();
if ($serialRecord && $serialRecord->stickerMasterRelation->item->code != $itemCode) {
$sNoExistLocation = NotInStock::where('plant_id', $plantId)
->where('serial_number', $this->sNo)
->where('type', '0')
->first();
if ($sNoExistLocation) {
Notification::make()
->title('Serial Number : Not In Stock')
->body("Serial number '{$this->sNo}' already exists for the type FG against plant code '$plantCode' in not in stock table.")
->danger()
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
Notification::make()
->title('Unknown Item Code')
->body("Item code not found '$this->itemCode' in stock data master for the type FG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?")
->danger()
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update')
->button()
->dispatch('confirmSerialFGUpdate', [
'plantId' => $plantId,
'location' => $location,
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
]),
])
->send();
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
}
if($record->scanned_status == 'Scanned'){
Notification::make()
->title('Duplicate: Item Code')
->body("Item code '$itemCode' and serial number '$serialNumber' have already been scanned and exist in the Stock Data Master.")
->title('Duplicate Serial Number')
->body("Serial number '$this->sNo' has already been scanned in stock data master for the type FG against plant code '$plantCode'.<br>Do you want to update in duplicate stock table?")
->danger()
->seconds(3)
->actions([
\Filament\Notifications\Actions\Action::make('confirm')
->label('Yes, Update')
->button()
->dispatch('confirmDuplicateUpdate', [
'plantId' => $plantId,
'location' => $location,
'bin' => $bin,
'serial_number' => $this->sNo,
'stickerMasterId' => $stickerMasterId,
'batch' => $this->batch,
'docNo' => $this->docNo,
'quantity' => $this->quantity
]),
])
->send();
$this->dispatch('playWarnSound');
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
$this->form->fill([
'plant_id' => $plantId,
'location' => $location,
'bin' => $bin,
'qr_code' => null,
]);
return;
@@ -1884,18 +2124,6 @@ class CycleCount extends Page
}
}
public function processLocation($value){
$location = $value;
$plantId = $this->form->getState()['plant_id'];
$plantId = trim($plantId) ?? null;
// $this->dispatch('')
// $this->dispatch('refreshInvoiceData', location: $location, plantId: $plantId);
}
protected function getHeaderActions(): array
{
return [