Skip to content

fix(excel-export): restore Normal/Sunday/Saturday hour columns in all-workers total sheet#1584

Merged
renemadsen merged 3 commits into
stablefrom
feat/restore-total-sheet-hour-columns
May 22, 2026
Merged

fix(excel-export): restore Normal/Sunday/Saturday hour columns in all-workers total sheet#1584
renemadsen merged 3 commits into
stablefrom
feat/restore-total-sheet-hour-columns

Conversation

@renemadsen
Copy link
Copy Markdown
Member

Summary

  • Commit ce4e33fa replaced the hardcoded Normal_Hours / Hours_Sunday / Hours_Saturday columns in the all-workers Excel Total sheet with the new dynamic pay-code columns, but those three columns should have been kept alongside the new ones — not removed.
  • Restores the three header columns in GenerateAllWorkersExcelDashboard and recomputes the per-worker normalHours, sumHoursSundayAndHoliday (Grundlovsdag only counts after 12:00), and sumHoursSaturday against the cached timePlannings so the totalRow matches the headers.
  • Dynamic per-pay-code columns added in ce4e33fa are preserved and continue to be appended after the restored fixed columns.

Test plan

  • Build the plugin solution (dotnet build TimePlanning.Pn.csproj) — verified clean locally (0 errors)
  • Trigger /working-hours/reports/file-all-workers export and confirm the Total sheet shows the three restored columns populated with the expected values
  • Confirm dynamic pay-code columns from a configured PayRuleSet still render after the restored columns
  • Confirm Grundlovsdag falls into Sunday/holiday hours only for hours after 12:00

🤖 Generated with Claude Code

…-workers total sheet

Commit ce4e33f replaced the hardcoded Normal_Hours / Hours_Sunday / Hours_Saturday
columns in the Total sheet with dynamic pay-code columns, but those three columns
should have been kept alongside the new dynamic columns — not removed.

Restores in TimePlanningWorkingHoursService.GenerateAllWorkersExcelDashboard:
- Normal_Hours / Hours_Sunday header columns after SumFlexStart
- Hours_Saturday header column after Message
- Per-worker totalRow now computes and writes:
  * sumHoursSundayAndHoliday (Sunday + holiday hours, Grundlovsdag only after 12:00)
  * normalHours = siteTotalNettoHours - sumHoursSundayAndHoliday
  * sumHoursSaturday = Saturday NettoHours sum
- Dynamic per-pay-code columns continue to be appended afterwards (unchanged).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 07:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the fixed hour-bucket columns (Normal / Sunday+Holiday / Saturday) in the “Total” sheet of the all-workers Excel export while keeping the dynamic per-pay-code columns introduced previously.

Changes:

  • Reintroduced Normal_Hours, Hours_Sunday, and Hours_Saturday headers in the Total sheet.
  • Added per-worker computations for normal hours, Sunday/holiday hours (with Grundlovsdag counting only after 12:00), and Saturday hours, and appended them to the Total row output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3324 to +3338
// Sunday + holiday hours (Grundlovsdag only counts hours after 12:00)
var sumHoursSundayAndHoliday = 0.0;
foreach (var day in timePlannings)
{
var isSundayOrHoliday = day.IsSunday || PlanRegistrationHelper.IsOfficialHoliday(day.Date);
if (!isSundayOrHoliday) continue;

sumHoursSundayAndHoliday += PlanRegistrationHelper.IsGrundlovsdag(day.Date)
? CalculateHoursAfterNoon(day)
: day.NettoHours;
}
var normalHours = siteTotalNettoHours - sumHoursSundayAndHoliday;
var sumHoursSaturday = timePlannings.Where(x => x.IsSaturday).Sum(x => x.NettoHours);

totalRow.Append(CreateNumericCell(normalHours));
renemadsen and others added 2 commits May 22, 2026 09:59
…uage

GenerateExcelDashboard(all-workers) never set Thread.CurrentUICulture (unlike the
single-worker version at line ~2375), so Translations.X static properties — which
resolve via ResourceManager + CurrentUICulture — fell back to the default culture
(English) for the entire request. The downstream `localizationService.GetString(Translations.X)`
chain then could not recover Danish headers for resx keys whose name differs from
the English value (PlanHours, NettoHours, SumFlexStart, Hours_Sunday, etc.).

Loads the user's language at the top of the function and assigns CurrentUICulture
to it (mirroring the single-worker path); removes the now-redundant later language
load. No resx changes needed — all keys already have Danish translations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Some customer DBs have stale Message rows where translations diverged from the
canonical seed values. The clearest example reported in the field is id=11
VacationDayOff stored as DaName='Ferie fridag' / DeName='Ferie fridag Tag' /
EnName='Vacation day off' instead of the correct Afspadsering / Freizeit / Time off.

The existing seed only INSERTed missing rows by Name and never UPDATEd divergent
ones, so once a customer DB had a wrong row it stayed wrong. This adds a self-heal
pass that, on every plugin startup, updates each Message row whose DaName, EnName,
or DeName differs from the corresponding entry in TimePlanningSeedMessages.

The seed file is the source of truth for these system messages; mirrors the
existing permissions update pattern in the same file (lines 79-89).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@renemadsen renemadsen merged commit c48b0b6 into stable May 22, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants