From d1e087e4a87ef76a740c81c154c46fa09f820cfa Mon Sep 17 00:00:00 2001 From: Brusnitsyn Date: Mon, 6 Jul 2026 14:23:15 +0000 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0=20=D0=BF=D0=BE=20=D1=81=D1=83=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MetricCalculators/PlanCalculator.php | 12 ++++++------ .../js/Pages/Statistic/Components/OutcomeColumn.vue | 13 +------------ resources/js/Pages/Statistic/Index.vue | 3 +-- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/Services/MetricCalculators/PlanCalculator.php b/app/Services/MetricCalculators/PlanCalculator.php index 9fb9aab..4cd8aa4 100644 --- a/app/Services/MetricCalculators/PlanCalculator.php +++ b/app/Services/MetricCalculators/PlanCalculator.php @@ -32,11 +32,8 @@ 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 - ); + // Кол-во дней в выбранном диапазоне (для нормы за период — пропорционально дням, а не месяцам) + $daysInRange = max(1, $startDate->diffInDays($endDate)); // Получаем фактические выписки с начала года по прошлый месяц $previousOutcomeMonth = DB::table('report_duties as r') @@ -74,6 +71,9 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf // План на 1 месяц (равномерно) $oneMonthPlan = $annualPlan > 0 ? ceil($annualPlan / 12) : 0; + // План на 1 день (равномерно, от годового плана) + $dailyPlan = $annualPlan > 0 ? $annualPlan / 365 : 0; + // ===== БЕЗОПАСНОЕ ПОЛУЧЕНИЕ ЗНАЧЕНИЙ ===== // Факт за прошлые месяцы (без текущего) $actualToLastMonth = (int) ($previousOutcomeMonth[$departmentId]->total ?? 0); @@ -105,7 +105,7 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf $results[$departmentId] = [ 'year_plan' => $annualPlan, 'month_plan' => $oneMonthPlan, - 'period_plan' => $oneMonthPlan * $monthsInRange, // норма за выбранный период (мес. × кол-во месяцев) + 'period_plan' => (int) round($dailyPlan * $daysInRange), // норма за выбранный период (дневной план × кол-во дней) 'total_debt' => $totalDebt, 'current_mouth_dept' => $currentMonthPlanOnly, 'cumulative_plan' => $cumulativePlan, diff --git a/resources/js/Pages/Statistic/Components/OutcomeColumn.vue b/resources/js/Pages/Statistic/Components/OutcomeColumn.vue index 9a0162e..9425cc6 100644 --- a/resources/js/Pages/Statistic/Components/OutcomeColumn.vue +++ b/resources/js/Pages/Statistic/Components/OutcomeColumn.vue @@ -2,8 +2,6 @@ import {NFlex, NSpace, NTag, NTooltip} from 'naive-ui' import {percentType} from "../../../Utils/numbers.js"; import {computed} from "vue"; -import {format, toDate} from "date-fns"; -import {ru} from "date-fns/locale"; const props = defineProps({ isTotalRow: { @@ -26,18 +24,9 @@ const props = defineProps({ total_debt: 0, year_plan: 0, }) - }, - endDate: { - type: [Number, String], - default: null } }) -const formatedMonth = computed(() => { - const date = toDate(props.endDate) - return date.toLocaleString('ru', { month: 'long' }) -}) - const typePlan = computed(() => { if (props.plan.debt_from_year > 20) return 'error' if (props.plan.debt_from_year > 10) return 'warning' @@ -89,7 +78,7 @@ const periodPercent = computed(() => { - План на {{formatedMonth}}: {{ plan.month_plan }} / {{ plan.current_mouth_dept }} + План / Выбывшие: {{ plan.period_plan }} / {{ value }} Долг с начала года: {{ plan.debt_from_year }} diff --git a/resources/js/Pages/Statistic/Index.vue b/resources/js/Pages/Statistic/Index.vue index a095fcd..0045f1d 100644 --- a/resources/js/Pages/Statistic/Index.vue +++ b/resources/js/Pages/Statistic/Index.vue @@ -183,8 +183,7 @@ const columns = ref([ { isTotalRow: row.isTotalRow, value: row.outcome, - plan: row.plan, - endDate: props.date[1] + plan: row.plan } ) }