diff --git a/web/export_full_excel.py b/web/export_full_excel.py index 68b5e75..7a06964 100644 --- a/web/export_full_excel.py +++ b/web/export_full_excel.py @@ -87,6 +87,17 @@ def czech_holidays(year): return out +def pms_hours(value): + """PMS (práce mimo směnu) hours — like hours_for, but negative values keep + their sign (hours taken off). Matches getPmsHours in FpdCheck.tsx.""" + if value in ('A', 'B'): + return 12 + try: + return float(value) + except (ValueError, TypeError): + return 0 + + def hours_for(value): """Match webapp's getHoursForValue (FpdCheck.tsx): A and B count as 12 hours; numeric values as themselves; @@ -463,6 +474,10 @@ def main(): collect(cd.get('nightValue'), is_workday) else: collect(cd.get('v'), is_workday) + # PMS (práce mimo směnu) counts as worked hours, positive or negative (as in FpdCheck.tsx) + pms_v = (person['data'].get(str(-month)) or {}).get('v') + if pms_v: + worked += pms_hours(pms_v) person_fpd = month_fpd - vacation diff = worked - person_fpd dst = ws.cell(row, 72) diff --git a/web/src/FpdCheck.tsx b/web/src/FpdCheck.tsx index 61681f1..185f11b 100644 --- a/web/src/FpdCheck.tsx +++ b/web/src/FpdCheck.tsx @@ -23,6 +23,12 @@ interface FpdResult { infoOnly: boolean // contractor — never warn on shortfall } +function getPmsHours(v: string): number { + if (v === 'A' || v === 'B') return 12 + const num = parseFloat(v) + return isNaN(num) ? 0 : num +} + function getHoursForValue(v: string): number { if (v === 'A' || v === 'B') return 12 const num = parseFloat(v) @@ -81,8 +87,9 @@ export function computeFpd( } } // PMS (práce mimo směnu) is stored at day-index -month; counts as worked hours. + // Unlike day cells it may be negative (hours taken off), so keep the sign. const pms = person.data[String(-month)]?.v - if (pms) workedHours += getHoursForValue(pms) + if (pms) workedHours += getPmsHours(pms) const personFpd = workDays * dailyHours - vacationHours const diff = workedHours - personFpd results.push({