KI-AGENT: Beleg-Relationswerte vor dem Speichern normalisieren
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 17s
Build and Push Docker Images / build-frontend (push) Successful in 51s
Build and Push Docker Images / build-docs (push) Successful in 11s

This commit is contained in:
2026-05-19 16:53:53 +02:00
parent 9cde630562
commit 6455be81bd
2 changed files with 28 additions and 14 deletions

View File

@@ -936,7 +936,16 @@ export default async function resourceRoutes(server: FastifyInstance) {
const normalizeDate = (val: any) => { const d = new Date(val); return isNaN(d.getTime()) ? null : d; }
Object.keys(createData).forEach((key) => {
if (key.toLowerCase().includes("date") && key !== "deliveryDateType") createData[key] = normalizeDate(createData[key])
const value = createData[key]
const shouldNormalize =
isDateLikeField(key) &&
value !== null &&
value !== undefined &&
(typeof value === "string" || typeof value === "number" || value instanceof Date)
if (shouldNormalize) {
createData[key] = normalizeDate(value)
}
})
const [created] = await server.db.insert(table).values(createData).returning()