From 5a654d1d40b1d7990f2019d2862f341f30521d20 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 8 Jul 2025 17:47:32 +0530 Subject: [PATCH] Added custom logic in for mail report --- routes/console.php | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/routes/console.php b/routes/console.php index e802730..d221072 100644 --- a/routes/console.php +++ b/routes/console.php @@ -11,3 +11,62 @@ Artisan::command('inspire', function () { // Schedule::command('send:invoice-report'); // Schedule::command('send:production-report'); +$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()->runInBackground(); + break; + case 'Hourly': + Schedule::command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground(); + break; + case 'Daily': + Schedule::command("send:invoice-report {$rule['argument']}")->dailyAt('07:59')->runInBackground(); + break; + default: + Schedule::command("send:invoice-report {$rule['argument']}")->hourly()->runInBackground(); + 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()->runInBackground(); + break; + case 'Hourly': + Schedule::command('send:production-report')->hourly()->runInBackground(); + break; + case 'Daily': + Schedule::command('send:production-report')->dailyAt('07:59')->runInBackground(); + break; + default: + Schedule::command('send:production-report')->hourly()->runInBackground(); + break; +} +