diff --git a/app/Models/Department.php b/app/Models/Department.php
index 645274b..7565c26 100644
--- a/app/Models/Department.php
+++ b/app/Models/Department.php
@@ -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();
}
diff --git a/app/Services/MetricCalculators/PlanCalculator.php b/app/Services/MetricCalculators/PlanCalculator.php
index c7b65f8..9fb9aab 100644
--- a/app/Services/MetricCalculators/PlanCalculator.php
+++ b/app/Services/MetricCalculators/PlanCalculator.php
@@ -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 месяц (равномерно)
diff --git a/app/Services/ReportService.php b/app/Services/ReportService.php
index 245f349..5971b55 100644
--- a/app/Services/ReportService.php
+++ b/app/Services/ReportService.php
@@ -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);
diff --git a/resources/js/Layouts/Components/Statistic/StatisticRecipientPlanOfYear.vue b/resources/js/Layouts/Components/Statistic/StatisticRecipientPlanOfYear.vue
index 33c8f0f..a1b2611 100644
--- a/resources/js/Layouts/Components/Statistic/StatisticRecipientPlanOfYear.vue
+++ b/resources/js/Layouts/Components/Statistic/StatisticRecipientPlanOfYear.vue
@@ -1,6 +1,8 @@
@@ -30,12 +26,13 @@ const percentColor = computed(() => {
План:
-
-
-
+
из
+
+ {{ percentProgress }}%
+
diff --git a/resources/js/Utils/numbers.js b/resources/js/Utils/numbers.js
index caf826f..daf7728 100644
--- a/resources/js/Utils/numbers.js
+++ b/resources/js/Utils/numbers.js
@@ -1,15 +1,15 @@
export const percentColor = (number) => {
if (!Number(number)) return
- if (number < 50) return 'color: var(--color-red-500);' // Ужасно
- if (number >= 50 && number < 80) return 'color: var(--color-amber-500);' // Плохо
- if (number >= 80) return 'color: var(--color-emerald-500);' // Хорошо
+ if (number >= 90) return 'color: var(--color-emerald-500);' // Хорошо
+ if (number >= 80) return 'color: var(--color-amber-500);' // Плохо
+ return 'color: var(--color-red-500);' // Ужасно
}
export const percentType = (number) => {
if (!Number(number)) return
- if (number < 50) return 'error' // Ужасно
- if (number >= 50 && number < 80) return 'warning' // Плохо
- if (number >= 80) return 'success' // Хорошо
+ if (number >= 90) return 'success' // Хорошо
+ if (number >= 80) return 'warning' // Плохо
+ return 'error' // Ужасно
}
export const typePlan = (plan, completed) => {