fix: negative PMS (práce mimo směnu) hours count in FPD totals
Web FPD check: PMS hours keep their sign (getPmsHours) instead of being dropped when negative. Month Excel FPD column: PMS was not counted at all; it now adds the signed PMS hours like the web. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,17 @@ def czech_holidays(year):
|
|||||||
return out
|
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):
|
def hours_for(value):
|
||||||
"""Match webapp's getHoursForValue (FpdCheck.tsx):
|
"""Match webapp's getHoursForValue (FpdCheck.tsx):
|
||||||
A and B count as 12 hours; numeric values as themselves;
|
A and B count as 12 hours; numeric values as themselves;
|
||||||
@@ -463,6 +474,10 @@ def main():
|
|||||||
collect(cd.get('nightValue'), is_workday)
|
collect(cd.get('nightValue'), is_workday)
|
||||||
else:
|
else:
|
||||||
collect(cd.get('v'), is_workday)
|
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
|
person_fpd = month_fpd - vacation
|
||||||
diff = worked - person_fpd
|
diff = worked - person_fpd
|
||||||
dst = ws.cell(row, 72)
|
dst = ws.cell(row, 72)
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ interface FpdResult {
|
|||||||
infoOnly: boolean // contractor — never warn on shortfall
|
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 {
|
function getHoursForValue(v: string): number {
|
||||||
if (v === 'A' || v === 'B') return 12
|
if (v === 'A' || v === 'B') return 12
|
||||||
const num = parseFloat(v)
|
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.
|
// 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
|
const pms = person.data[String(-month)]?.v
|
||||||
if (pms) workedHours += getHoursForValue(pms)
|
if (pms) workedHours += getPmsHours(pms)
|
||||||
const personFpd = workDays * dailyHours - vacationHours
|
const personFpd = workDays * dailyHours - vacationHours
|
||||||
const diff = workedHours - personFpd
|
const diff = workedHours - personFpd
|
||||||
results.push({
|
results.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user