Vertragstypen für Änderungsanfragen pflegen

This commit is contained in:
2026-05-08 20:09:24 +02:00
parent 6a5c1e844d
commit d7eced3e77
6 changed files with 67 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ async function getPortalContract(server: FastifyInstance, req: any, contractId:
tenant: contracts.tenant,
customer: contracts.customer,
contracttype: contracts.contracttype,
allowedContracttypes: contracts.allowedContracttypes,
archived: contracts.archived,
})
.from(contracts)
@@ -121,6 +122,14 @@ export default async function portalContractRoutes(server: FastifyInstance) {
return reply.code(400).send({ error: "Ungültiger Vertragstyp" })
}
const allowedContracttypes = Array.isArray(contract.allowedContracttypes)
? contract.allowedContracttypes.map((id) => Number(id)).filter((id) => Number.isInteger(id))
: []
if (!allowedContracttypes.includes(requestedContracttype.id)) {
return reply.code(400).send({ error: "Dieser Vertragstyp steht für diesen Vertrag nicht zur Auswahl" })
}
const [currentContracttype] = contract.contracttype
? await server.db
.select({