Changed logic for sending invoice report mail for aginst based on plants
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-11 14:55:40 +05:30
parent 25cfaa6479
commit 3a7104513c

View File

@@ -91,6 +91,7 @@ class SendInvoiceReport extends Command
$serialTableData[] = [ $serialTableData[] = [
'no' => $no, 'no' => $no,
'plant_id' => $plantId,
'plant' => $plantName, 'plant' => $plantName,
'totalInvoice' => $totalSerialCount, 'totalInvoice' => $totalSerialCount,
'scannedInvoice' => $scannedSerialCount, 'scannedInvoice' => $scannedSerialCount,
@@ -127,6 +128,7 @@ class SendInvoiceReport extends Command
$materialTableData[] = [ $materialTableData[] = [
'no' => $no, 'no' => $no,
'plant_id' => $plantId,
'plant' => $plantName, 'plant' => $plantName,
'totalInvoice' => $totalMatCount, 'totalInvoice' => $totalMatCount,
'scannedInvoice' => $scannedMatCount, 'scannedInvoice' => $scannedMatCount,
@@ -163,6 +165,7 @@ class SendInvoiceReport extends Command
$bundleTableData[] = [ $bundleTableData[] = [
'no' => $no, 'no' => $no,
'plant_id' => $plantId,
'plant' => $plantName, 'plant' => $plantName,
'totalInvoice' => $totalBundleCount, 'totalInvoice' => $totalBundleCount,
'scannedInvoice' => $scannedBundleCount, 'scannedInvoice' => $scannedBundleCount,
@@ -206,7 +209,26 @@ class SendInvoiceReport extends Command
continue; continue;
} }
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule)); if ($rule->plant == 0) {
$filteredSerialData = $serialTableData;
} else {
$filteredSerialData = collect($serialTableData)
->where('plant_id', $rule->plant)
->values()
->toArray();
}
\Mail::to($toEmails)
->cc($ccEmails)
->send(new test(
$filteredSerialData,
[],
[],
$schedule
));
// \Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, [], [], $schedule));
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : '')); $this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
} }
@@ -240,7 +262,35 @@ class SendInvoiceReport extends Command
continue; continue;
} }
\Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule)); // FILTER DATA
if ($rule->plant == 0) {
$filteredMaterialData = $materialTableData;
$filteredBundleData = $bundleTableData;
} else {
$filteredMaterialData = collect($materialTableData)
->where('plant_id', $rule->plant)
->values()
->toArray();
$filteredBundleData = collect($bundleTableData)
->where('plant_id', $rule->plant)
->values()
->toArray();
}
\Mail::to($toEmails)
->cc($ccEmails)
->send(new test(
[],
$filteredMaterialData,
$filteredBundleData,
$schedule
));
// \Mail::to($toEmails)->cc($ccEmails)->send(new test([], $materialTableData, $bundleTableData, $schedule));
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : '')); $this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
} }
@@ -275,7 +325,41 @@ class SendInvoiceReport extends Command
continue; continue;
} }
\Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule)); // FILTER DATA
if ($rule->plant == 0) {
$filteredSerialData = $serialTableData;
$filteredMaterialData = $materialTableData;
$filteredBundleData = $bundleTableData;
} else {
$filteredSerialData = collect($serialTableData)
->where('plant_id', $rule->plant)
->values()
->toArray();
$filteredMaterialData = collect($materialTableData)
->where('plant_id', $rule->plant)
->values()
->toArray();
$filteredBundleData = collect($bundleTableData)
->where('plant_id', $rule->plant)
->values()
->toArray();
}
\Mail::to($toEmails)
->cc($ccEmails)
->send(new test(
$filteredSerialData,
$filteredMaterialData,
$filteredBundleData,
$schedule
));
// \Mail::to($toEmails)->cc($ccEmails)->send(new test($serialTableData, $materialTableData, $bundleTableData, $schedule));
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : '')); $this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
} }