feat: Finanzplan Phase 1-4 — DB + Engine + API + Spreadsheet-UI

Phase 1: DB-Schema (12 fp_* Tabellen) + Excel-Import (332 Zeilen importiert)
Phase 2: Compute Engine (Personal, Invest, Umsatz, Material, Betrieblich, Liquiditaet, GuV)
Phase 3: API (/api/finanzplan/ — GET sheets, PUT cells, POST compute)
Phase 4: Spreadsheet-UI (FinanzplanSlide als Annex mit Tab-Leiste, editierbarem Grid, Jahres-Navigation)

Zusaetzlich:
- Gruendungsdatum verschoben: Feb→Aug 2026 (DB + Personalkosten)
- Neue Preisstaffel: Startup/<10 MA ab 3.600 EUR/Jahr (14-Tage-Test, Kreditkarte)
- Competition-Slide: Pricing-Tiers aktualisiert

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-26 19:26:46 +01:00
parent f514667ef9
commit a58cd16f01
16 changed files with 4589 additions and 5 deletions

View File

@@ -0,0 +1,38 @@
import { NextRequest, NextResponse } from 'next/server'
import pool from '@/lib/db'
import { computeFinanzplan } from '@/lib/finanzplan/engine'
export async function POST(request: NextRequest) {
try {
const body = await request.json().catch(() => ({}))
const scenarioId = body.scenarioId
// Get scenario ID
let sid = scenarioId
if (!sid) {
const { rows } = await pool.query('SELECT id FROM fp_scenarios WHERE is_default = true LIMIT 1')
if (rows.length === 0) {
return NextResponse.json({ error: 'No default scenario found' }, { status: 404 })
}
sid = rows[0].id
}
const result = await computeFinanzplan(pool, sid)
return NextResponse.json({
scenarioId: sid,
computed: true,
summary: {
total_revenue_y2026: result.umsatzerloese.total.m1 !== undefined
? Object.values(result.umsatzerloese.total).reduce((a, b) => a + b, 0)
: 0,
total_costs_y2026: Object.values(result.betriebliche.total_gesamt).reduce((a, b) => a + b, 0),
headcount_m60: result.personalkosten.headcount.m60 || 0,
cash_balance_m60: result.liquiditaet.endstand.m60 || 0,
},
})
} catch (error) {
console.error('Finanzplan compute error:', error)
return NextResponse.json({ error: String(error) }, { status: 500 })
}
}