fix: move totalBestandskunden before formulaRows (TDZ error)
Some checks failed
Build pitch-deck / build-push-deploy (push) Successful in 1m12s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 34s
CI / test-python-voice (push) Successful in 32s
CI / test-bqas (push) Has been cancelled

This commit is contained in:
Benjamin Admin
2026-04-21 23:19:10 +02:00
parent 62aa56b007
commit f3dba93d81

View File

@@ -237,6 +237,17 @@ export async function computeFinanzplan(pool: Pool, scenarioId: string): Promise
// 6. Betriebliche Aufwendungen — compute formula-based rows + sum rows
const betrieb = betriebRows.rows as FPBetrieblicheAufwendungen[]
// Pre-compute total Bestandskunden (needed for Bewirtungskosten + Serverkosten)
const totalBestandskunden = emptyMonthly()
for (const row of kundenRows.rows) {
const rl = (row as { row_label?: string }).row_label || ''
if (rl.includes('Bestandskunden') && !rl.includes('gesamt')) {
for (let m = 1; m <= MONTHS; m++) {
totalBestandskunden[`m${m}`] += row.values?.[`m${m}`] || 0
}
}
}
// Formula-based rows: derive from headcount (excl. founders) or customers
const formulaRows: { label: string; perUnit: number; source: MonthlyValues }[] = [
{ label: 'Fort-/Weiterbildungskosten (F)', perUnit: 300, source: hcWithoutFounders },
@@ -283,16 +294,7 @@ export async function computeFinanzplan(pool: Pool, scenarioId: string): Promise
marketingRow.values = computed
}
// Serverkosten: 2.000 EUR Basis (SysEleven) + 250 EUR pro Bestandskunde
const totalBestandskunden = emptyMonthly()
for (const row of kundenRows.rows) {
const rl = (row as { row_label?: string }).row_label || ''
if (rl.includes('Bestandskunden') && !rl.includes('gesamt')) {
for (let m = 1; m <= MONTHS; m++) {
totalBestandskunden[`m${m}`] += row.values?.[`m${m}`] || 0
}
}
}
// Serverkosten: 2.000 EUR Basis (SysEleven) + 250 EUR pro Bestandskunde (first 10 incl.)
const serverRow = betrieb.find(r => r.row_label === 'Serverkosten Cloud (F)' || r.row_label === 'Serverkosten (Cloud)')
if (serverRow) {
const computed = emptyMonthly()