Add support for 'WOS' distribution in InvoiceDataChart for comprehensive invoice tracking

This commit is contained in:
dhanabalan
2025-11-05 14:40:04 +05:30
parent cbb3a62997
commit 0b034a7963

View File

@@ -176,6 +176,50 @@ class InvoiceDataChart extends ChartWidget
],
];
}
elseif ($selectedDistribution == 'WOS')
{
$totalInvoices = InvoiceDataValidation::where('plant_id', $selectedPlant)
->where('distribution_channel_desc', $selectedDistribution)
->whereBetween('document_date', [$startDate, $endDate])
->distinct('document_number')
->pluck('document_number')
->toArray();
if (empty($totalInvoices)) {
return [
'labels' => ['Total', 'Went Out', 'Pending'],
'datasets' => [
[
'label' => 'Invoice Count',
'data' => [0, 0, 0],
'backgroundColor' => ['#60A5FA', '#34D399', '#F87171'],
],
],
];
}
$wentOutInvoices = InvoiceOutValidation::where('plant_id', $selectedPlant)
->whereIn('qr_code', $totalInvoices)
->whereBetween('scanned_at', [$startDate, $endDate])
->distinct('qr_code')
->pluck('qr_code')
->toArray();
$totalCount = count($totalInvoices);
$wentOutCount = count($wentOutInvoices);
$pendingCount = $totalCount - $wentOutCount;
return [
'labels' => ['Total Invoices', 'Went Out', 'Pending'],
'datasets' => [
[
'label' => ucfirst(str_replace('_', ' ', $activeFilter)),
'data' => [$totalCount, $wentOutCount, $pendingCount],
'backgroundColor' => ['#60A5FA', '#34D399', '#F87171'], // blue, green, red
],
],
];
}
elseif ($selectedDistribution == 'Challan')
{
$totalInvoices = InvoiceDataValidation::where('plant_id', $selectedPlant)