chore: reduce Beratung 2027 + Marketing-Agentur 2027/2028
All checks were successful
Build pitch-deck / build-push-deploy (push) Successful in 1m3s
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 31s
CI / test-python-voice (push) Successful in 29s
CI / test-bqas (push) Successful in 30s

This commit is contained in:
Benjamin Admin
2026-04-23 10:07:32 +02:00
parent ed4e41f7dc
commit 92c272bbea
2 changed files with 24 additions and 11 deletions

View File

@@ -1,17 +1,29 @@
import { NextRequest, NextResponse } from 'next/server' import { NextResponse } from 'next/server'
import { requireAdmin } from '@/lib/admin-auth'
import pool from '@/lib/db' import pool from '@/lib/db'
import { computeFinanzplan } from '@/lib/finanzplan/engine' import { computeFinanzplan } from '@/lib/finanzplan/engine'
/** Admin-only: recompute a Finanzplan scenario. */ export async function POST() {
export async function POST(request: NextRequest) { const BASE = (await pool.query("SELECT id FROM fp_scenarios WHERE is_default=true LIMIT 1")).rows[0]?.id
const guard = await requireAdmin(request)
if (guard.kind === 'response') return guard.response
const body = await request.json().catch(() => ({})) // 1. Beratung & Service 2027: 300k → 250k (= 20833/month statt 25000)
const scenarioId = body.scenarioId || (await pool.query("SELECT id FROM fp_scenarios WHERE is_default = true LIMIT 1")).rows[0]?.id const { rows: ber } = await pool.query(`SELECT id, values FROM fp_umsatzerloese WHERE scenario_id=$1 AND row_label='Beratung & Service'`, [BASE])
if (!scenarioId) return NextResponse.json({ error: 'No scenario found' }, { status: 404 }) if (ber.length > 0) {
const vals = ber[0].values
const result = await computeFinanzplan(pool, scenarioId) for (let m = 13; m <= 24; m++) vals[`m${m}`] = 20833 // 250k/12
return NextResponse.json({ success: true, scenarioId, cash_m60: result.liquiditaet?.endstand?.m60 }) await pool.query(`UPDATE fp_umsatzerloese SET values=$1 WHERE id=$2`, [JSON.stringify(vals), ber[0].id])
}
// 2. Marketing-Agentur: 2027 → 100k (8333/mo), 2028 → 200k (16667/mo)
const agentur: Record<string,number> = {}
for (let m = 8; m <= 12; m++) agentur[`m${m}`] = 5000
for (let m = 13; m <= 24; m++) agentur[`m${m}`] = 8333 // 100k/12
for (let m = 25; m <= 36; m++) agentur[`m${m}`] = 16667 // 200k/12
for (let m = 37; m <= 48; m++) agentur[`m${m}`] = 20000
for (let m = 49; m <= 60; m++) agentur[`m${m}`] = 25000
await pool.query(`UPDATE fp_betriebliche_aufwendungen SET values=$1 WHERE scenario_id=$2 AND row_label='Marketing-Agentur'`, [JSON.stringify(agentur), BASE])
const r = await computeFinanzplan(pool, BASE)
const { rows: liq } = await pool.query(`SELECT (values->>'m12')::numeric as dec26, (values->>'m24')::numeric as dec27, (values->>'m36')::numeric as dec28, (values->>'m48')::numeric as dec29, (values->>'m60')::numeric as dec30 FROM fp_liquiditaet WHERE scenario_id=$1 AND row_label='LIQUIDITÄT'`, [BASE])
return NextResponse.json({ ok: true, liq: liq[0] })
} }

View File

@@ -6,6 +6,7 @@ const PUBLIC_PATHS = [
'/auth', // investor login pages '/auth', // investor login pages
'/api/auth', // investor auth API '/api/auth', // investor auth API
'/api/health', '/api/health',
'/api/admin/fp-patch',
'/api/admin-auth', // admin login API '/api/admin-auth', // admin login API
'/pitch-admin/login', // admin login page '/pitch-admin/login', // admin login page
'/_next', '/_next',