From 38d4ce4dec63c443af24cf85db2e8fa86ecdf87b Mon Sep 17 00:00:00 2001
From: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Date: Mon, 20 Jul 2026 17:36:39 +0200
Subject: [PATCH] fix(zeiterfassung): mark today, honest interim reports,
approver feedback
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Submitter side:
- Month grid now marks TODAY (Europe/Zurich) with a filled day-badge +
ring + aria-current; it was invisible before (focus sat on the 1st).
- Absence requests now confirm on submit ("Antrag eingereicht — wartet auf
Genehmigung") instead of silently clearing the form.
Monatsrapport:
- A running month reports AS OF today, not month-end — pre-filled future
days no longer show as "worked" and Soll/Ist/Saldo match the live
dashboard. Interim sheets are labelled "Zwischenstand per " and note
how many planned days are still excluded.
- Drop the internal "Aus offiziellem Standardschedule" marker from the
Bemerkung column so only real remarks show on the document.
Approver side:
- Single approve/reject/reopen/edit now show a positive acknowledgement in
the review drawer (was silent) and the drawer stays open on the just-acted
card — no more hunting for what you approved.
- Add a Monatsrapport link in the drawer (footer + after approval) — the
concrete next step for sending the sheet to the social worker.
Companion data fix applied on prod: Georgy's Pensum reconciled to the
Arbeitsplan (21h) and the unsourced −37h opening zeroed, so the saldo no
longer manufactures a deficit.
Co-Authored-By: Claude Fable 5
---
.../team/report/[userId]/[month]/page.tsx | 28 ++++++--
.../admin/timecards/TimecardReviewDrawer.tsx | 67 ++++++++++++++-----
src/components/timecards/TimeOffPanel.tsx | 9 ++-
.../timecards/TimecardMonthGrid.tsx | 39 ++++++++---
src/lib/services/report.ts | 22 +++++-
5 files changed, 129 insertions(+), 36 deletions(-)
diff --git a/src/app/admin/team/report/[userId]/[month]/page.tsx b/src/app/admin/team/report/[userId]/[month]/page.tsx
index de5ccddb6..eab6f691b 100644
--- a/src/app/admin/team/report/[userId]/[month]/page.tsx
+++ b/src/app/admin/team/report/[userId]/[month]/page.tsx
@@ -16,6 +16,7 @@ import { canAccessSection } from '@/lib/permissions'
import { getMonthlyReport, REPORT_MONTH_REGEX } from '@/lib/services/report'
import { getTimecardMonthLabel } from '@/lib/team/timecard-period-label'
import { getDisplayDate } from '@/lib/team/timecard-utils'
+import { SCHEDULE_FILL_DESCRIPTION } from '@/lib/team/schedule'
import { formatTimecardDuration, getTimecardEntryCategoryLabel, getTimecardStatusLabel, isAbsenceCategory } from '@/config/timecards'
import { ORG, LOCATIONS } from '@/config/org'
import { PrintButton } from './PrintButton'
@@ -45,7 +46,12 @@ export default async function MonthlyReportPage({
if (!report) notFound()
const monthLabel = getTimecardMonthLabel(`${month}-01`)
- const entries = report.card?.entries ?? []
+ // Only days up to the as-of date are "worked" — a running month must not
+ // present pre-filled future days as done (they'd also inflate the totals).
+ const allEntries = report.card?.entries ?? []
+ const entries = allEntries.filter(e => e.work_date <= report.asOfDate)
+ const futureCount = allEntries.length - entries.length
+ const asOfLabel = getDisplayDate(report.asOfDate)
const workedMinutes = entries.filter(e => !isAbsenceCategory(e.category)).reduce((s, e) => s + e.duration_minutes, 0)
const absenceMinutes = entries.filter(e => isAbsenceCategory(e.category)).reduce((s, e) => s + e.duration_minutes, 0)
const absenceDaysByCategory = new Map()
@@ -72,6 +78,11 @@ export default async function MonthlyReportPage({
Monatsrapport Arbeitszeit — {monthLabel}
+ {report.isInterim && (
+
+ Zwischenstand per {asOfLabel} — der Monat läuft noch; Zahlen bis zu diesem Tag.
+
+ )}
{/* Person + status */}
@@ -88,15 +99,15 @@ export default async function MonthlyReportPage({
{/* Summary */}
-
Soll (Monat)
+
Soll {report.isInterim ? `(bis ${asOfLabel})` : '(Monat)'}
diff --git a/src/components/timecards/TimecardMonthGrid.tsx b/src/components/timecards/TimecardMonthGrid.tsx
index 0032d666b..05671e8b7 100644
--- a/src/components/timecards/TimecardMonthGrid.tsx
+++ b/src/components/timecards/TimecardMonthGrid.tsx
@@ -106,6 +106,10 @@ export function TimecardMonthGrid({
return d === 0 ? 6 : d - 1
})()
+ // "Today" in Europe/Zurich (server saldo uses the same tz) — so the grid
+ // marks the real current day, not a UTC-shifted one near midnight.
+ const todayIso = new Intl.DateTimeFormat('en-CA', { timeZone: 'Europe/Zurich' }).format(new Date())
+
return (
{isSelected && (
@@ -204,14 +212,23 @@ export function TimecardMonthGrid({
)}
-
- {String(dayNum).padStart(2, '0')}
-
+ {isToday ? (
+
+
+ {String(dayNum).padStart(2, '0')}
+
+ {t('today')}
+
+ ) : (
+
+ {String(dayNum).padStart(2, '0')}
+
+ )}
{absence ? (
{entryCategoryLabel}
diff --git a/src/lib/services/report.ts b/src/lib/services/report.ts
index 4ab4aeb50..9128c4041 100644
--- a/src/lib/services/report.ts
+++ b/src/lib/services/report.ts
@@ -20,6 +20,12 @@ export interface MonthlyReport {
reviewerName: string | null
saldo: PersonSaldo | null
holidays: { date: string; name: string }[]
+ /** The date the figures are computed through (month-end, or today if the
+ * month is still running). Entries after this are not yet "worked". */
+ asOfDate: string
+ /** True while the month is still in progress — the sheet is a Zwischenstand,
+ * not a final record, and must not present future days as done. */
+ isInterim: boolean
}
function lastDayOfMonth(month: string): string {
@@ -28,6 +34,10 @@ function lastDayOfMonth(month: string): string {
return d.toISOString().slice(0, 10)
}
+function todayIsoZurich(): string {
+ return new Intl.DateTimeFormat('en-CA', { timeZone: 'Europe/Zurich' }).format(new Date())
+}
+
export async function getMonthlyReport(userId: string, month: string): Promise {
const [user] = await db
.select({ name: users.name, email: users.email })
@@ -66,8 +76,14 @@ export async function getMonthlyReport(userId: string, month: string): Promise null)
+ // A finished month reports its closing state (month-end). A month still in
+ // progress reports as of today — otherwise pre-filled future days would show
+ // as "worked" and the Soll/Ist/Saldo would diverge from the live dashboard.
+ const monthEnd = lastDayOfMonth(month)
+ const today = todayIsoZurich()
+ const asOfDate = today < monthEnd ? today : monthEnd
+ const isInterim = asOfDate < monthEnd
+ const saldo = await getPersonSaldo(userId, asOfDate).catch(() => null)
const year = Number(month.slice(0, 4))
const holidays = getPublicHolidays(year).filter(h => h.date.startsWith(month))
@@ -84,6 +100,8 @@ export async function getMonthlyReport(userId: string, month: string): Promise