changed logic in item overview final updation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 9s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 3m14s
Laravel Larastan / larastan (pull_request) Failing after 5m29s

This commit is contained in:
dhanabalan
2026-10-29 12:48:24 +05:30
parent 4da6375db0
commit 74ae73918f

View File

@@ -13,6 +13,8 @@ class ItemOverview extends ChartWidget
{
protected static ?string $heading = 'Hourly Production';
public ?string $filter = 'today';
protected int|string|array $columnSpan = '12';
protected static ?string $maxHeight = '400px';
@@ -150,6 +152,8 @@ class ItemOverview extends ChartWidget
// $planQuantity
// );
$planData = [];
if ($activeFilter === 'today') {
$monthlyPlanQuantity = \DB::table('production_plans')
@@ -159,18 +163,16 @@ class ItemOverview extends ChartWidget
->whereMonth('created_at', $startDate->month)
->sum('plan_quantity');
// Calculate daily target directly
$weeksCount = (int) ceil($startDate->daysInMonth / 7);
$weeksCount = (int) ceil(now()->daysInMonth / 7);
$dailyPlan = $weeksCount > 0
? round($monthlyPlanQuantity / ($weeksCount * 7), 2)
: 0;
// Calculate hourly target
$hourlyPlan = round($dailyPlan / 22.5, 2);
// Same hourly plan value for every hour
$planData = array_fill(0, 24, $hourlyPlan);
$planData = array_fill(0, count($orderedData), $hourlyPlan);
}
if ($activeFilter === 'yesterday') {
@@ -240,14 +242,7 @@ class ItemOverview extends ChartWidget
// Monday through Sunday
$planData = array_fill(0, 7, $dailyPlan);
}
else {
// This Week: each day's production / 22.5
// This Month: each week's production / 22.5
$planData = array_map(
fn ($quantity) => round($quantity / 22.5, 2),
$orderedData
);
}
return [
'datasets' => [