Изменил пороги цвета и привязку процента к выбранной дате

This commit is contained in:
Brusnitsyn
2026-07-06 13:36:30 +00:00
parent 9d8177c086
commit 86a33f2e46
5 changed files with 18 additions and 21 deletions

View File

@@ -43,12 +43,12 @@ class Department extends Model
return $this->belongsTo(UserDepartment::class, 'department_id', 'rf_department_id');
}
public function recipientPlanOfYear()
public function recipientPlanOfYear(?Carbon $asOf = null)
{
$now = Carbon::now();
$asOf = $asOf ?? Carbon::now();
return $this->metrikaDefault()
->where('date_end', '>', $now)
->where('date_end', '>', $asOf)
->where('rf_metrika_item_id', 23)
->first();
}

View File

@@ -68,7 +68,7 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
$department = Department::find($departmentId);
// Получаем годовой план
$annualPlanModel = $department->recipientPlanOfYear();
$annualPlanModel = $department->recipientPlanOfYear($endDate);
$annualPlan = $annualPlanModel ? (int) $annualPlanModel->value : 0;
// План на 1 месяц (равномерно)

View File

@@ -829,7 +829,7 @@ class ReportService
*/
public function getRecipientPlanOfYear(Department $department, DateRange $dateRange): array
{
$periodPlanModel = $department->recipientPlanOfYear();
$periodPlanModel = $department->recipientPlanOfYear($dateRange->endDate);
$monthsInPeriod = ceil($dateRange->startDate->diffInMonths($dateRange->endDate));
$annualPlan = $periodPlanModel ? (int) $periodPlanModel->value : 0;
$oneMonthPlan = ceil($annualPlan / 12);