Добавил ограничение по отказникам

This commit is contained in:
brusnitsyn
2026-06-17 17:38:48 +09:00
parent fe59410187
commit 839a534bb2
6 changed files with 105 additions and 3 deletions

View File

@@ -32,6 +32,12 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
$startCurrentMonth = $endDate->copy()->startOfMonth()->setHours(9);
$currentMonth = $endDate->month;
// Кол-во календарных месяцев, затронутых выбранным диапазоном (для нормы за период)
$monthsInRange = max(
1,
($endDate->year * 12 + $endDate->month) - ($startDate->year * 12 + $startDate->month) + 1
);
// Получаем фактические выписки с начала года по прошлый месяц
$previousOutcomeMonth = DB::table('report_duties as r')
->join('duty_report_metric_results as mr', 'r.id', '=', 'mr.rf_report_id')
@@ -99,6 +105,7 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
$results[$departmentId] = [
'year_plan' => $annualPlan,
'month_plan' => $oneMonthPlan,
'period_plan' => $oneMonthPlan * $monthsInRange, // норма за выбранный период (мес. × кол-во месяцев)
'total_debt' => $totalDebt,
'current_mouth_dept' => $currentMonthPlanOnly,
'cumulative_plan' => $cumulativePlan,