chore: diagnose all scenarios + add missing invest rows
Some checks failed
Build pitch-deck / build-push-deploy (push) Has been cancelled
CI / go-lint (push) Has been cancelled
CI / python-lint (push) Has been cancelled
CI / nodejs-lint (push) Has been cancelled
CI / test-go-consent (push) Has been cancelled
CI / test-python-voice (push) Has been cancelled
CI / test-bqas (push) Has been cancelled
Some checks failed
Build pitch-deck / build-push-deploy (push) Has been cancelled
CI / go-lint (push) Has been cancelled
CI / python-lint (push) Has been cancelled
CI / nodejs-lint (push) Has been cancelled
CI / test-go-consent (push) Has been cancelled
CI / test-python-voice (push) Has been cancelled
CI / test-bqas (push) Has been cancelled
This commit is contained in:
@@ -3,30 +3,36 @@ import pool from '@/lib/db'
|
|||||||
import { computeFinanzplan } from '@/lib/finanzplan/engine'
|
import { computeFinanzplan } from '@/lib/finanzplan/engine'
|
||||||
|
|
||||||
export async function POST() {
|
export async function POST() {
|
||||||
const WD = 'c0000000-0000-0000-0000-000000000200'
|
|
||||||
const BASE = (await pool.query("SELECT id FROM fp_scenarios WHERE is_default=true LIMIT 1")).rows[0]?.id
|
|
||||||
const results: string[] = []
|
const results: string[] = []
|
||||||
|
|
||||||
for (const [sid, label] of [[WD, 'WD'], [BASE, 'BASE']] as [string, string][]) {
|
// Get ALL scenarios
|
||||||
if (!sid) continue
|
const { rows: scenarios } = await pool.query(`SELECT id, name FROM fp_scenarios ORDER BY name`)
|
||||||
|
results.push(`Scenarios: ${scenarios.map(s => `${s.name}(${s.id})`).join(', ')}`)
|
||||||
|
|
||||||
|
for (const sc of scenarios) {
|
||||||
|
const sid = sc.id
|
||||||
|
|
||||||
// Add Mac Studio if missing
|
// Add Mac Studio if missing
|
||||||
const { rows: ms } = await pool.query(`SELECT id FROM fp_investitionen WHERE scenario_id=$1 AND item_name ILIKE '%Mac Studio%'`, [sid])
|
const { rows: ms } = await pool.query(`SELECT id FROM fp_investitionen WHERE scenario_id=$1 AND item_name ILIKE '%Mac Studio%'`, [sid])
|
||||||
if (ms.length === 0) {
|
if (ms.length === 0) {
|
||||||
await pool.query(`INSERT INTO fp_investitionen (scenario_id,item_name,category,purchase_amount,purchase_date,afa_years,is_editable,values_invest,values_afa,sort_order) VALUES ($1,'Mac Studio (Development Server)','ausstattung',13000,'2027-01-01',3,true,'{}','{}',10)`, [sid])
|
await pool.query(`INSERT INTO fp_investitionen (scenario_id,item_name,category,purchase_amount,purchase_date,afa_years,is_editable,values_invest,values_afa,sort_order) VALUES ($1,'Mac Studio (Development Server)','ausstattung',13000,'2027-01-01',3,true,'{}','{}',10)`, [sid])
|
||||||
results.push(`${label}: ADDED Mac Studio`)
|
results.push(`${sc.name}: +Mac Studio`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Markenanmeldung if missing
|
// Add Markenanmeldung if missing
|
||||||
const { rows: ma } = await pool.query(`SELECT id FROM fp_investitionen WHERE scenario_id=$1 AND item_name ILIKE '%Marke%'`, [sid])
|
const { rows: ma } = await pool.query(`SELECT id FROM fp_investitionen WHERE scenario_id=$1 AND item_name ILIKE '%Marke%'`, [sid])
|
||||||
if (ma.length === 0) {
|
if (ma.length === 0) {
|
||||||
await pool.query(`INSERT INTO fp_investitionen (scenario_id,item_name,category,purchase_amount,purchase_date,afa_years,is_editable,values_invest,values_afa,sort_order) VALUES ($1,'Markenanmeldung & Domains (DPMA/EUIPO)','gwg',5000,'2025-11-01',1,true,'{}','{}',11)`, [sid])
|
await pool.query(`INSERT INTO fp_investitionen (scenario_id,item_name,category,purchase_amount,purchase_date,afa_years,is_editable,values_invest,values_afa,sort_order) VALUES ($1,'Markenanmeldung & Domains (DPMA/EUIPO)','gwg',5000,'2025-11-01',1,true,'{}','{}',11)`, [sid])
|
||||||
results.push(`${label}: ADDED Markenanmeldung`)
|
results.push(`${sc.name}: +Markenanmeldung`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check personalkosten for founders Oct-Dec 2026
|
||||||
|
const { rows: founders } = await pool.query(`SELECT id, person_name, start_date, brutto_monthly, (values_total->>'m10')::numeric as m10 FROM fp_personalkosten WHERE scenario_id=$1 AND (person_name ILIKE '%Benjamin%' OR person_name ILIKE '%Sharang%' OR person_name ILIKE '%Boenisch%' OR person_name ILIKE '%Parnerkar%') ORDER BY sort_order`, [sid])
|
||||||
|
results.push(`${sc.name} founders: ${JSON.stringify(founders.map(f => ({name: f.person_name, start: f.start_date, brutto: f.brutto_monthly, m10: f.m10})))}`)
|
||||||
|
|
||||||
// Recompute
|
// Recompute
|
||||||
const r = await computeFinanzplan(pool, sid)
|
const r = await computeFinanzplan(pool, sid)
|
||||||
results.push(`${label}: cash_m60=${r.liquiditaet?.endstand?.m60}`)
|
results.push(`${sc.name}: cash_m60=${r.liquiditaet?.endstand?.m60}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({ ok: true, results })
|
return NextResponse.json({ ok: true, results })
|
||||||
|
|||||||
Reference in New Issue
Block a user