Added updated logic in panel box validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 24s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 34s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 21s
Laravel Pint / pint (pull_request) Successful in 1m50s
Laravel Larastan / larastan (pull_request) Failing after 3m12s

This commit is contained in:
dhanabalan
2026-07-08 09:55:07 +05:30
parent d213049fdd
commit f0af6853ee

View File

@@ -151,19 +151,38 @@ public $records = [];
$characteristic = ProductCharacteristicsMaster::find($characteristicId); $characteristic = ProductCharacteristicsMaster::find($characteristicId);
if (($characteristic?->inspection_type ?? null) === 'Value') { $itemCharacteristic = ProductCharacteristicsMaster::where('plant_id', $this->data['plant_id'])
if ($characteristic && is_numeric($value) && (($value >= $characteristic->lower && $value <= $characteristic->upper) || $value == $characteristic->lower || $value == $characteristic->upper) ->where('line_id', $this->data['line_id'])
->where('name', $characteristic->name)
->where('item_id', $itemId)
->first();
// if (($characteristic?->inspection_type ?? null) === 'Value') {
// if ($characteristic && is_numeric($value) && (($value >= $characteristic->lower && $value <= $characteristic->upper) || $value == $characteristic->lower || $value == $characteristic->upper)
// ) {
// $status = 'Ok';
// } else {
// $status = 'NotOk';
// }
// }
// else {
// $status = $value;
// }
if (($itemCharacteristic?->inspection_type ?? null) === 'Value') {
if ($itemCharacteristic && is_numeric($value) && $value >= $itemCharacteristic->lower && $value <= $itemCharacteristic->upper
) { ) {
$status = 'Ok'; $status = 'Ok';
} else { } else {
$status = 'NotOk'; $status = 'NotOk';
} }
} }
// else { else {
// $status = $value; $status = $value;
// } }
ProductionCharacteristic::create([ $prod = ProductionCharacteristic::create([
'plant_id' => $this->data['plant_id'] ?? null, 'plant_id' => $this->data['plant_id'] ?? null,
'item_id' => $itemId ?? null, 'item_id' => $itemId ?? null,
'line_id' => $this->data['line_id'] ?? null, 'line_id' => $this->data['line_id'] ?? null,
@@ -178,6 +197,15 @@ public $records = [];
]); ]);
} }
if (! $prod) {
Notification::make()
->title('Failed to save Panel Box Validation')
->body('Something went wrong while inserting data.')
->danger()
->send();
return;
}
$this->showChecklist = false; $this->showChecklist = false;
$this->dispatch('checklist-saved'); $this->dispatch('checklist-saved');
@@ -214,11 +242,24 @@ public $records = [];
$characteristic = ProductCharacteristicsMaster::find($characteristicId); $characteristic = ProductCharacteristicsMaster::find($characteristicId);
$itemCode = $this->data['item_id'];
$itemId = Item::where('plant_id', $characteristic->plant_id)->where('code', $itemCode)->value('id');
$characteristic = ProductCharacteristicsMaster::find($characteristicId);
$limit = ProductCharacteristicsMaster::where('plant_id', $characteristic->plant_id)
->where('line_id', $characteristic->line_id)
->where('name', $characteristic->name)
->where('item_id', $itemId)
->first();
if (! $characteristic || ! is_numeric($value)) { if (! $characteristic || ! is_numeric($value)) {
return 'Not Ok'; return 'Not Ok';
} }
// return ($value >= $characteristic->lower && $value <= $characteristic->upper) ? 'Ok' : 'Not Ok';
return ($value >= $characteristic->lower && $value <= $characteristic->upper) ? 'Ok' : 'Not Ok'; return ($value >= $limit->lower && $value <= $limit->upper) ? 'Ok' : 'Not Ok';
} }