Added remark column for invoice data report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 2m59s
Laravel Larastan / larastan (pull_request) Failing after 4m6s

This commit is contained in:
dhanabalan
2026-01-20 10:26:38 +05:30
parent 76afd15b3b
commit cf7e0294c4
2 changed files with 10 additions and 13 deletions

View File

@@ -6,12 +6,8 @@ use App\Mail\InvoiceDataMail;
use App\Models\AlertMailRule;
use App\Models\InvoiceDataValidation;
use App\Models\InvoiceOutValidation;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProductionPlan;
use App\Models\ProductionQuantity;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class SendInvoiceDataReport extends Command
{
@@ -49,7 +45,7 @@ class SendInvoiceDataReport extends Command
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
if ($plants->isEmpty()) {
$this->error("No valid plant(s) found.");
$this->error('No valid plant(s) found.');
return;
}
@@ -105,7 +101,7 @@ class SendInvoiceDataReport extends Command
->where('distribution_channel_desc', $selectedDistribution)
->whereBetween('document_date', [$startDate, $endDate])
->orderBy('document_date', 'asc')
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location')
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location', 'remark')
->get()
->unique('document_number')
->values();
@@ -114,7 +110,6 @@ class SendInvoiceDataReport extends Command
continue;
}
// Filter invoices directly — exclude ones with '-' in document_number
$invoices = $invoices->filter(function ($inv) {
return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
});
@@ -134,7 +129,6 @@ class SendInvoiceDataReport extends Command
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
->toArray();
//where('plant_id', $plant->id)
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
//->whereBetween('scanned_at', [$startDate, $endDate])
->distinct('qr_code')
@@ -164,7 +158,6 @@ class SendInvoiceDataReport extends Command
return !in_array($doc, $wentOutInvoices, true);
});
if ($pendingInvoices->isEmpty()) {
continue;
}
@@ -182,7 +175,7 @@ class SendInvoiceDataReport extends Command
}
$tableData[] = [
//'no' => $no++,
// 'no' => $no++,
'plant' => $plant->name,
// 'distribution_type' => $selectedDistribution,
'customer_code' => $inv->customer_code,
@@ -194,6 +187,7 @@ class SendInvoiceDataReport extends Command
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
'status' => 'Pending',
'status_class' => $statusColor,
'remark' => $inv->remark,
];
}
}
@@ -203,6 +197,7 @@ class SendInvoiceDataReport extends Command
->values()
->map(function ($item, $index) {
$item['no'] = $index + 1;
return $item;
})
->toArray();
@@ -214,7 +209,7 @@ class SendInvoiceDataReport extends Command
$this->info($contentVars['greeting'] ?? 'Invoice Data Report');
$this->table(
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status'],//'Distribution Type'
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status', 'Remark'],// 'Distribution Type'
$tableData
);
$this->info($contentVars['wishes'] ?? '');
@@ -236,13 +231,13 @@ class SendInvoiceDataReport extends Command
->toArray();
if (empty($toEmails)) {
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found.");
$this->info("Skipping rule ID {$rule->id} — no valid To emails found.");
continue;
}
\Mail::to($toEmails)->cc($ccEmails)->send($mail);
$this->info("Mail sent for rule ID {$rule->id} → To: " . implode(', ', $toEmails) . ($ccEmails ? " | CC: " . implode(', ', $ccEmails) : ''));
$this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
}
}
}

View File

@@ -88,6 +88,7 @@
<th>Location</th>
<th>Pending Days</th>
<th>Status</th>
<th>Remark</th>
</tr>
</thead>
<tbody>
@@ -117,6 +118,7 @@
<td class="{{ $row['status_class'] ?? '' }}">
{{ $row['status'] }}
</td>
<td>{{ $row['remark'] ?? '-'}}</td>
</tr>
@endforeach
</tbody>