Added logic if data not exist on the day mail wont trigger for invoice in transit
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 2m28s
Laravel Larastan / larastan (pull_request) Failing after 3m33s

This commit is contained in:
dhanabalan
2026-03-07 11:14:50 +05:30
parent ec0a53e308
commit 37d42a34de

View File

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
use App\Mail\InvoiceTransitMail; use App\Mail\InvoiceTransitMail;
use App\Models\AlertMailRule; use App\Models\AlertMailRule;
use App\Models\InvoiceInTransit;
use App\Models\InvoiceMaster; use App\Models\InvoiceMaster;
use App\Models\Plant; use App\Models\Plant;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@@ -52,6 +53,13 @@ class SendInvoiceTransitReport extends Command
return; return;
} }
$todayRecordExists = InvoiceInTransit::whereDate('created_at', now()->toDateString())->first();
if (!$todayRecordExists) {
$this->info('No records created today. Mail not sent.');
return;
}
if (strtolower($scheduleType) == 'daily') { if (strtolower($scheduleType) == 'daily') {
$results = DB::table('invoice_in_transits as it') $results = DB::table('invoice_in_transits as it')
->join('invoice_masters as im', function ($join) { ->join('invoice_masters as im', function ($join) {