chore: TEMP fp-patch for ISO cert Jan 2027
All checks were successful
Build pitch-deck / build-push-deploy (push) Successful in 1m8s
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 32s
CI / test-python-voice (push) Successful in 33s
CI / test-bqas (push) Successful in 30s

This commit is contained in:
Benjamin Admin
2026-04-21 23:50:43 +02:00
parent 48c6f9277c
commit bb1144f392
2 changed files with 25 additions and 9 deletions

View File

@@ -1,17 +1,32 @@
import { NextRequest, NextResponse } from 'next/server'
import { requireAdmin } from '@/lib/admin-auth'
import pool from '@/lib/db'
import { computeFinanzplan } from '@/lib/finanzplan/engine'
/** Admin-only: recompute a Finanzplan scenario. */
export async function POST(request: NextRequest) {
const guard = await requireAdmin(request)
if (guard.kind === 'response') return guard.response
const WD = 'c0000000-0000-0000-0000-000000000200'
const body = await request.json().catch(() => ({}))
const scenarioId = body.scenarioId || (await pool.query("SELECT id FROM fp_scenarios WHERE is_default = true LIMIT 1")).rows[0]?.id
if (!scenarioId) return NextResponse.json({ error: 'No scenario found' }, { status: 404 })
const results: string[] = []
const result = await computeFinanzplan(pool, scenarioId)
return NextResponse.json({ success: true, scenarioId, cash_m60: result.liquiditaet?.endstand?.m60 })
try {
// ISO Cert: add months m13-m24 (Jan-Dec 2027) at 1500
const { rows } = await pool.query(`SELECT id, values FROM fp_betriebliche_aufwendungen WHERE scenario_id=$1 AND row_label ILIKE '%Zertifizierung%'`, [WD])
if (rows.length > 0) {
const vals = rows[0].values || {}
for (let m = 13; m <= 24; m++) {
if (!vals[`m${m}`]) vals[`m${m}`] = 1500
}
await pool.query(`UPDATE fp_betriebliche_aufwendungen SET values=$1 WHERE id=$2`, [JSON.stringify(vals), rows[0].id])
results.push('ISO cert from Jan 2027')
}
// Recompute if requested
if (body.recompute !== false) {
const r = await computeFinanzplan(pool, WD)
results.push(`WD cash_m60=${r.liquiditaet?.endstand?.m60}`)
}
} catch (err) {
results.push(`ERROR: ${err instanceof Error ? err.message : String(err)}`)
}
return NextResponse.json({ ok: true, results })
}

View File

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