removed unwanted commented lines in send invoice data report
This commit is contained in:
@@ -33,43 +33,15 @@ class SendInvoiceDataReport extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$scheduleType = $this->argument('schedule_type');
|
$scheduleType = $this->argument('schedule_type');
|
||||||
$plantId = (int) $this->argument('plant'); // cast to int for safety
|
$plantId = (int) $this->argument('plant');
|
||||||
|
|
||||||
|
|
||||||
// // Fetch mail rules based on schedule type
|
|
||||||
// $mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceDataReport')
|
|
||||||
// ->where('rule_name', 'InvoiceDataMail')
|
|
||||||
// ->where('schedule_type', $scheduleType)
|
|
||||||
// ->where('plant', $plantId)
|
|
||||||
// ->get();
|
|
||||||
|
|
||||||
// $emails = $mailRules->pluck('email')->unique()->toArray();
|
|
||||||
|
|
||||||
// $ccEmails = $mailRules->pluck('cc_emails')->filter()->unique()->toArray();
|
|
||||||
|
|
||||||
// $this->info('Found emails: ' . implode(', ', $ccEmails));
|
|
||||||
|
|
||||||
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceDataReport')
|
$mailRules = \App\Models\AlertMailRule::where('module', 'InvoiceDataReport')
|
||||||
->where('rule_name', 'InvoiceDataMail')
|
->where('rule_name', 'InvoiceDataMail')
|
||||||
->where('schedule_type', $scheduleType)
|
->where('schedule_type', $scheduleType)
|
||||||
->where('plant', $plantId)
|
->where('plant', $plantId)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
// $toEmails = $mailRules->pluck('email')
|
|
||||||
// ->flatMap(function ($emails) {
|
|
||||||
// return array_map('trim', explode(',', $emails));
|
|
||||||
// })
|
|
||||||
// ->filter()
|
|
||||||
// ->toArray();
|
|
||||||
|
|
||||||
// $ccEmails = $mailRules->pluck('cc_emails')
|
|
||||||
// ->filter() // remove null or empty
|
|
||||||
// ->flatMap(function ($emails) {
|
|
||||||
// return array_map('trim', explode(',', $emails));
|
|
||||||
// })
|
|
||||||
// ->filter()
|
|
||||||
// ->toArray();
|
|
||||||
|
|
||||||
$plants = $plantId == 0
|
$plants = $plantId == 0
|
||||||
? Plant::all()
|
? Plant::all()
|
||||||
: Plant::where('id', $plantId)->get();
|
: Plant::where('id', $plantId)->get();
|
||||||
@@ -108,8 +80,6 @@ class SendInvoiceDataReport extends Command
|
|||||||
|
|
||||||
//..
|
//..
|
||||||
|
|
||||||
$no = 1;
|
|
||||||
|
|
||||||
foreach ($plants as $plant)
|
foreach ($plants as $plant)
|
||||||
{
|
{
|
||||||
$tableData = [];
|
$tableData = [];
|
||||||
@@ -140,18 +110,11 @@ class SendInvoiceDataReport extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $lastInvoiceDate = $invoices->max('document_date');
|
|
||||||
// $extendedEndDate = \Carbon\Carbon::parse($lastInvoiceDate)
|
|
||||||
// ->addDay() // +1 day
|
|
||||||
// ->setTime(10, 0, 0); // 10:00 AM
|
|
||||||
|
|
||||||
|
|
||||||
// Filter invoices directly — exclude ones with '-' in document_number
|
// Filter invoices directly — exclude ones with '-' in document_number
|
||||||
$invoices = $invoices->filter(function ($inv) {
|
$invoices = $invoices->filter(function ($inv) {
|
||||||
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
|
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
|
||||||
});
|
});
|
||||||
|
|
||||||
// For empty distribution, only take those starting with '7'
|
|
||||||
if (trim($selectedDistribution) == '' || $selectedDistribution == null) {
|
if (trim($selectedDistribution) == '' || $selectedDistribution == null) {
|
||||||
$invoices = $invoices->filter(function ($inv) {
|
$invoices = $invoices->filter(function ($inv) {
|
||||||
return str_starts_with($inv->document_number, '7');
|
return str_starts_with($inv->document_number, '7');
|
||||||
@@ -168,8 +131,6 @@ class SendInvoiceDataReport extends Command
|
|||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
$wentOutInvoices = \App\Models\InvoiceOutValidation::where('plant_id', $plant->id)
|
$wentOutInvoices = \App\Models\InvoiceOutValidation::where('plant_id', $plant->id)
|
||||||
//->whereIn('qr_code', $invoices->pluck('document_number'))
|
|
||||||
//->whereIn('qr_code', $invoices->pluck('document_number')->toArray())
|
|
||||||
->whereIn('qr_code', $invoiceNumbers)
|
->whereIn('qr_code', $invoiceNumbers)
|
||||||
->whereBetween('scanned_at', [$startDate, $endDate])
|
->whereBetween('scanned_at', [$startDate, $endDate])
|
||||||
->distinct('qr_code')
|
->distinct('qr_code')
|
||||||
|
|||||||
Reference in New Issue
Block a user