Vertragstypen für Änderungsanfragen pflegen
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user