Added validation logic in process order importer

This commit is contained in:
dhanabalan
2025-11-22 12:02:24 +05:30
parent 8596c9109f
commit 3958a73a2c

View File

@@ -74,6 +74,17 @@ class ProcessOrderImporter extends Importer
$warnMsg[] = "User not found"; $warnMsg[] = "User not found";
} }
if ($plant && $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)) { if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg)); throw new RowImportFailedException(implode(', ', $warnMsg));
} }