Подсчет долга теперь только при начальной дате периода = началу года

This commit is contained in:
brusnitsyn
2026-07-08 15:09:01 +09:00
parent 18638dfcab
commit 8db7f19dda
3 changed files with 11 additions and 3 deletions

View File

@@ -92,6 +92,9 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
// чтобы % выполнения учитывал непогашенный долг, а не только текущий период // чтобы % выполнения учитывал непогашенный долг, а не только текущий период
$debtAtPeriodStart = max(0, $cumulativePlanAtStart - $actualToRangeStart); $debtAtPeriodStart = max(0, $cumulativePlanAtStart - $actualToRangeStart);
// Индикатор вывода плана с учетом долга (только если дата начала = началу года)
$isCalculateDebt = $startDate->equalTo($startYear);
// Процент выполнения плана с начала года на дату конца периода // Процент выполнения плана с начала года на дату конца периода
$cumulativePercent = $cumulativePlan > 0 $cumulativePercent = $cumulativePlan > 0
? round($actualYearToDate * 100 / $cumulativePlan) ? round($actualYearToDate * 100 / $cumulativePlan)
@@ -106,6 +109,7 @@ class PlanCalculator extends BaseMetricService implements MetricCalculatorInterf
'debt_from_year' => $debtFromYearStart, 'debt_from_year' => $debtFromYearStart,
'actual_year_to_date' => $actualYearToDate, 'actual_year_to_date' => $actualYearToDate,
'cumulative_percent' => $cumulativePercent, 'cumulative_percent' => $cumulativePercent,
'is_calculate_debt' => $isCalculateDebt,
]; ];
} }

View File

@@ -23,18 +23,23 @@ const props = defineProps({
debt_from_year: 0, debt_from_year: 0,
actual_year_to_date: 0, actual_year_to_date: 0,
cumulative_percent: 0, cumulative_percent: 0,
is_calculate_debt: false,
}) })
} }
}) })
// План за период + непогашенный долг, накопленный до начала периода // План за период + непогашенный долг, накопленный до начала периода
const planWithDebt = computed(() => { const planWithDebt = computed(() => {
return Number(props.plan?.period_plan ?? 0) + Number(props.plan?.debt_at_period_start ?? 0) const periodPlan = Number(props.plan?.period_plan ?? 0)
const periodDebt = Number(props.plan?.debt_from_year ?? 0)
return props.plan?.is_calculate_debt ? periodPlan + periodDebt : periodPlan
}) })
// % выполнения плана за период с учётом долга (иначе долг никак не влияет на оценку) // % выполнения плана за период с учётом долга
const periodPercent = computed(() => { const periodPercent = computed(() => {
if (!planWithDebt.value) return 0 if (!planWithDebt.value) return 0
return Math.round((Number(props.value) * 100) / planWithDebt.value) return Math.round((Number(props.value) * 100) / planWithDebt.value)
}) })

View File

@@ -6,7 +6,6 @@ export const percentColor = (number) => {
} }
export const percentType = (number) => { export const percentType = (number) => {
if (!Number(number)) return
if (number >= 90) return 'success' // Хорошо if (number >= 90) return 'success' // Хорошо
if (number >= 80) return 'warning' // Плохо if (number >= 80) return 'warning' // Плохо
return 'error' // Ужасно return 'error' // Ужасно