chore: diagnose Umsatzerlöse on production
Some checks failed
Build pitch-deck / build-push-deploy (push) Successful in 1m15s
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 36s
CI / test-python-voice (push) Successful in 34s
CI / test-bqas (push) Has been cancelled
Some checks failed
Build pitch-deck / build-push-deploy (push) Successful in 1m15s
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 36s
CI / test-python-voice (push) Successful in 34s
CI / test-bqas (push) Has been cancelled
This commit is contained in:
@@ -4,28 +4,34 @@ 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[] = []
|
|
||||||
|
|
||||||
// Delete duplicate Pos 10 Rechtsanwalt
|
// Diagnose
|
||||||
const { rowCount: d1 } = await pool.query(
|
const { rows: guv } = await pool.query(
|
||||||
`DELETE FROM fp_personalkosten WHERE scenario_id = $1 AND sort_order = 10`, [WD])
|
`SELECT row_label, values FROM fp_guv WHERE scenario_id = $1 AND row_label ILIKE '%Umsatz%'`, [WD])
|
||||||
results.push(`DEL pos 10: ${d1}`)
|
const { rows: liq } = await pool.query(
|
||||||
|
`SELECT row_label, values FROM fp_liquiditaet WHERE scenario_id = $1 AND row_label ILIKE '%Umsatz%' AND row_label NOT LIKE '%steuer%'`, [WD])
|
||||||
|
const { rows: rev } = await pool.query(
|
||||||
|
`SELECT row_label, section, values FROM fp_umsatzerloese WHERE scenario_id = $1 AND row_label = 'GESAMTUMSATZ'`, [WD])
|
||||||
|
const { rows: qty } = await pool.query(
|
||||||
|
`SELECT row_label, section, (values->>'m12')::numeric as m12, (values->>'m24')::numeric as m24 FROM fp_umsatzerloese WHERE scenario_id = $1 AND section = 'quantity' ORDER BY row_label`, [WD])
|
||||||
|
|
||||||
// Fix umlauts in person names + positions across ALL scenarios
|
// Recompute
|
||||||
const nameFixSql = [
|
|
||||||
"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)
|
||||||
results.push(`WD cash_m60=${r.liquiditaet?.endstand?.m60}`)
|
|
||||||
|
|
||||||
return NextResponse.json({ ok: true, results })
|
// Re-check after compute
|
||||||
|
const { rows: guvAfter } = await pool.query(
|
||||||
|
`SELECT row_label, (values->>'y2026')::numeric as y2026, (values->>'y2027')::numeric as y2027 FROM fp_guv WHERE scenario_id = $1 AND row_label ILIKE '%Umsatz%'`, [WD])
|
||||||
|
const { rows: liqAfter } = await pool.query(
|
||||||
|
`SELECT row_label, (values->>'m12')::numeric as m12, (values->>'m24')::numeric as m24 FROM fp_liquiditaet WHERE scenario_id = $1 AND row_label = 'Umsatzerlöse'`, [WD])
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
before: {
|
||||||
|
guv: guv.map(r => ({ label: r.row_label, y2026: r.values?.y2026, y2027: r.values?.y2027 })),
|
||||||
|
liq: liq.map(r => ({ label: r.row_label, m12: r.values?.m12, m24: r.values?.m24 })),
|
||||||
|
gesamtumsatz: rev.map(r => ({ m12: r.values?.m12, m24: r.values?.m24 })),
|
||||||
|
quantities: qty,
|
||||||
|
},
|
||||||
|
after: { guv: guvAfter, liq: liqAfter },
|
||||||
|
cash_m60: r.liquiditaet?.endstand?.m60,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user