import { NextResponse } from 'next/server'
import pool from '@/lib/db'

export async function POST() {
  const WD = 'c0000000-0000-0000-0000-000000000200'

  const { rows } = await pool.query(`
    SELECT row_label, row_type,
      (values->>'m12')::numeric as dec26,
      (values->>'m24')::numeric as dec27,
      (values->>'m60')::numeric as dec30
    FROM fp_liquiditaet WHERE scenario_id=$1
    AND (row_label ILIKE '%Summe%' OR row_label ILIKE '%Umsatz%' OR row_label ILIKE '%Ertr%' OR row_label ILIKE '%Förder%' OR row_label ILIKE '%Forschung%' OR row_label ILIKE '%LIQUIDIT%')
    ORDER BY sort_order
  `, [WD])

  return NextResponse.json({ rows })
}
