fix(dashboard): не копировать оценку расходов на все месяцы
Docker / build (push) Failing after 20s

Оценка burn только за текущий месяц; KPI совпадает с convertVpsMonthlyBurnToBase.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-07-20 01:00:11 +07:00
co-authored by Cursor
parent d25beec289
commit 8a4934940f
4 changed files with 65 additions and 18 deletions
+10 -7
View File
@@ -168,6 +168,14 @@ export function aggregateEstimatedVpsBurnByMonthYear(
ratesData: RatesData | null,
): { month: string; amount: number }[] {
const providerById = providerByIdMap(providers)
const now = new Date()
const byMonth = Array.from({ length: 12 }, () => 0)
// Без факта списаний не выдумываем историю: оценка = текущий burn только в текущем месяце.
if (year !== now.getFullYear()) {
return bucketsToRows(byMonth)
}
const monthlyBurn = vps
.filter((item) => item.status === 'active')
.reduce(
@@ -177,13 +185,8 @@ export function aggregateEstimatedVpsBurnByMonthYear(
0,
)
const now = new Date()
const rounded = Math.round(monthlyBurn)
return Array.from({ length: 12 }, (_, index) => ({
month: formatMonthShortRu(index),
amount: year === now.getFullYear() && index <= now.getMonth() ? rounded : 0,
}))
byMonth[now.getMonth()] = monthlyBurn
return bucketsToRows(byMonth)
}
export function aggregateDashboardExpensesByMonthYear(