mirror of
https://github.com/Since-3/since3-portal.git
synced 2026-10-12 21:41:16 +00:00
see comments
This commit is contained in:
parent
0d1eb75127
commit
c7c7c47ad7
9 changed files with 65 additions and 18 deletions
|
|
@ -15,8 +15,13 @@ export async function GET(request: NextRequest) {
|
|||
const parsed = IdsSchema.safeParse(request.nextUrl.searchParams.getAll("id"))
|
||||
if (!parsed.success) return Response.json({ error: "Ungültige Auswahl." }, { status: 400 })
|
||||
|
||||
const invoices = await getInvoicesForPdf(parsed.data)
|
||||
const requestedIds = [...new Set(parsed.data)]
|
||||
const invoices = await getInvoicesForPdf(requestedIds)
|
||||
if (invoices.length === 0) return Response.json({ error: "Keine Rechnungen gefunden." }, { status: 404 })
|
||||
// RLS filtert unerlaubte/stornierte Rechnungen stillschweigend raus – dann lieber gar nichts liefern als ein unvollständiges ZIP.
|
||||
if (invoices.length !== requestedIds.length) {
|
||||
return Response.json({ error: "Nicht alle ausgewählten Rechnungen sind verfügbar." }, { status: 404 })
|
||||
}
|
||||
|
||||
if (invoices.length === 1) {
|
||||
const pdf = await renderInvoicePdf(invoices[0])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue