Logbuch Überarbeitung
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 29s
Build and Push Docker Images / build-frontend (push) Successful in 16s

This commit is contained in:
2026-02-15 20:43:01 +01:00
parent cb4917c536
commit db4e9612a0
4 changed files with 259 additions and 11 deletions

View File

@@ -17,6 +17,7 @@ export async function insertHistoryItem(
const textMap = {
created: `Neuer Eintrag in ${params.entity} erstellt`,
updated: `Eintrag in ${params.entity} geändert`,
unchanged: `Eintrag in ${params.entity} unverändert`,
archived: `Eintrag in ${params.entity} archiviert`,
deleted: `Eintrag in ${params.entity} gelöscht`
}
@@ -45,7 +46,9 @@ export async function insertHistoryItem(
trackingtrips: "trackingtrip",
createddocuments: "createddocument",
inventoryitemgroups: "inventoryitemgroup",
bankstatements: "bankstatement"
bankstatements: "bankstatement",
incominginvoices: "incomingInvoice",
files: "file",
}
const fkColumn = columnMap[params.entity]
@@ -54,14 +57,19 @@ export async function insertHistoryItem(
return
}
const stringifyHistoryValue = (value: any) => {
if (value === undefined || value === null) return null
return typeof value === "string" ? value : JSON.stringify(value)
}
const entry = {
tenant: params.tenant_id,
created_by: params.created_by,
createdBy: params.created_by,
text: params.text || textMap[params.action],
action: params.action,
[fkColumn]: params.entityId,
oldVal: params.oldVal ? JSON.stringify(params.oldVal) : null,
newVal: params.newVal ? JSON.stringify(params.newVal) : null
oldVal: stringifyHistoryValue(params.oldVal),
newVal: stringifyHistoryValue(params.newVal)
}
await server.db.insert(historyitems).values(entry as any)