Use global ticket detail entrypoint

This commit is contained in:
michael committed 2026-09-01 11:06:36 +02:00
1 parent b67dbad0b1
commit 018c06dc3e
6 files changed
+94 -25

No files matched your search

+30
View File
@@ -2758,6 +2758,21 @@ app.post("/api/sessions", requireUser, async (req, res) => {
throw badRequest("endedAt must be after startedAt");
}
const monthClosureResult = await query<{ closed_at: string }>(
`
SELECT closed_at
FROM month_closures
WHERE month = date_trunc('month', $1::timestamptz AT TIME ZONE 'Europe/Berlin')::date
AND user_id = $2;
`,
[startedAt.toISOString(), user.id]
);
if (monthClosureResult.rows.length > 0) {
res.status(409).json({ error: "Monat ist abgeschlossen" });
return;
}
const roundedMinutes = Math.max(1, Math.round(durationSeconds / 60));
const created = await withTransaction(async (client) => {
const existingTicketResult = await client.query<{ id: string; organization_id: string | null; customer_name: string | null; work_type: string | null }>(
@@ -3035,6 +3050,21 @@ app.patch("/api/tickets/:ticketId/day-billings/:day", requireUser, async (req, r
const billedMinutes = parseOptionalBilledMinutes(req.body.billedMinutes);
const userId = currentUser(req).id;
const monthClosureResult = await query<{ closed_at: string }>(
`
SELECT closed_at
FROM month_closures
WHERE month = date_trunc('month', $1::date)::date
AND user_id = $2;
`,
[day.start, userId]
);
if (monthClosureResult.rows.length > 0) {
res.status(409).json({ error: "Monat ist abgeschlossen" });
return;
}
const sessionResult = await query<{ id: string }>(
`
SELECT id