Skip to content

Enforce Clustox Leave Policy v1.3 rules on leave applications - #18

Open
hamad-clustox wants to merge 1 commit into
developfrom
feature/leave-rule-enforcement
Open

hamad-clustox wants to merge 1 commit into
developfrom
feature/leave-rule-enforcement

Conversation

@hamad-clustox

Copy link
Copy Markdown
Collaborator

What

Server-side enforcement of the leave rules from Leave Policy v1.3 that Frappe doesn't enforce natively — a new hrms/leave_rules.py module wired through hooks.py doc_events on Leave Application and Leave Allocation.

Rules enforced (on /hrms PWA, desk, and API alike)

  • Advance notice — Annual (3 days for ≤2 days off, 30 for longer), Religious 15, Marriage 45, Hajj 60. Same-day / backdated requests are exempt as emergencies.
  • Gender — Maternity = Female, Paternity = Male.
  • Hajj/Umrah — once per employment.
  • Probation (first 90 days) — Casual blocked, Sick capped at 2.
  • Notice period — no leave once relieving_date is set.
  • Casual — cannot be combined with another leave or an adjacent holiday.
  • Sandwich leave — leave immediately before and after a holiday is blocked.
  • Medical proof — attachment required for Sick Leave over 2 days (before_submit).
  • Compensatory Off — allocation expires 30 days after it is earned.

Enforcement = hard block, but HR Manager / HR User / System Manager / Administrator override (for approved exceptions / emergencies).

Verification

17 in-memory cases exercised before activation on the test server (notice, gender, once, emergency exemption, medical-proof-on-submit, override bypass, comp-off cap) — all passed. Now live.

Notes

  • Depends on real reporting lines / holiday list for the routing-dependent parts (both now in place on the test server).
  • hooks.py edit touches only the doc_events dict; independent of Per-user app landing (supersedes #14) #17's role_home_page edit (different region), so they merge cleanly.
  • Deferred (separate work): "missing application → absent → deduction" attendance/payroll automation, and a Long-Service 5-vs-10 tier allocation helper.

🤖 Generated with Claude Code

…tions

Server-side validations (hrms/leave_rules.py, wired via hooks.py doc_events)
that Frappe does not enforce natively:

- advance notice (Annual 3/30, Religious 15, Marriage 45, Hajj 60); same-day
  and backdated requests are exempt as emergencies
- gender restriction (Maternity = Female, Paternity = Male)
- Hajj/Umrah once per employment
- probation (first 90 days): Casual blocked, Sick capped at 2
- no leave during the notice / resignation period
- Casual cannot be combined with another leave or an adjacent holiday
- sandwich leave (leave immediately before AND after a holiday) blocked
- medical proof (attachment) required for Sick Leave over 2 days
- Compensatory Off expires 1 month after it is earned

Hard block, but HR Manager / HR User / System Manager / Administrator override.
Verified with 17 in-memory cases before activating on the test server.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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