Refactored alignments and updated type from SFG to NON-FG on resource / importer / exporter pages
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 19:29:31 +05:30
parent ec8bfc8296
commit 658db00ac8
5 changed files with 84 additions and 97 deletions

View File

@@ -6,12 +6,12 @@ use App\Models\Item;
use App\Models\Plant;
use App\Models\StickerMaster;
use App\Models\StockDataMaster;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
class StockDataMasterImporter extends Importer
{
@@ -23,46 +23,46 @@ class StockDataMasterImporter extends Importer
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('PLANT CODE')
->example('1000')
->examples(['1000', '1000'])
->label('PLANT CODE')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('type')
->requiredMapping()
->exampleHeader('TYPE')
->example('FG/SFG')
->examples(['FG', 'NON-FG'])
->label('TYPE'),
ImportColumn::make('location')
->requiredMapping()
->exampleHeader('LOCATION')
->example('2001')
->examples(['2001', '2002'])
->label('LOCATION')
->rules(['required']),
ImportColumn::make('item_reference')// stickerMaster
ImportColumn::make('item_reference')
->requiredMapping()
->exampleHeader('ITEM CODE')
->example('123456')
->examples(['123456', '246118'])
->label('ITEM CODE')
->rules(['required']),
ImportColumn::make('serial_number')
->requiredMapping()
->exampleHeader('SERIAL NUMBER')
->example('200235236622')
->examples(['200235236622', '200235236623'])
->label('SERIAL NUMBER'),
ImportColumn::make('batch')
->requiredMapping()
->exampleHeader('BATCH')
->example('20102')
->examples(['20102', '20103'])
->label('BATCH'),
ImportColumn::make('quantity')
->requiredMapping()
->exampleHeader('QUANTITY')
->example('1')
->examples(['1', '1'])
->label('QUANTITY'),
ImportColumn::make('doc_no')
->requiredMapping()
->exampleHeader('DOCUMENT NUMBER')
->example('156566')
->examples(['82128', '21222'])
->label('DOCUMENT NUMBER'),
];
}
@@ -86,26 +86,21 @@ class StockDataMasterImporter extends Importer
$operatorName = $user->name;
if ($plantCod == null || $plantCod == '') {
$warnMsg[] = "Plant code can't be empty!";
}
else if ($typeValue == null || $typeValue == '') {
} elseif ($typeValue == null || $typeValue == '') {
$warnMsg[] = "Type can't be empty!";
}
else if ($iCode == null || $iCode == '') {
} elseif ($iCode == null || $iCode == '') {
$warnMsg[] = "Item code can't be empty!";
}
else if ($location == null || $location == '') {
} elseif ($location == null || $location == '') {
$warnMsg[] = "Location can't be empty!";
}
else if ($serialNumber == null || $serialNumber == '') {
} elseif ($serialNumber == null || $serialNumber == '') {
$warnMsg[] = "Serial number can't be empty!";
}
// else if ($batch == null || $batch == '') {
// $warnMsg[] = "Batch can't be empty!";
// }
else if ($quantity == null || $quantity == '') {
elseif ($quantity == null || $quantity == '') {
$warnMsg[] = "Quantity can't be empty!";
}
// else if ($docNo == null || $docNo == '') {
@@ -152,33 +147,27 @@ class StockDataMasterImporter extends Importer
$typeValue = strtoupper($typeValue);
if (! in_array($typeValue, ['FG', 'SFG'])) {
$warnMsg[] = 'Invalid type found! It should be either FG or SFG and fg/sfg.';
}
else if (Str::length($location) < 4) {
if (! in_array($typeValue, ['FG', 'NON-FG'])) {
$warnMsg[] = 'Invalid type found! It should be either FG or NON-FG.';
} elseif (Str::length($location) < 4) {
$warnMsg[] = 'Location should contain minimum 4 digits!';
}
else if (! ctype_digit((string) $location)) {
} elseif (! ctype_digit((string) $location)) {
$warnMsg[] = 'Location must be an integer!';
}
else if (Str::length($serialNumber) < 9) {
} elseif (Str::length($serialNumber) < 9) {
$warnMsg[] = 'Serial number should contain minimum 9 digits!';
}
else if (!ctype_alnum($serialNumber)) {
} elseif (! ctype_alnum($serialNumber)) {
$warnMsg[] = 'Serial number should contain alpha-numeric values!';
}
else if (! ctype_digit((string) $quantity) || (int) $quantity <= 0) {
} elseif (! ctype_digit((string) $quantity) || (int) $quantity <= 0) {
$warnMsg[] = 'Quantity must be an integer and greater than 0!';
}
if($batch){
if ($batch) {
if (Str::length($batch) < 5) {
$warnMsg[] = 'Batch should contain minimum 5 digits!';
}
}
if($docNo){
if ($docNo) {
if (Str::length($docNo) < 5) {
$warnMsg[] = 'Document number contain minimum 5 digits!';
}
@@ -190,7 +179,7 @@ class StockDataMasterImporter extends Importer
$type = match ($typeValue) {
'FG' => '0',
'SFG' => '1',
'NON-FG' => '1',
default => null,
};
@@ -199,7 +188,7 @@ class StockDataMasterImporter extends Importer
$record = StockDataMaster::where([
'plant_id' => $plantId,
'sticker_master_id' => $stickId,
'serial_number' => $serialNumber
'serial_number' => $serialNumber,
])->first();
if ($record) {
@@ -234,10 +223,10 @@ class StockDataMasterImporter extends Importer
public static function getCompletedNotificationBody(Import $import): string
{
$body = 'Your stock data master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
$body = 'Your stock data master import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
}
return $body;