correction of alert mail rule logic for invoice data report
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 11s
Gemini PR Review / review (pull_request) Failing after 51s
Laravel Larastan / larastan (pull_request) Failing after 3m1s
Laravel Pint / pint (pull_request) Successful in 2m47s
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 11s
Gemini PR Review / review (pull_request) Failing after 51s
Laravel Larastan / larastan (pull_request) Failing after 3m1s
Laravel Pint / pint (pull_request) Successful in 2m47s
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Mail\test;
|
||||
use App\Models\InvoiceValidation;
|
||||
use App\Models\Plant;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\test;
|
||||
|
||||
class SendInvoiceReport extends Command
|
||||
{
|
||||
@@ -15,9 +15,8 @@ class SendInvoiceReport extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report{schedule_type} {plant}';
|
||||
|
||||
// protected $signature = 'app:send-invoice-report';
|
||||
protected $signature = 'send:invoice-report {schedule_type} {plant}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -29,12 +28,10 @@ class SendInvoiceReport extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$schedule = $this->argument('schedule_type');
|
||||
//$scheduleType = $this->argument('scheduleType');
|
||||
// $scheduleType = $this->argument('scheduleType');
|
||||
$plantIdArg = (int) $this->argument('plant'); // can be 0 for all plants
|
||||
|
||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceValidation')->get()->groupBy('rule_name');
|
||||
@@ -52,18 +49,14 @@ class SendInvoiceReport extends Command
|
||||
: [$plantIdArg];
|
||||
|
||||
$no = 1;
|
||||
if (strtolower($schedule) == 'daily')
|
||||
{
|
||||
if (strtolower($schedule) == 'daily') {
|
||||
$startDate = now()->subDay()->setTime(8, 0, 0);
|
||||
$endDate = now()->setTime(8, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$startDate = now()->setTime(8, 0, 0);
|
||||
$endDate = now()->copy()->addDay()->setTime(8, 0, 0);
|
||||
}
|
||||
foreach ($plantIds as $plantId)
|
||||
{
|
||||
foreach ($plantIds as $plantId) {
|
||||
$plant = Plant::find($plantId);
|
||||
$plantName = $plant ? $plant->name : $plantId;
|
||||
|
||||
@@ -89,7 +82,7 @@ class SendInvoiceReport extends Command
|
||||
|
||||
$scannedInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('scanned_status', 'Scanned')
|
||||
->where(function($query) {
|
||||
->where(function ($query) {
|
||||
$query->whereNull('quantity')
|
||||
->orWhere('quantity', 0);
|
||||
})
|
||||
@@ -128,7 +121,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedMatInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
@@ -164,7 +157,7 @@ class SendInvoiceReport extends Command
|
||||
$scannedBundleInvoiceQuan = InvoiceValidation::where('plant_id', $plantId)
|
||||
->where('quantity', '>', 1)
|
||||
->whereNotNull('serial_number')
|
||||
->where('serial_number','!=', '')
|
||||
->where('serial_number', '!=', '')
|
||||
->whereBetween('updated_at', [$startDate, $endDate])
|
||||
->count();
|
||||
|
||||
@@ -193,7 +186,6 @@ class SendInvoiceReport extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send to MaterialInvoiceMail recipients (material + bundle table)
|
||||
if ($mailRules->has('MaterialInvoiceMail')) {
|
||||
$emails = $mailRules['MaterialInvoiceMail']->pluck('email')->unique()->toArray();
|
||||
@@ -212,16 +204,14 @@ class SendInvoiceReport extends Command
|
||||
|
||||
// Show preview in console
|
||||
$this->info('--- Serial Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $serialTableData);
|
||||
|
||||
$this->info('--- Material Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $materialTableData);
|
||||
|
||||
$this->info('--- Bundle Invoice Table ---');
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice','TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
$this->table(['#', 'Plant', 'Total Invoice', 'Scanned Invoice', 'TotalInvoice Quantity', 'ScannedInvoice Quantity'], $bundleTableData);
|
||||
|
||||
$this->info($contentVars['wishes'] ?? '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user