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

@@ -60,8 +60,61 @@ class StockDataMasterExporter extends Exporter
->label('PANEL BOX SNO'),
ExportColumn::make('scanned_status')
->label('SCANNED STATUS'),
ExportColumn::make('scanned_count')
->label('SCANNED COUNT'),
ExportColumn::make('scanned_quantity')
->label('SCANNED QUANTITY'),
ExportColumn::make('system_stock')
->label('SYSTEM STOCK')
->state(fn ($record) => $record->quantity),
ExportColumn::make('scanned_stock')
->label('SCANNED STOCK')
->state(fn ($record) => $record->scanned_quantity),
ExportColumn::make('duplicate_stock')
->label('DUPLICATE STOCK')
->state(function ($record) {
return \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
}),
ExportColumn::make('not_in_stock')
->label('NOT IN STOCK')
->state(function ($record) {
return \App\Models\NotInStock::where('serial_number', $record->serial_number)
->where('plant_id', $record->plant_id)
->count();
}),
ExportColumn::make('physical_stock')
->label('PHYSICAL STOCK')
->state(function ($record) {
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
->where('plant_id', $record->plant_id)
->count();
$scanned = $record->scanned_quantity ?? 0;
return $scanned + $duplicate + $notInStock;
}),
ExportColumn::make('stock_difference')
->label('STOCK DIFFERENCE COUNT')
->state(function ($record) {
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
->where('plant_id', $record->plant_id)
->count();
$scanned = (int) $record->scanned_quantity;
$physicalStock = $scanned + $duplicate + $notInStock;
$systemStock = (int) $record->quantity;
$difference = $physicalStock - $systemStock;
return max($difference, 0);
}),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')

View File

@@ -612,10 +612,26 @@ 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([
@@ -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')
@@ -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,10 +1373,24 @@ 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([
@@ -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,17 +1707,87 @@ 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,
@@ -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 [

View File

@@ -304,12 +304,13 @@ class StockDataMasterResource extends Resource
->label('Advanced Filters')
->form([
Radio::make('type')
->label('Type')
->label('Stock Type')
->options([
'0' => 'FG',
'1' => 'SFG',
])
->inline()
->default('0')
->nullable(),
Select::make('Plant')
->label('Select Plant')