Изменил пороги цвета и привязку процента к выбранной дате
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 месяц (равномерно)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user