From 03e830f97b37fb198c39d5ff86c8d3c7d699e4b5 Mon Sep 17 00:00:00 2001 From: BOHA Date: Tue, 24 Mar 2026 19:14:28 +0100 Subject: [PATCH] fix: monthly cards and table show same +/- using prorated fund for current month Backend: per-user missing/overtime in current month now calculated against bizDaysToDate (working days up to today), not full month. Frontend: monthly card percentage and fulfilled check also use fund_to_date for current month. Now both the yearly summary table and the monthly cards agree. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/admin/pages/AttendanceBalances.tsx | 5 +++-- src/services/attendance.service.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/admin/pages/AttendanceBalances.tsx b/src/admin/pages/AttendanceBalances.tsx index 36db791..82a7db3 100644 --- a/src/admin/pages/AttendanceBalances.tsx +++ b/src/admin/pages/AttendanceBalances.tsx @@ -458,8 +458,9 @@ export default function AttendanceBalances() { {fundData.users && fundData.users.map(user => { const us = monthData.users?.[String(user.id)] if (!us) return null - const pct = monthData.fund > 0 ? Math.min(100, (us.covered / monthData.fund) * 100) : 0 - const isFulfilled = us.covered >= monthData.fund + const effectiveFund = (monthData as any).fund_to_date ?? monthData.fund + const pct = effectiveFund > 0 ? Math.min(100, (us.covered / effectiveFund) * 100) : 0 + const isFulfilled = us.covered >= effectiveFund return (
diff --git a/src/services/attendance.service.ts b/src/services/attendance.service.ts index feafb81..0323081 100644 --- a/src/services/attendance.service.ts +++ b/src/services/attendance.service.ts @@ -406,7 +406,7 @@ export async function getWorkfund(year: number) { } } - const userFund = Math.max(0, (bizDays - holidayDays) * 8); + const userFund = Math.max(0, (bizDaysToDate - holidayDays) * 8); const workedRound = Math.round(worked * 10) / 10; const leaveHours = vacationHours + sickHours; const covered = Math.round((worked + leaveHours) * 10) / 10;