Merge pull request 'ranjith-dev' (#361) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #361
This commit was merged in pull request #361.
This commit is contained in:
@@ -40,10 +40,10 @@ class CharacteristicValueExporter extends Exporter
|
||||
->label('OBSERVED VALUE'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
|
||||
@@ -46,10 +46,10 @@ class ProcessOrderExporter extends Exporter
|
||||
->label('REWORK STATUS'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('deleted_at')
|
||||
|
||||
@@ -112,22 +112,30 @@ class CharacteristicValueImporter extends Importer
|
||||
$iCode = trim($this->data['item']);
|
||||
$workCenter = trim($this->data['machine']);
|
||||
$lineName = trim($this->data['line']);
|
||||
$status = trim($this->data['status']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
$coilNo = trim($this->data['coil_number']);
|
||||
$obserVal = trim($this->data['observed_value']);
|
||||
$status = trim($this->data['status']);
|
||||
$createdBy = trim($this->data['created_by']);
|
||||
|
||||
if ($plantCode == null || $plantCode == '') {
|
||||
$warnMsg[] = 'Plant code cannot be empty';
|
||||
} elseif ($iCode == null || $iCode == '') {
|
||||
} elseif ($iCode == null || $iCode == '') {// process_order
|
||||
$warnMsg[] = 'Item code cannot be empty';
|
||||
} elseif ($processOrder == null || $processOrder == '') {//
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
} elseif ($workCenter == null || $workCenter == '') {
|
||||
$warnMsg[] = 'Work center cannot be empty';
|
||||
} elseif ($lineName == null || $lineName == '') {
|
||||
$warnMsg[] = 'Line cannot be empty';
|
||||
$warnMsg[] = 'Line name cannot be empty';
|
||||
} elseif ($coilNo == null || $coilNo == '') {
|
||||
$warnMsg[] = 'Coil number cannot be empty';
|
||||
} elseif ($obserVal == null || $obserVal == '') {
|
||||
$warnMsg[] = 'Observed value cannot be empty';
|
||||
} elseif ($status == null || $status == '') {
|
||||
$warnMsg[] = 'Status cannot be empty';
|
||||
}
|
||||
|
||||
if (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode)) {
|
||||
if (Str::length($plantCode) > 0 && (Str::length($plantCode) < 4 || ! is_numeric($plantCode) || ! preg_match('/^[1-9]\d{3,}$/', $plantCode))) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCode)->first();
|
||||
@@ -138,7 +146,7 @@ class CharacteristicValueImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
|
||||
if (Str::length($iCode) > 0 && (Str::length($iCode) < 6 || ! ctype_alnum($iCode))) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
@@ -198,25 +206,15 @@ class CharacteristicValueImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
}
|
||||
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$warnMsg[] = 'Coil No cannot be empty';
|
||||
} elseif (! is_numeric($coilNo)) {
|
||||
if (Str::length($coilNo) > 0 && ! is_numeric($coilNo)) {
|
||||
$warnMsg[] = 'Coil number should contain only numeric values!';
|
||||
}
|
||||
|
||||
if ($obserVal == null || $obserVal == '') {
|
||||
$warnMsg[] = 'Observed value cannot be empty';
|
||||
} elseif (! is_numeric($obserVal)) {
|
||||
if (Str::length($obserVal) > 0 && ! is_numeric($obserVal)) {
|
||||
$warnMsg[] = 'Observed value should contain only numeric values!';
|
||||
}
|
||||
|
||||
if ($status == null || $status == '' || ! $status) {
|
||||
$warnMsg[] = 'Status cannot be empty';
|
||||
} elseif (! in_array($status, ['Ok', 'NotOk'], true)) {
|
||||
if (Str::length($status) > 0 && ! in_array($status, ['Ok', 'NotOk'], true)) {
|
||||
$warnMsg[] = "Status must be either 'Ok' or 'NotOk'!";
|
||||
}
|
||||
// else {
|
||||
@@ -255,7 +253,7 @@ class CharacteristicValueImporter extends Importer
|
||||
$warnMsg[] = 'Created By cannot be empty';
|
||||
}
|
||||
|
||||
if ($plantId != null) {
|
||||
if ($plantId) {
|
||||
$user = User::where('name', $createdBy)->first();
|
||||
|
||||
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
|
||||
@@ -280,7 +278,7 @@ class CharacteristicValueImporter extends Importer
|
||||
}
|
||||
}
|
||||
|
||||
if ($plant && $itemCode && $processOrder != '') {
|
||||
if ($plant && $itemCode && $processOrder != '' && $processOrder != null) {
|
||||
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
|
||||
@@ -29,7 +29,6 @@ class ProcessOrderImporter extends Importer
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('LINE NAME')
|
||||
->example(' Polywrapped line')
|
||||
->label('LINE NAME')
|
||||
@@ -42,6 +41,7 @@ class ProcessOrderImporter extends Importer
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('process_order')
|
||||
->requiredMapping()
|
||||
->exampleHeader('PROCESS ORDER')
|
||||
->example('202500123456')
|
||||
->label('PROCESS ORDER')
|
||||
@@ -49,9 +49,9 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('coil_number')
|
||||
->exampleHeader('COIL NUMBER')
|
||||
->example('01')
|
||||
->label('COIL NUMBER')
|
||||
->rules(['required']),
|
||||
->label('COIL NUMBER'),
|
||||
ImportColumn::make('order_quantity')
|
||||
->requiredMapping()
|
||||
->exampleHeader('ORDER QUANTITY')
|
||||
->example('100')
|
||||
->label('ORDER QUANTITY')
|
||||
@@ -59,8 +59,7 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('received_quantity')
|
||||
->exampleHeader('RECEIVED QUANTITY')
|
||||
->example('01')
|
||||
->label('RECEIVED QUANTITY')
|
||||
->rules(['required']),
|
||||
->label('RECEIVED QUANTITY'),
|
||||
ImportColumn::make('sfg_number')
|
||||
->exampleHeader('SFG NUMBER')
|
||||
->example('200000220613-72')
|
||||
@@ -80,8 +79,7 @@ class ProcessOrderImporter extends Importer
|
||||
ImportColumn::make('created_at')
|
||||
->exampleHeader('CREATED AT')
|
||||
->example('2026-02-20 13:00:00')
|
||||
->label('CREATED AT')
|
||||
->rules(['required']),
|
||||
->label('CREATED AT'),
|
||||
ImportColumn::make('updated_at')
|
||||
->exampleHeader('UPDATED AT')
|
||||
->example('2026-02-20 13:00:00')
|
||||
@@ -102,16 +100,18 @@ class ProcessOrderImporter extends Importer
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
$iCode = trim($this->data['item']);
|
||||
$lineName = trim($this->data['line']);
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$coilNo = trim($this->data['coil_number'] ?? '');
|
||||
$sfgNo = trim($this->data['sfg_number'] ?? '');
|
||||
$machineName = trim($this->data['machine_name'] ?? '');
|
||||
$orderQuan = trim($this->data['order_quantity'] ?? '');
|
||||
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
|
||||
$reworkStatus = trim($this->data['rework_status'] ?? '');
|
||||
$orderQuan = trim($this->data['order_quantity'] ?? '');
|
||||
$recQuan = trim($this->data['received_quantity'] ?? '');
|
||||
$processOrder = trim($this->data['process_order'] ?? '');
|
||||
$createdAt = trim($this->data['created_at'] ?? '');
|
||||
$createdBy = trim($this->data['created_by'] ?? '');
|
||||
$updatedAt = trim($this->data['updated_at'] ?? '');
|
||||
@@ -119,12 +119,41 @@ class ProcessOrderImporter extends Importer
|
||||
// $user = Filament::auth()->user();
|
||||
// $operatorName = $user->name;
|
||||
|
||||
if ($plantCod == null || $plantCod == '') {
|
||||
$warnMsg[] = 'Plant code cannot be empty';
|
||||
}
|
||||
if ($iCode == null || $iCode == '') {
|
||||
$warnMsg[] = 'Item code cannot be empty';
|
||||
}
|
||||
if ($processOrder == null || $processOrder == '') {
|
||||
$warnMsg[] = 'Process order cannot be empty';
|
||||
}
|
||||
if ($orderQuan == null || $orderQuan == '') {
|
||||
$warnMsg[] = 'Order quantity cannot be empty';
|
||||
} elseif ($orderQuan == 0 || $orderQuan == '0') {
|
||||
$warnMsg[] = 'Order quantity cannot be zero';
|
||||
}
|
||||
if ($coilNo == null || $coilNo == '') {
|
||||
$coilNo = '0';
|
||||
}
|
||||
if ($scrapQuan == null || $scrapQuan == '') {
|
||||
$scrapQuan = 0;
|
||||
}
|
||||
if ($recQuan == null || $recQuan == '') {
|
||||
$recQuan = 0;
|
||||
}
|
||||
if ($reworkStatus == null || $reworkStatus = '') {
|
||||
$reworkStatus = 0;
|
||||
}
|
||||
|
||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = 'Invalid plant code found';
|
||||
} else {
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,27 +162,46 @@ class ProcessOrderImporter extends Importer
|
||||
} else {
|
||||
$itemCode = Item::where('code', $iCode)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item Code not found';
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
|
||||
if (! $itemCode) {
|
||||
$warnMsg[] = 'Item code not found for the given plant';
|
||||
} else {
|
||||
$itemId = $itemCode->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($processOrder == '') {
|
||||
$warnMsg[] = 'Process Order cannot be empty';
|
||||
}
|
||||
if ($plant && $itemCode && $processOrder != '') {
|
||||
|
||||
if($lineName != null && $lineName != ''){
|
||||
$lineAgaPlant = Line::where('plant_id', $plant->id)->where('name', $lineName)->first();
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if(! $lineAgaPlant){
|
||||
$warnMsg[] = "Line not found against plant code $plantCod";
|
||||
}
|
||||
else{
|
||||
$lineId = $lineAgaPlant->id;
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
}
|
||||
}
|
||||
|
||||
if($scrapQuan == null || $scrapQuan == ''){
|
||||
$scrapQuan = 0;
|
||||
if ($lineName != null && $lineName != '') {
|
||||
$lineExists = Line::where('name', $lineName)->first();
|
||||
if (! $lineExists) {
|
||||
$warnMsg[] = 'Line name not found';
|
||||
} else {
|
||||
if ($plantId) {
|
||||
$lineAgainstPlant = Line::where('name', $lineName)->where('plant_id', $plantId)->first();
|
||||
if (! $lineAgainstPlant) {
|
||||
$warnMsg[] = 'Line name not found for the given plant';
|
||||
} else {
|
||||
$lineId = $lineAgainstPlant->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$lineId = null;
|
||||
}
|
||||
|
||||
// $user = User::where('name', $this->data['created_by'])->first();
|
||||
@@ -161,43 +209,28 @@ class ProcessOrderImporter extends Importer
|
||||
// $warnMsg[] = 'User not found';
|
||||
// }
|
||||
|
||||
if ($plant && $itemCode && $processOrder != '') {
|
||||
|
||||
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
|
||||
->where('process_order', $processOrder)
|
||||
->first();
|
||||
|
||||
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
|
||||
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($warnMsg)) {
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
}
|
||||
|
||||
$lineId = null;
|
||||
|
||||
if($lineName != null && $lineName != ''){
|
||||
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plant->id)
|
||||
if ($lineName != null && $lineName != '') {
|
||||
$existingCoil = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if (! $existingCoil)
|
||||
{
|
||||
if (! $existingCoil) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemCode->id,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineName,
|
||||
'rework_status' => $reworkStatus,
|
||||
@@ -207,17 +240,15 @@ class ProcessOrderImporter extends Importer
|
||||
'updated_by' => $updatedBy,
|
||||
]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessOrder::where('plant_id', $plant->id)
|
||||
} else {
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => $reworkStatus,
|
||||
@@ -226,24 +257,23 @@ class ProcessOrderImporter extends Importer
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
else if($lineName == null || $lineName == ''){
|
||||
$existing = ProcessOrder::where('plant_id', $plant->id)
|
||||
} elseif ($lineName == null || $lineName == '') {
|
||||
$existing = ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('coil_number', $coilNo)
|
||||
->first();
|
||||
|
||||
if(!$existing){
|
||||
if (! $existing) {
|
||||
ProcessOrder::Create(
|
||||
[
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => null,
|
||||
'plant_id' => $plantId,
|
||||
'line_id' => $lineId,
|
||||
'process_order' => $processOrder,
|
||||
'item_id' => $itemCode->id,
|
||||
'item_id' => $itemId,
|
||||
'coil_number' => $coilNo,
|
||||
'order_quantity' => $orderQuan,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan ?? 0,
|
||||
'scrap_quantity' => $scrapQuan ?? 0,
|
||||
'sfg_number' => $sfgNo,
|
||||
'machine_name' => $machineName,
|
||||
'rework_status' => $reworkStatus,
|
||||
@@ -253,17 +283,26 @@ class ProcessOrderImporter extends Importer
|
||||
'updated_by' => $updatedBy,
|
||||
]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessOrder::where('plant_id', $plant->id)
|
||||
} elseif ($coilNo == '0' || $coilNo == 0) {
|
||||
ProcessOrder::create([
|
||||
'plant_id' => $plantId,
|
||||
'item_id' => $itemId,
|
||||
'process_order' => $processOrder,
|
||||
'coil_number' => '0',
|
||||
'order_quantity' => $orderQuan,
|
||||
'received_quantity' => 0,
|
||||
'scrap_quantity' => 0,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
} else {// $coilNo = '0'
|
||||
ProcessOrder::where('plant_id', $plantId)
|
||||
->where('process_order', $processOrder)
|
||||
->where('line_id', $lineId)
|
||||
->where('coil_number', $coilNo)
|
||||
->update([
|
||||
// 'order_quantity' => $orderQty,
|
||||
'received_quantity' => $recQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
'scrap_quantity' => $scrapQuan,
|
||||
// 'sfg_number' => $sfgNo,
|
||||
// 'machine_name' => $machineId,
|
||||
'rework_status' => $reworkStatus,
|
||||
|
||||
Reference in New Issue
Block a user