Skip to content

feat: support shifts that cross midnight - #60

Merged
PPeitsch merged 1 commit into
mainfrom
feat/overnight-shifts
Oct 4, 2026
Merged

PPeitsch merged 1 commit into
mainfrom
feat/overnight-shifts

Conversation

@PPeitsch

@PPeitsch PPeitsch commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Description

Review finding C11: calculate_daily_hours gave negative hours for a shift that crosses midnight, and the validators rejected it, so there was no way to log a night shift.

Rule: a time range whose exit is earlier than its entry ends the next day, and its hours count for the day the shift started (22:00 - 06:00 is 8 hours).

  • calculate_daily_hours adds a day to a negative range.
  • validate_entries accepts that range only if it is the one that starts last (any later range would overlap it), and at most one per day. Equal entry and exit is now the invalid case ("Exit time must be different from entry time").
  • The import path uses the same validator, so an overnight record in a PDF/Excel is accepted too.
  • Day panel: a hint under the time ranges, and the worked preview counts overnight ranges.
  • Spanish catalog updated for the new messages.

Type of Change

  • New feature

Testing

  • New tests for the calculator and validator (overnight, order in the list, overlap after an overnight range, two overnight ranges). Four tests that used "exit before entry" as the invalid case now use equal times.
  • pytest (257 passed), black, isort, mypy clean.
  • Headless run against a demo database: 22:00 - 06:30 previews and saves as 8:30; two overnight ranges in one day return 400.

Screenshots

Day panel with a night shift (preview 8:30 and the new hint), and the calendar after saving.

Checklist

  • I have read the contributing guidelines
  • I have followed the project's code style (Black, isort, PEP 8)
  • My code generates no new warnings

@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
app/utils/time_calculator.py 100.00% <100.00%> (ø)
app/utils/validators.py 95.65% <100.00%> (+1.05%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PPeitsch
PPeitsch merged commit 8f181f1 into main Oct 4, 2026
3 checks passed
@PPeitsch
PPeitsch deleted the feat/overnight-shifts branch October 4, 2026 18:28
@PPeitsch PPeitsch mentioned this pull request Oct 4, 2026
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.

1 participant