Updated validation logic against machin name on resource and import page
Some checks are pending
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Some checks are pending
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
This commit is contained in:
@@ -132,7 +132,10 @@ 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!";
|
||||
@@ -169,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)) {
|
||||
@@ -233,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!';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +265,7 @@ class ProcessOrderImporter extends Importer
|
||||
->where('process_order', $processOrder)
|
||||
->sum('received_quantity');
|
||||
|
||||
if($existing){
|
||||
if ($existing) {
|
||||
$liveOrdQuan = (float) $existing->order_quantity;
|
||||
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
|
||||
|
||||
@@ -273,16 +276,15 @@ class ProcessOrderImporter extends Importer
|
||||
|
||||
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}"
|
||||
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
|
||||
);
|
||||
}
|
||||
else if ($liveUpdatedOrdQuan < $minAllowedQty) {
|
||||
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}"
|
||||
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
|
||||
);
|
||||
}else if($liveUpdatedOrdQuan < $receivedQty) {
|
||||
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
|
||||
throw new RowImportFailedException(
|
||||
"Updated order quantity cannot decrease below its received quantity {$receivedQty}"
|
||||
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -299,10 +301,9 @@ class ProcessOrderImporter extends Importer
|
||||
// ->where('line_id', $lineId)
|
||||
// ->first();
|
||||
|
||||
if($existing){
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
@@ -350,10 +351,9 @@ class ProcessOrderImporter extends Importer
|
||||
// // ->where('coil_number', $coilNo)
|
||||
// ->first();
|
||||
|
||||
if($existing){
|
||||
if ($existing) {
|
||||
$existUpdateOrdQuan = $existing->updated_order_quantity;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$existUpdateOrdQuan = $updatedOrderQuan;
|
||||
}
|
||||
|
||||
|
||||
@@ -410,13 +410,13 @@ class ProcessOrderResource extends Resource
|
||||
$orderQty = (float) $get('order_quantity');
|
||||
$updatedQty = (float) $value;
|
||||
|
||||
$allowedVariance = $orderQty * 0.10;
|
||||
$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.");
|
||||
$fail('Quantity can vary by ±10% of the order quantity.');
|
||||
}
|
||||
|
||||
$otherReceivedQty = ProcessOrder::where('plant_id', $plantId)
|
||||
@@ -631,6 +631,7 @@ class ProcessOrderResource extends Resource
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->reactive()
|
||||
->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);
|
||||
|
||||
Reference in New Issue
Block a user