Added logic for production mail report

This commit is contained in:
dhanabalan
2025-07-09 10:04:54 +05:30
parent 5ab109006e
commit 29de91e03d
2 changed files with 266 additions and 120 deletions

View File

@@ -74,68 +74,75 @@ Artisan::command('inspire', function () {
// break;
// }
// app()->booted(function () {
// $schedule = app(Schedule::class);
// // Dynamic rules for invoice reports
// $rules = [
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'InvoiceMail',
// 'argument' => 'InvoiceMail',
// ],
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'SerialInvoiceMail',
// 'argument' => 'SerialInvoiceMail',
// ],
// [
// 'module' => 'InvoiceValidation',
// 'rule_name' => 'MaterialInvoiceMail',
// 'argument' => 'MaterialInvoiceMail',
// ],
// ];
// foreach ($rules as $rule) {
// $scheduleType = AlertMailRule::where('module', $rule['module'])
// ->where('rule_name', $rule['rule_name'])
// ->value('schedule_type');
// switch ($scheduleType) {
// case 'Live':
// $schedule->command("send:invoice-report {$rule['argument']}")->everyMinute();
// break;
// case 'Hourly':
// $schedule->command("send:invoice-report {$rule['argument']}")->hourly();
// break;
// case 'Daily':
// $schedule->command("send:invoice-report {$rule['argument']}")->dailyAt('07:59');
// break;
// default:
// $schedule->command("send:invoice-report {$rule['argument']}")->hourly();
// break;
// }
// }
// // Production Report Scheduling
// $productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
// ->where('rule_name', 'ProductionMail')
// ->value('schedule_type');
// switch ($productionScheduleType) {
// case 'Live':
// $schedule->command('send:production-report')->everyMinute();
// break;
// case 'Hourly':
// $schedule->command('send:production-report')->hourly();
// break;
// case 'Daily':
// $schedule->command('send:production-report')->dailyAt('07:59');
// break;
// default:
// $schedule->command('send:production-report')->hourly();
// break;
// }
// });
app()->booted(function () {
$schedule = app(Schedule::class);
// Dynamic rules for invoice reports
$rules = [
[
'module' => 'InvoiceValidation',
'rule_name' => 'InvoiceMail',
'argument' => 'InvoiceMail',
],
[
'module' => 'InvoiceValidation',
'rule_name' => 'SerialInvoiceMail',
'argument' => 'SerialInvoiceMail',
],
[
'module' => 'InvoiceValidation',
'rule_name' => 'MaterialInvoiceMail',
'argument' => 'MaterialInvoiceMail',
],
];
foreach ($rules as $rule) {
$scheduleType = AlertMailRule::where('module', $rule['module'])
->where('rule_name', $rule['rule_name'])
->value('schedule_type');
switch ($scheduleType) {
case 'Live':
$schedule->command("send:invoice-report {$rule['argument']}")->everyMinute();
break;
case 'Hourly':
$schedule->command("send:invoice-report {$rule['argument']}")->hourly();
break;
case 'Daily':
$schedule->command("send:invoice-report {$rule['argument']}")->dailyAt('07:59');
break;
default:
$schedule->command("send:invoice-report {$rule['argument']}")->hourly();
break;
}
}
// Production Report Scheduling
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->value('schedule_type');
switch ($productionScheduleType) {
case 'Live':
$schedule->command('send:production-report')->everyMinute();
break;
case 'Hourly':
$schedule->command('send:production-report')->hourly();
break;
case 'Daily':
$schedule->command('send:production-report')->dailyAt('07:59');
break;
default:
$schedule->command('send:production-report')->hourly();
break;
}
//Always run every minute — the command itself will filter recipients
$schedule->command('send:production-report')->everyMinute();
});