From f3dba93d81c05a1a4713a534d4157d3d8a087c3b Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 21 Apr 2026 23:19:10 +0200 Subject: [PATCH] fix: move totalBestandskunden before formulaRows (TDZ error) --- pitch-deck/lib/finanzplan/engine.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pitch-deck/lib/finanzplan/engine.ts b/pitch-deck/lib/finanzplan/engine.ts index 71a603c..86c3ee6 100644 --- a/pitch-deck/lib/finanzplan/engine.ts +++ b/pitch-deck/lib/finanzplan/engine.ts @@ -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()