chore: fp-patch — delete dup Rechtsanwalt + fix name umlauts
All checks were successful
Build pitch-deck / build-push-deploy (push) Successful in 1m13s
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 32s
CI / test-bqas (push) Successful in 31s

This commit is contained in:
Benjamin Admin
2026-04-21 18:41:46 +02:00
parent 4c2a7574e4
commit 9a750eb2b1

View File

@@ -4,21 +4,28 @@ import { computeFinanzplan } from '@/lib/finanzplan/engine'
export async function POST() { export async function POST() {
const WD = 'c0000000-0000-0000-0000-000000000200' const WD = 'c0000000-0000-0000-0000-000000000200'
const results: string[] = []
// Check current state // Delete duplicate Pos 10 Rechtsanwalt
const { rows: before } = await pool.query( const { rowCount: d1 } = await pool.query(
`SELECT id, person_name, position, start_date FROM fp_personalkosten WHERE scenario_id = $1 ORDER BY sort_order`, [WD] `DELETE FROM fp_personalkosten WHERE scenario_id = $1 AND sort_order = 10`, [WD])
) results.push(`DEL pos 10: ${d1}`)
// Update ANY row with Datenschutz or Recht in position // Fix umlauts in person names + positions across ALL scenarios
const { rowCount } = await pool.query( const nameFixSql = [
`UPDATE fp_personalkosten SET start_date = '2030-01-01' WHERE scenario_id = $1 AND (position ILIKE '%Datenschutz%' OR position ILIKE '%Recht%Jurist%')`, [WD] "UPDATE fp_personalkosten SET person_name = REPLACE(person_name, 'Boenisch', 'Bönisch') WHERE person_name LIKE '%Boenisch%'",
) "UPDATE fp_personalkosten SET position = REPLACE(position, 'Geschaeftsfuehrer', 'Geschäftsführer') WHERE position LIKE '%Geschaeftsfuehrer%'",
"UPDATE fp_personalkosten SET position = REPLACE(position, 'Geschaefts', 'Geschäfts') WHERE position LIKE '%Geschaefts%'",
"UPDATE fp_personalkosten SET position = REPLACE(position, 'fuehrer', 'führer') WHERE position LIKE '%fuehrer%'",
]
for (const sql of nameFixSql) {
const { rowCount } = await pool.query(sql)
if (rowCount && rowCount > 0) results.push(`NAME FIX: ${rowCount}`)
}
// Recompute WD
const r = await computeFinanzplan(pool, WD) const r = await computeFinanzplan(pool, WD)
return NextResponse.json({ results.push(`WD cash_m60=${r.liquiditaet?.endstand?.m60}`)
updated: rowCount,
before: before.map(r => ({ pos: r.person_name, role: r.position, start: r.start_date })), return NextResponse.json({ ok: true, results })
cash_m60: r.liquiditaet?.endstand?.m60,
})
} }