This commit is contained in:
Moritz Utcke
2025-04-20 17:21:46 -04:00
parent f9555c7a1e
commit e21a829cb6
19 changed files with 350 additions and 233 deletions

View File

@@ -65,6 +65,9 @@ export const PUT = defineApiRoute({
const ausweis = await adapter.findUnique({
where: {
id: ausweis_id
},
include: {
rechnung: true
}
})
@@ -75,6 +78,13 @@ export const PUT = defineApiRoute({
});
}
if (ausweis.rechnung) {
throw new APIError({
code: "BAD_REQUEST",
message: "Eine Rechnung für diesen Ausweis existiert bereits.",
});
}
if (ausweis.benutzer_id !== user.id) {
throw new APIError({
code: "UNAUTHORIZED",