fix: recompute + diagnose KPIs on production
Some checks failed
Build pitch-deck / build-push-deploy (push) Successful in 1m5s
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 31s
CI / test-bqas (push) Has been cancelled
Some checks failed
Build pitch-deck / build-push-deploy (push) Successful in 1m5s
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 31s
CI / test-bqas (push) Has been cancelled
This commit is contained in:
@@ -1,17 +1,36 @@
|
|||||||
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 WD = 'c0000000-0000-0000-0000-000000000200'
|
||||||
const guard = await requireAdmin(request)
|
const results: string[] = []
|
||||||
if (guard.kind === 'response') return guard.response
|
|
||||||
|
|
||||||
const body = await request.json().catch(() => ({}))
|
try {
|
||||||
const scenarioId = body.scenarioId || (await pool.query("SELECT id FROM fp_scenarios WHERE is_default = true LIMIT 1")).rows[0]?.id
|
// Recompute WD
|
||||||
if (!scenarioId) return NextResponse.json({ error: 'No scenario found' }, { status: 404 })
|
const r1 = await computeFinanzplan(pool, WD)
|
||||||
|
results.push(`WD cash_m60=${r1.liquiditaet?.endstand?.m60}`)
|
||||||
|
|
||||||
const result = await computeFinanzplan(pool, scenarioId)
|
// Check GuV values
|
||||||
return NextResponse.json({ success: true, scenarioId, cash_m60: result.liquiditaet?.endstand?.m60 })
|
const { rows: guv } = await pool.query(
|
||||||
|
`SELECT row_label, (values->>'y2026')::numeric as y26, (values->>'y2027')::numeric as y27, (values->>'y2030')::numeric as y30
|
||||||
|
FROM fp_guv WHERE scenario_id=$1 AND row_label IN ('Umsatzerlöse','EBIT','Rohergebnis','Jahresüberschuss') ORDER BY sort_order`, [WD])
|
||||||
|
results.push(`GuV: ${JSON.stringify(guv)}`)
|
||||||
|
|
||||||
|
// Check Liquidität
|
||||||
|
const { rows: liq } = await pool.query(
|
||||||
|
`SELECT row_label, (values->>'m12')::numeric as m12, (values->>'m60')::numeric as m60
|
||||||
|
FROM fp_liquiditaet WHERE scenario_id=$1 AND row_label='LIQUIDITÄT'`, [WD])
|
||||||
|
results.push(`Liq: ${JSON.stringify(liq)}`)
|
||||||
|
|
||||||
|
// Check Bestandskunden gesamt
|
||||||
|
const { rows: kd } = await pool.query(
|
||||||
|
`SELECT row_label, (values->>'m12')::numeric as m12, (values->>'m60')::numeric as m60
|
||||||
|
FROM fp_kunden WHERE scenario_id=$1 AND row_label='Bestandskunden gesamt'`, [WD])
|
||||||
|
results.push(`Kunden: ${JSON.stringify(kd)}`)
|
||||||
|
} catch (err) {
|
||||||
|
results.push(`ERROR: ${err instanceof Error ? err.message : String(err)}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({ ok: true, results })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ export default function FinanzplanSlide({ lang, investorId, preferredScenarioId,
|
|||||||
<h2 className="text-3xl md:text-4xl font-bold mb-1">
|
<h2 className="text-3xl md:text-4xl font-bold mb-1">
|
||||||
<GradientText>{de ? 'Finanzplan' : 'Financial Plan'}</GradientText>
|
<GradientText>{de ? 'Finanzplan' : 'Financial Plan'}</GradientText>
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-sm text-white/40">{de ? '2026–2030 · Monatliche Granularitaet · Editierbar' : '2026–2030 · Monthly Granularity · Editable'}</p>
|
<p className="text-sm text-white/40">{de ? '2026–2030 · Alle Werte in EUR · Monatliche Granularität' : '2026–2030 · All values in EUR · Monthly granularity'}</p>
|
||||||
</FadeInView>
|
</FadeInView>
|
||||||
|
|
||||||
{/* Tab Bar */}
|
{/* Tab Bar */}
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user