Added logic for checking wthehere same customer name or not
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled

This commit is contained in:
dhanabalan
2026-05-29 15:47:33 +05:30
parent 8c362bd83f
commit 280b62d27d

View File

@@ -17,6 +17,8 @@ class CustomerPoMasterImporter extends Importer
{ {
protected static ?string $model = CustomerPoMaster::class; protected static ?string $model = CustomerPoMaster::class;
protected array $importedPos = [];
public static function getColumns(): array public static function getColumns(): array
{ {
return [ return [
@@ -67,6 +69,8 @@ class CustomerPoMasterImporter extends Importer
$plantCod = $this->data['plant']; $plantCod = $this->data['plant'];
$plant = null; $plant = null;
$item = null; $item = null;
$customerPo = trim($this->data['customer_po']);
$customerName = trim($this->data['customer_name']);
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) { if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = 'Invalid plant code found'; $warnMsg[] = 'Invalid plant code found';
@@ -90,6 +94,23 @@ class CustomerPoMasterImporter extends Importer
$warnMsg[] = 'Customer PO cannot be empty.'; $warnMsg[] = 'Customer PO cannot be empty.';
} }
if (isset($this->importedPos[$customerPo])) {
if (strtolower(trim($this->importedPos[$customerPo])) != strtolower($customerName)){
$warnMsg[] = "Customer PO '{$customerPo}' has multiple customer names in the import file.";
}
}
else {
$this->importedPos[$customerPo] = $customerName;
}
$existingPo = CustomerPoMaster::where('plant_id', $plant->id)->where('customer_po', $this->data['customer_po'])->first();
if ($existingPo && trim(strtolower($existingPo->customer_name)) != trim(strtolower($this->data['customer_name'])))
{
$warnMsg[] = "Customer PO '{$this->data['customer_po']}' is already mapped to customer '{$existingPo->customer_name}'.";
}
// $user = User::where('name', $this->data['created_by'])->first(); // $user = User::where('name', $this->data['created_by'])->first();
// if (! $user) { // if (! $user) {
// $warnMsg[] = 'User not found'; // $warnMsg[] = 'User not found';