Compare commits
34 Commits
80d24b7448
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b5468fdf7 | |||
|
|
27b5ad2cfe | ||
| 74cdcb89b9 | |||
|
|
4c7bed8c63 | ||
| 60d17902a2 | |||
|
|
253d319587 | ||
|
|
ead2edc63b | ||
|
|
18f23ce097 | ||
| 6a752b81b2 | |||
|
|
198b901671 | ||
|
|
3192e32d5d | ||
| 44b2ff6f24 | |||
|
|
61be13c367 | ||
| 7a242c820c | |||
|
|
3d139c005a | ||
| bc02a49b54 | |||
|
|
4325f2695f | ||
|
|
8eeb23e2aa | ||
| aa60fc14e0 | |||
|
|
73611a417b | ||
| e7a7ea063f | |||
|
|
37df670eab | ||
| 891b02b6a4 | |||
|
|
58b801b8e2 | ||
|
|
5aa2e7a871 | ||
| 10eff34cc9 | |||
|
|
97fb46883f | ||
| 1a37dd5e49 | |||
|
|
e20892cc83 | ||
|
|
658db00ac8 | ||
| 6bdabe3e1f | |||
|
|
ec8bfc8296 | ||
| 1dba08f5da | |||
|
|
6dff4fb77e |
@@ -36,6 +36,8 @@ class ProcessOrderExporter extends Exporter
|
||||
->label('COIL NUMBER'),
|
||||
ExportColumn::make('order_quantity')
|
||||
->label('ORDER QUANTITY'),
|
||||
ExportColumn::make('updated_order_quantity')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ExportColumn::make('received_quantity')
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ExportColumn::make('sfg_number')
|
||||
|
||||
@@ -14,6 +14,7 @@ class StockDataMasterExporter extends Exporter
|
||||
public static function getColumns(): array
|
||||
{
|
||||
static $rowNumber = 0;
|
||||
|
||||
return [
|
||||
ExportColumn::make('no')
|
||||
->label('NO')
|
||||
@@ -29,7 +30,7 @@ class StockDataMasterExporter extends Exporter
|
||||
->label('TYPE')
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
}),
|
||||
ExportColumn::make('location')
|
||||
@@ -93,7 +94,7 @@ class StockDataMasterExporter extends Exporter
|
||||
$scanned = $record->scanned_quantity ?? 0;
|
||||
|
||||
return $scanned + $duplicate + $notInStock;
|
||||
}),
|
||||
}),
|
||||
|
||||
ExportColumn::make('stock_difference')
|
||||
->label('STOCK DIFFERENCE COUNT')
|
||||
@@ -114,7 +115,7 @@ class StockDataMasterExporter extends Exporter
|
||||
$difference = $physicalStock - $systemStock;
|
||||
|
||||
return max($difference, 0);
|
||||
}),
|
||||
}),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
@@ -131,10 +132,10 @@ class StockDataMasterExporter extends Exporter
|
||||
|
||||
public static function getCompletedNotificationBody(Export $export): string
|
||||
{
|
||||
$body = 'Your stock data master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||
$body = 'Your stock data master export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
|
||||
|
||||
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@@ -52,6 +52,9 @@ class ProcessOrderImporter extends Importer
|
||||
->example('1000')
|
||||
->label('ORDER QUANTITY')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('updated_order_quantity')
|
||||
->exampleHeader('UPDATED ORDER QUANTITY')
|
||||
->label('UPDATED ORDER QUANTITY'),
|
||||
ImportColumn::make('coil_number')
|
||||
->exampleHeader('COIL NUMBER')
|
||||
// ->example('01')
|
||||
@@ -110,6 +113,7 @@ class ProcessOrderImporter extends Importer
|
||||
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$orderQuan = trim($this->data['order_quantity'] ?? '');
|
||||
$updatedOrderQuan = trim($this->data['updated_order_quantity'] ?? '');
|
||||
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
|
||||
$reworkStatus = trim($this->data['rework_status'] ?? '');
|
||||
$recQuan = trim($this->data['received_quantity'] ?? '');
|
||||
@@ -128,11 +132,14 @@ class ProcessOrderImporter extends Importer
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = "Item code can't be empty!";
|
||||
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
}
|
||||
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
|
||||
$warnMsg[] = 'Invalid machine name found!';
|
||||
}
|
||||
if ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = "Process order can't be empty!";
|
||||
} elseif ($processOrder && Str::contains($processOrder, '.')) {
|
||||
} elseif ($processOrder && (Str::contains($processOrder, '.') || Str::contains($processOrder, 'E', ignoreCase: true))) {
|
||||
$warnMsg[] = 'Invalid process order found!';
|
||||
}
|
||||
if ($lineNam == null || $lineNam == '') {
|
||||
@@ -145,6 +152,12 @@ class ProcessOrderImporter extends Importer
|
||||
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
|
||||
$warnMsg[] = 'Invalid order quantity found!';
|
||||
}
|
||||
if ($updatedOrderQuan == null || $updatedOrderQuan == '' || $updatedOrderQuan == 0 || $updatedOrderQuan == '0') {
|
||||
$updatedOrderQuan = $orderQuan;
|
||||
} elseif (Str::length($updatedOrderQuan) >= 1 && ! is_numeric($updatedOrderQuan)) {
|
||||
$warnMsg[] = 'Invalid Updated order quantity found!';
|
||||
}
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$coilNo = '0';
|
||||
}
|
||||
@@ -159,7 +172,7 @@ class ProcessOrderImporter extends Importer
|
||||
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
|
||||
$reworkStatus = 1;
|
||||
} else {
|
||||
$warnMsg[] = 'Invalid rework status found';
|
||||
$warnMsg[] = 'Invalid rework status found!';
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
@@ -223,7 +236,7 @@ class ProcessOrderImporter extends Importer
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code!';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,6 +256,39 @@ class ProcessOrderImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
$receivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->sum('received_quantity');
|
||||
|
||||
if ($existing) {
|
||||
$liveOrdQuan = (float) $existing->order_quantity;
|
||||
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
|
||||
|
||||
$allowedIncrease = $liveOrdQuan * 0.10;
|
||||
|
||||
$maxAllowedQty = $liveOrdQuan + $allowedIncrease;
|
||||
$minAllowedQty = $liveOrdQuan - $allowedIncrease;
|
||||
|
||||
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
|
||||
);
|
||||
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -250,6 +296,17 @@ class ProcessOrderImporter extends Importer
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
// $existingProcess = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// ->where('line_id', $lineId)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existingCoil) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
@@ -259,6 +316,7 @@ class ProcessOrderImporter extends Importer
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -288,10 +346,16 @@ class ProcessOrderImporter extends Importer
|
||||
}
|
||||
} else {
|
||||
$coilNo = '0';
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
// ->where('coil_number', $coilNo)
|
||||
->first();
|
||||
// $existing = ProcessOrder::where('plant_id', $plantId)
|
||||
// ->where('process_order', $processOrder)
|
||||
// // ->where('coil_number', $coilNo)
|
||||
// ->first();
|
||||
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
||||
ProcessOrder::create([
|
||||
@@ -301,6 +365,7 @@ class ProcessOrderImporter extends Importer
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => '0',
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => 0,
|
||||
'scrap_quantity' => 0,
|
||||
'created_by' => $createdBy,
|
||||
@@ -315,6 +380,7 @@ class ProcessOrderImporter extends Importer
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'updated_order_quantity' => $existUpdateOrdQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan ?? 0,
|
||||
'sfg_number' => $sfgNo,
|
||||
|
||||
@@ -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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\DuplicateStockResource\Pages;
|
||||
use App\Filament\Resources\DuplicateStockResource\RelationManagers;
|
||||
use App\Models\DuplicateStock;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
@@ -97,7 +96,7 @@ class DuplicateStockResource extends Resource
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
})
|
||||
->sortable(),
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\NotInStockResource\Pages;
|
||||
use App\Filament\Resources\NotInStockResource\RelationManagers;
|
||||
use App\Models\NotInStock;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -38,15 +37,15 @@ class NotInStockResource extends Resource
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
if (!$get('plant_id')) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return StickerMaster::with('item')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->get()
|
||||
->pluck('item.code', 'id')
|
||||
->toArray();
|
||||
return StickerMaster::with('item')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->get()
|
||||
->pluck('item.code', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('location')
|
||||
->label('Location'),
|
||||
@@ -64,7 +63,7 @@ class NotInStockResource extends Resource
|
||||
->label('Type')
|
||||
->options([
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
]),
|
||||
Forms\Components\TextInput::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status'),
|
||||
@@ -122,7 +121,7 @@ class NotInStockResource extends Resource
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
})
|
||||
->sortable(),
|
||||
|
||||
@@ -74,6 +74,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -113,6 +114,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -141,6 +143,7 @@ class ProcessOrderResource extends Resource
|
||||
$set('process_order', null);
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -217,6 +220,7 @@ class ProcessOrderResource extends Resource
|
||||
$plantId = $get('plant_id');
|
||||
$set('coil_number', '0');
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
$set('received_quantity', '0');
|
||||
$set('scrap_quantity', '0');
|
||||
$set('sfg_number', null);
|
||||
@@ -280,10 +284,10 @@ class ProcessOrderResource extends Resource
|
||||
->required()
|
||||
->reactive()
|
||||
->numeric()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
// $coilNo = $get('coil_number');
|
||||
if (! $plantId) {
|
||||
$set('poPlantError', 'Please select a plant first.');
|
||||
@@ -319,14 +323,29 @@ class ProcessOrderResource extends Resource
|
||||
function (callable $get) {
|
||||
return Rule::unique('process_orders', 'coil_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->where('process_order', $get('process_order'))
|
||||
->where('process_order', trim($get('process_order')))
|
||||
->ignore($get('id'));
|
||||
},
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$rework = $get('rework_status');
|
||||
if ($value && Str::contains($value, '.') && $rework == 0) {
|
||||
$fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if ($value && Str::contains($value, '.')) {
|
||||
if ($rework == 0) {
|
||||
$fail("Rework status should be 'Yes' for rework coil number '{$value}'!");
|
||||
}
|
||||
} elseif ($value > 1) {
|
||||
$prevCoilNo = (string) ($value - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
$fail("Previous coil number '{$prevCoilNo}' not exist against plant and process order!");
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -334,7 +353,7 @@ class ProcessOrderResource extends Resource
|
||||
// ->rule(function (callable $get) {
|
||||
// return Rule::unique('process_orders', 'coil_number')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->where('process_order', $get('process_order'))
|
||||
// ->where('process_order', trim($get('process_order')))
|
||||
// ->ignore($get('id'));
|
||||
// })
|
||||
->extraAttributes(fn ($get) => [
|
||||
@@ -348,15 +367,17 @@ class ProcessOrderResource extends Resource
|
||||
->required()
|
||||
->reactive()
|
||||
->numeric()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$set('received_quantity', '0');
|
||||
// $set('updated_order_quantity', $state);
|
||||
$set('scrap_quantity', '0');
|
||||
if (! $plantId || ! $itemId || ! $processOrder) {
|
||||
$set('order_quantity', '0');
|
||||
$set('updated_order_quantity', '0');
|
||||
}
|
||||
|
||||
$query = ProcessOrder::where('plant_id', $plantId)
|
||||
@@ -372,13 +393,175 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('updated_order_quantity')
|
||||
->label('Updated Order Quantity')
|
||||
->required()
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == '' || trim($get('order_quantity')) == '' || trim($get('order_quantity')) == null))
|
||||
->reactive()
|
||||
->rules([
|
||||
function (callable $get): Closure {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$plantId = $get('plant_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$receivedQty = $get('received_quantity');
|
||||
|
||||
$currentId = $get('id');
|
||||
|
||||
$orderQty = (float) $get('order_quantity');
|
||||
$updatedQty = (float) $value;
|
||||
|
||||
$allowedVariance = $orderQty * 0.10;
|
||||
|
||||
$maxAllowed = $orderQty + $allowedVariance;
|
||||
$minAllowed = $orderQty - $allowedVariance;
|
||||
|
||||
if ($updatedQty > $maxAllowed || $updatedQty < $minAllowed) {
|
||||
$fail('Quantity can vary by ±10% of the order quantity.');
|
||||
}
|
||||
|
||||
$otherReceivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->when($currentId, fn ($q) => $q->where('id', '!=', $currentId))
|
||||
->sum('received_quantity');
|
||||
|
||||
$currentReceivedQty = (float) $get('received_quantity');
|
||||
|
||||
$totalReceivedQty = $otherReceivedQty + $currentReceivedQty;
|
||||
|
||||
if ($updatedQty < $totalReceivedQty) {
|
||||
$fail("You cannot set quantity below received quantity ({$totalReceivedQty}).");
|
||||
}
|
||||
};
|
||||
},
|
||||
]),
|
||||
Forms\Components\TextInput::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->default('0.000')
|
||||
->required()
|
||||
->reactive()
|
||||
->numeric()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->maxValue(fn (Get $get) => $get('order_quantity') ?? PHP_INT_MAX)
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->rule(function (callable $get) {
|
||||
return function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$rework = $get('rework_status');
|
||||
$plantId = $get('plant_id');
|
||||
$lineId = $get('line_id');
|
||||
$itemId = $get('item_id');
|
||||
$processOrder = trim($get('process_order'));
|
||||
$coilNo = trim($get('coil_number'));
|
||||
|
||||
$orderExist = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)->latest()->first();
|
||||
|
||||
if ($orderExist) {
|
||||
// $orderQty = $orderExist->order_quantity ?? 0;
|
||||
$orderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
|
||||
$alreadyReceived = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->sum('received_quantity');
|
||||
|
||||
$total = $alreadyReceived + $value;
|
||||
|
||||
if ($rework == 1) {
|
||||
if ($coilNo && Str::contains($coilNo, '.')) {
|
||||
$coilMain = explode('.', $coilNo)[0];
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilMain)
|
||||
->first();
|
||||
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existPrevCoil && $existPrevCoil->received_quantity < $value) {
|
||||
$fail('Rework received quantity should not exceed exist received quantity!');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($existingCoil && $existingCoil->rework_status == 1 && $total > $orderQty) {
|
||||
$fail("Rework received quantity should not exceed exist order quantity! Already Exist Total Received Qty = '{$alreadyReceived}'.");
|
||||
}
|
||||
} else {
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if (! $existingCoil) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existPrevCoil && $existPrevCoil->received_quantity < $value) {
|
||||
$fail('Rework received quantity should not exceed exist received quantity!');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($coilNo && Str::contains($coilNo, '.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
if ($existing) {
|
||||
if ($existing->received_quantity < $value) {
|
||||
$fail('Received quantity should not exceed exist received quantity!'); // Exist Received Qty = '{$existing->received_quantity}'.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $prevCoilNo)
|
||||
->first();
|
||||
|
||||
if (! $existPrevCoil) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $orderQty) {
|
||||
$fail("Received quantity should not exceed exist order quantity! Already Exist Total Received Qty = '{$alreadyReceived}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('scrap_quantity', '0');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
@@ -387,7 +570,7 @@ class ProcessOrderResource extends Resource
|
||||
->label('Scrap Quantity')
|
||||
->default('0.000')
|
||||
->required()
|
||||
->readOnly(fn ($get) => ($get('rework_status') == 0 || $get('process_order') == null))
|
||||
->readOnly(fn ($get) => ($get('rework_status') == 0 || trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->reactive()
|
||||
->numeric()
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
@@ -414,7 +597,7 @@ class ProcessOrderResource extends Resource
|
||||
Forms\Components\TextInput::make('sfg_number')
|
||||
->label('SFG Number')
|
||||
->reactive()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
|
||||
$plantId = $get('plant_id');
|
||||
$sfgNo = $get('sfg_number');
|
||||
@@ -448,7 +631,8 @@ class ProcessOrderResource extends Resource
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->reactive()
|
||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||
->maxLength(18)
|
||||
->readOnly(fn ($get) => (trim($get('process_order')) == null || trim($get('process_order')) == ''))
|
||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -576,7 +760,7 @@ class ProcessOrderResource extends Resource
|
||||
}
|
||||
|
||||
// Get the value of process_order field
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if ($batchId != $processOrder) {
|
||||
Notification::make()
|
||||
@@ -621,7 +805,7 @@ class ProcessOrderResource extends Resource
|
||||
return Filament::auth()->user()->can('view process order packing slip');
|
||||
})
|
||||
->action(function ($get, callable $set) {
|
||||
$equipmentNumber = $get('process_order');
|
||||
$equipmentNumber = trim($get('process_order'));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
if (! $equipmentNumber) {
|
||||
@@ -720,6 +904,11 @@ class ProcessOrderResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_order_quantity')
|
||||
->label('Updated Order Quantity')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('received_quantity')
|
||||
->label('Received Quantity')
|
||||
->alignCenter()
|
||||
@@ -1064,7 +1253,7 @@ class ProcessOrderResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$itemId = $get('Item');
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if (empty($plantId) || empty($itemId) || empty($processOrder)) {
|
||||
return [];
|
||||
@@ -1081,7 +1270,7 @@ class ProcessOrderResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant');
|
||||
$itemId = $get('Item');
|
||||
$processOrder = $get('process_order');
|
||||
$processOrder = trim($get('process_order'));
|
||||
|
||||
if (! $plantId || ! $itemId || ! $processOrder || ! $state) {
|
||||
$set('received_quantity', null);
|
||||
|
||||
@@ -3,10 +3,28 @@
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProcessOrder extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
$plantId = $this->data['plant_id'];
|
||||
$processOrder = $this->data['process_order'];
|
||||
$updatedQty = (float) $this->data['updated_order_quantity'];
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->update([
|
||||
'updated_order_quantity' => $updatedQty,
|
||||
'updated_by' => Filament::auth()->user()->name,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,78 @@
|
||||
namespace App\Filament\Resources\ProcessOrderResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ProcessOrderResource;
|
||||
use App\Models\ProcessOrder;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProcessOrder extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProcessOrderResource::class;
|
||||
|
||||
protected function beforeSave(): void
|
||||
{
|
||||
$plantId = $this->data['plant_id'] ?? null;
|
||||
$processOrder = $this->data['process_order'] ?? null;
|
||||
$extraQty = (float) ($this->data['updated_order_quantity'] ?? 0);
|
||||
$extraQtyRaw = $this->data['updated_order_quantity'] ?? '';
|
||||
|
||||
if (!preg_match('/^\d+(\.\d{1,3})?$/', $extraQtyRaw)) {
|
||||
Notification::make()
|
||||
->title('Invalid Quantity')
|
||||
->body('Only positive numbers with up to 3 decimal places are allowed.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt(); // stop save
|
||||
}
|
||||
|
||||
if ($extraQty < 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Invalid Quantity')
|
||||
->body('Negative values are not allowed.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
if ($extraQty > 0) {
|
||||
|
||||
$order = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($order) {
|
||||
|
||||
$baseQty = (float) $order->order_quantity;
|
||||
$maxAllowed = $baseQty * 0.10;
|
||||
|
||||
$maxFinalQty = $baseQty + $maxAllowed;
|
||||
|
||||
if ($extraQty > $maxFinalQty) {
|
||||
Notification::make()
|
||||
->title('Limit Exceeded')
|
||||
->body("You can only increase the order by 10% (Max allowed: {$maxFinalQty}).")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->halt(); // stops save
|
||||
}
|
||||
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->update([
|
||||
'updated_order_quantity' => $extraQty,
|
||||
'updated_by' => Filament::auth()->user()?->name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -5,28 +5,26 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\StockDataMasterExporter;
|
||||
use App\Filament\Imports\StockDataMasterImporter;
|
||||
use App\Filament\Resources\StockDataMasterResource\Pages;
|
||||
use App\Filament\Resources\StockDataMasterResource\RelationManagers;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use App\Models\SerialValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use App\Models\StockDataMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class StockDataMasterResource extends Resource
|
||||
{
|
||||
@@ -51,15 +49,15 @@ class StockDataMasterResource extends Resource
|
||||
->required()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
if (!$get('plant_id')) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return StickerMaster::with('item')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->get()
|
||||
->pluck('item.code', 'id')
|
||||
->toArray();
|
||||
return StickerMaster::with('item')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->get()
|
||||
->pluck('item.code', 'id')
|
||||
->toArray();
|
||||
}),
|
||||
Forms\Components\TextInput::make('location')
|
||||
->label('Location'),
|
||||
@@ -77,7 +75,7 @@ class StockDataMasterResource extends Resource
|
||||
->label('Type')
|
||||
->options([
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
]),
|
||||
Forms\Components\TextInput::make('motor_scanned_status')
|
||||
->label('Motor Scanned Status'),
|
||||
@@ -135,7 +133,7 @@ class StockDataMasterResource extends Resource
|
||||
->searchable()
|
||||
->formatStateUsing(fn ($state) => match ($state) {
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
default => '-',
|
||||
})
|
||||
->sortable(),
|
||||
@@ -258,27 +256,27 @@ class StockDataMasterResource extends Resource
|
||||
|
||||
return $scanned + $duplicate + $notInStock;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('stock_difference')
|
||||
->label('Stock Difference Count')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record) {
|
||||
Tables\Columns\TextColumn::make('stock_difference')
|
||||
->label('Stock Difference Count')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record) {
|
||||
|
||||
$duplicate = \App\Models\DuplicateStock::where('stock_data_master_id', $record->id)->count();
|
||||
$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();
|
||||
$notInStock = \App\Models\NotInStock::where('serial_number', $record->serial_number)
|
||||
->where('plant_id', $record->plant_id)
|
||||
->count();
|
||||
|
||||
$scanned = (int) $record->scanned_quantity;
|
||||
$scanned = (int) $record->scanned_quantity;
|
||||
|
||||
$physicalStock = $scanned + $duplicate + $notInStock;
|
||||
$physicalStock = $scanned + $duplicate + $notInStock;
|
||||
|
||||
$systemStock = (int) $record->quantity;
|
||||
$systemStock = (int) $record->quantity;
|
||||
|
||||
$difference = $physicalStock - $systemStock;
|
||||
$difference = $physicalStock - $systemStock;
|
||||
|
||||
return max($difference, 0); // prevents negative values
|
||||
}),
|
||||
return max($difference, 0); // prevents negative values
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
@@ -307,7 +305,7 @@ class StockDataMasterResource extends Resource
|
||||
->label('Stock Type')
|
||||
->options([
|
||||
'0' => 'FG',
|
||||
'1' => 'SFG',
|
||||
'1' => 'NON-FG',
|
||||
])
|
||||
->inline()
|
||||
->default('0')
|
||||
@@ -346,6 +344,7 @@ class StockDataMasterResource extends Resource
|
||||
if (empty($pId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::whereHas('stickerMasters', function ($query) use ($pId) {
|
||||
if ($pId) {
|
||||
$query->where('plant_id', $pId);
|
||||
@@ -389,7 +388,7 @@ class StockDataMasterResource extends Resource
|
||||
->native(false),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
if (!isset($data['type']) && (empty($data['Plant']) && empty($data['location']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||
if (! isset($data['type']) && (empty($data['Plant']) && empty($data['location']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||
|
||||
if (empty($data['type'])) {
|
||||
Notification::make()
|
||||
@@ -397,16 +396,17 @@ class StockDataMasterResource extends Resource
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
if($data['type'] != ''){
|
||||
if ($data['type'] != '') {
|
||||
|
||||
if ($data['type'] == '0') {
|
||||
|
||||
$query->where('type', '0');
|
||||
|
||||
if (!empty($data['scanned_status'])) {
|
||||
if (! empty($data['scanned_status'])) {
|
||||
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
$query->whereNotNull('scanned_status')
|
||||
@@ -428,32 +428,31 @@ class StockDataMasterResource extends Resource
|
||||
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
|
||||
$query->whereNotNull('scanned_status')
|
||||
$query->whereNotNull('scanned_status')
|
||||
->where('scanned_status', '!=', '');
|
||||
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if ($data['scanned_status']) {
|
||||
|
||||
if ($data['scanned_status'] == 'Scanned') {
|
||||
|
||||
$query->whereNotNull('scanned_status')
|
||||
$query->whereNotNull('scanned_status')
|
||||
->where('scanned_status', '!=', '');
|
||||
|
||||
} elseif ($data['scanned_status'] == 'Pending') {
|
||||
|
||||
$query->where(function ($q) {
|
||||
$q->whereNull('scanned_status')
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
->orWhere('scanned_status', '!=', 'Scanned');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -627,7 +627,7 @@ class PdfController extends Controller
|
||||
// 'coil_number' => $proOrdAgPlant->coil_number ?? "",
|
||||
// 'order_quantity' => (string)$proOrdAgPlant->order_quantity ?? "",
|
||||
'coil_number' => $currentCoil,
|
||||
'order_quantity' => (string) $lastRecord->order_quantity ?? '0.000',
|
||||
'order_quantity' => (string) $lastRecord->updated_order_quantity ?? '0.000',
|
||||
'ok_quantity' => (string) $okQty ?? '0',
|
||||
'not_ok_quantity' => (string) $notOkQty ?? '0',
|
||||
'received_quantity' => (string) (($totalReceivedQty == 0) ? '0.000' : $totalReceivedQty) ?? '0.000',
|
||||
@@ -686,7 +686,7 @@ class PdfController extends Controller
|
||||
$itemCode = $data['item_code'] ?? '';
|
||||
$lineName = $data['line_name'] ?? '';
|
||||
$coilNo = $data['coil_number'] ?? '';
|
||||
$orderQty = $data['order_quantity'] ?? 0;
|
||||
$updatedOrderQty = $data['order_quantity'] ?? 0;
|
||||
$receivedQty = $data['received_quantity'] ?? 0;
|
||||
$scrapQty = $data['scrap_quantity'] ?? 0;
|
||||
$sfgNo = $data['sfg_number'] ?? '';
|
||||
@@ -728,6 +728,17 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($scrapQty == null || $scrapQty == '') {
|
||||
$scrapQty = 0;
|
||||
}
|
||||
|
||||
if ($rework == null || $rework == '' || ! $rework) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$line = Line::where('name', $lineName)->first();
|
||||
|
||||
if (! $line) {
|
||||
@@ -861,7 +872,8 @@ class PdfController extends Controller
|
||||
->where('item_id', $itemId)
|
||||
->sum('received_quantity');
|
||||
|
||||
if ($orderQty == 0) {
|
||||
$orderQty = 0;
|
||||
if ($updatedOrderQty == 0) {
|
||||
$orderExist = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)->latest()->first();
|
||||
@@ -869,6 +881,7 @@ class PdfController extends Controller
|
||||
|
||||
if ($orderExist) {
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
$updatedOrderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
} else {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -882,9 +895,11 @@ class PdfController extends Controller
|
||||
// ->value('order_quantity') ?? 0;
|
||||
|
||||
if ($orderExist) {
|
||||
$existOrderQty = $orderExist->order_quantity ?? 0;
|
||||
// $existOrderQty = $orderExist->updated_order_quantity ?? 0;
|
||||
$orderQty = $orderExist->order_quantity ?? 0;
|
||||
$existUpdatedOrdQuan = $orderExist->updated_order_quantity ?? 0;
|
||||
|
||||
if ($existOrderQty != $orderQty) {
|
||||
if ($existUpdatedOrdQuan != $updatedOrderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Order quantity doesn't equal to exist process order '{$processOrder}'",
|
||||
@@ -895,20 +910,6 @@ class PdfController extends Controller
|
||||
|
||||
$total = $alreadyReceived + $receivedQty;
|
||||
|
||||
if ($total > $orderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Received quantity should not exceed order quantity! Order Qty = {$orderQty}, Already Received Qty = {$alreadyReceived}, Trying to Insert Qty = {$receivedQty}",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($rework == null || $rework == '' || ! $rework) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework value can't be empty!",
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($rework != 'Yes' && $rework != 'No') {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
@@ -949,6 +950,13 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
@@ -964,6 +972,7 @@ class PdfController extends Controller
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'updated_order_quantity' => $updatedOrderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
@@ -994,7 +1003,7 @@ class PdfController extends Controller
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if ($coilNo >= 1) {
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -1004,7 +1013,7 @@ class PdfController extends Controller
|
||||
if (! $existPrevCoil) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Previouse coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
@@ -1022,6 +1031,19 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('item_id', $itemId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if ($existPrevCoil->received_quantity < $receivedQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Rework received quantity should not exceed exist received quantity! Exist Received Qty = '{$existPrevCoil->received_quantity}', Trying to Insert Rework Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
$updated = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineNamePlantId)
|
||||
@@ -1070,7 +1092,7 @@ class PdfController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
if ($coilNo >= 1) {
|
||||
if ($coilNo > 1) {
|
||||
$prevCoilNo = (string) ($coilNo - 1);
|
||||
$existPrevCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
@@ -1080,11 +1102,18 @@ class PdfController extends Controller
|
||||
if (! $existPrevCoil) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Previouse coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
'status_description' => "Previous coil number '{$prevCoilNo}' not exist against plant code '{$plantCode}' and process order '{$processOrder}'!",
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
||||
if ($total > $updatedOrderQty) {
|
||||
return response()->json([
|
||||
'status_code' => 'ERROR',
|
||||
'status_description' => "Received quantity should not exceed exist order quantity! Exist Order Qty = '{$updatedOrderQty}', Already Exist Total Received Qty = '{$alreadyReceived}', Trying to Insert Received Qty = '{$receivedQty}'",
|
||||
], 404);
|
||||
}
|
||||
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plantId,
|
||||
@@ -1093,6 +1122,7 @@ class PdfController extends Controller
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQty,
|
||||
'updated_order_quantity' => $updatedOrderQty,
|
||||
'received_quantity' => $receivedQty,
|
||||
'scrap_quantity' => $scrapQty,
|
||||
'sfg_number' => $sfgNo,
|
||||
|
||||
@@ -30,7 +30,7 @@ class UserController extends Controller
|
||||
* Display the specified resource.
|
||||
*/
|
||||
// show(string $id)
|
||||
public function get_testing_data(Request $request)
|
||||
public function get_user_data(Request $request)
|
||||
{
|
||||
$expectedUser = env('API_AUTH_USER');
|
||||
$expectedPw = env('API_AUTH_PW');
|
||||
|
||||
@@ -209,12 +209,13 @@ class StockDataTable extends Component
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmSerialFGUpdate($plantId, $location, $bin, $sNo, $stickerMasterId)
|
||||
public function confirmSerialFGUpdate($plantId, $location, $bin, $serial_number, $stickerMasterId)
|
||||
{
|
||||
|
||||
$sNo = $serial_number;
|
||||
$record = NotInStock::where('plant_id', $plantId)
|
||||
->where('location', $location)
|
||||
->where('sticker_master_id', $stickerMasterId)
|
||||
->where('serial_number', $sNo)
|
||||
->where('bin', $bin)
|
||||
->first();
|
||||
|
||||
@@ -225,7 +226,7 @@ class StockDataTable extends Component
|
||||
'location' => $location,
|
||||
'bin' => $bin,
|
||||
'sticker_master_id' => $stickerMasterId,
|
||||
'type' => '1',
|
||||
'type' => '0',
|
||||
'serial_number' => $sNo ?? null,
|
||||
'batch' => $batch ?? null,
|
||||
'doc_no' => $docNo ?? null,
|
||||
|
||||
@@ -64,6 +64,11 @@ class Item extends Model
|
||||
return $this->hasMany(CharacteristicValue::class);
|
||||
}
|
||||
|
||||
public function ClassCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ClassCharacteristic::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function weightValidations()
|
||||
{
|
||||
return $this->hasMany(WeightValidation::class);
|
||||
|
||||
@@ -43,6 +43,11 @@ class Machine extends Model
|
||||
return $this->hasMany(CharacteristicValue::class);
|
||||
}
|
||||
|
||||
public function ClassCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ClassCharacteristic::class, 'machine_id', 'id');
|
||||
}
|
||||
|
||||
public function testingPanelReadings()
|
||||
{
|
||||
return $this->hasMany(TestingPanelReading::class);
|
||||
|
||||
@@ -113,6 +113,11 @@ class Plant extends Model
|
||||
return $this->hasMany(EquipmentMaster::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
public function ClassCharacteristics()
|
||||
{
|
||||
return $this->hasMany(ClassCharacteristic::class, 'plant_id', 'id');
|
||||
}
|
||||
|
||||
// public function rejectReasons()
|
||||
// {
|
||||
// return $this->hasMany(RejectReason::class, 'plant_id', 'id');
|
||||
|
||||
@@ -21,6 +21,7 @@ class ProcessOrder extends Model
|
||||
'coil_number',
|
||||
'order_quantity',
|
||||
'received_quantity',
|
||||
'updated_order_quantity',
|
||||
'sfg_number',
|
||||
'machine_name',
|
||||
'scrap_quantity',
|
||||
|
||||
@@ -142,7 +142,7 @@ return new class extends Migration
|
||||
zmm_type TEXT DEFAULT NULL,
|
||||
zmm_usp TEXT DEFAULT NULL,
|
||||
mark_status TEXT DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP DEFAULT NULL,
|
||||
marked_datetime TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
marked_physical_count TEXT DEFAULT '0',
|
||||
marked_expected_time TEXT DEFAULT '0',
|
||||
marked_by TEXT DEFAULT NULL,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE process_orders
|
||||
ADD COLUMN updated_order_quantity NUMERIC(10,3) NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('process_orders', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
@@ -136,9 +136,13 @@ Route::post('serial-invoice/store-data', [InvoiceValidationController::class, 's
|
||||
|
||||
Route::post('material-invoice/store-data', [InvoiceValidationController::class, 'materialInvoice']);
|
||||
|
||||
// User Controller
|
||||
|
||||
Route::get('user/get-data', [UserController::class, 'get_user_data']);
|
||||
|
||||
// Testing panel Controller
|
||||
|
||||
Route::get('testing/user/get-data', [UserController::class, 'get_testing_data']);
|
||||
Route::get('testing/user/get-data', [UserController::class, 'get_user_data']);
|
||||
|
||||
Route::get('testing/item/get-master-data', [TestingPanelController::class, 'get_motor_master']);
|
||||
|
||||
@@ -170,7 +174,7 @@ Route::get('laser/characteristics/check', [CharacteristicsController::class, 'ch
|
||||
|
||||
Route::post('laser/characteristics/data', [CharacteristicsController::class, 'storeClassChar']);
|
||||
|
||||
// ..serial (auto or manual)
|
||||
// ..Marked serial (auto or manual)
|
||||
|
||||
Route::post('laser/characteristics/status', [CharacteristicsController::class, 'storeLaserStatus']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user