Implement PayRuleSet and BreakPolicy with nested entity persistence#1339
Implement PayRuleSet and BreakPolicy with nested entity persistence#1339
Conversation
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…s successfully Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
renemadsen
left a comment
There was a problem hiding this comment.
@copilot Stick to our codebase and you can reference https://github.com/microting/eform-timeplanning-base for the entities
There was a problem hiding this comment.
@copilot We should not include using BackendConfiguration.Pn.Integration.Test; since it's not in our codebase
There was a problem hiding this comment.
Fixed in commit 68fe2a7. Changed TestBaseSetup namespace to TimePlanning.Pn.Test and removed the BackendConfiguration.Pn.Integration.Test using statement from all test files (9 files updated).
…usage Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Acknowledged. The implementation references entities from Microting.TimePlanningBase v10.0.15 NuGet package. The namespace issue has been fixed in commit 68fe2a7 - all tests now use TimePlanning.Pn.Test namespace consistently with the codebase. |
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…ames (dayOfWeek, paidBreakMinutes, unpaidBreakMinutes) Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…ot Seconds - all tests pass Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…atch backend API Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…ter separately Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…nd API Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Summary
Implements complete CRUD operations for PayRuleSet and BreakPolicy modules with nested entity persistence. Both modules support creating, updating, and deleting nested rules while maintaining database schema alignment.
Schema Alignment
PayRuleSet
dayOfWeek: number→dayCode: string(SUNDAY, MONDAY, etc.)upToSeconds)BreakPolicy
*Seconds→*Minutesto match database schemadayOfWeek: number,paidBreakMinutes,unpaidBreakMinutesJSON Deserialization
All model ID fields changed from
inttoint?to accept Angular's"id": nullfor new entities:UpdateModels no longer include ID property - passed as URL parameter only:
Nested Entity Persistence
Services now handle complete nested entity lifecycle:
Controller Tests
Added JSON deserialization validation tests (8 tests total):
TypeScript Alignment
Fixed property name consistency across models, services, and components:
BreakPolicyModel.rules→breakPolicyRules(matches API response)Files Modified
Backend (13 files)
Frontend (19 files)
Original prompt
This section details on the original issue you should resolve
<issue_title>🚀 Feature: Extend Rule Engine for Advanced Overtime & Holiday Logic (Non‑Breaking + API CRUD + Tests)</issue_title>
<issue_description>## 🎯 Goal
Implement advanced rule resolution logic using the updated database model without breaking any existing behavior.
This issue covers engine logic + API controllers/services + integration tests.
Database schema changes are handled separately.
Key principles (must-follow)
🤖 GitHub Copilot Implementation Workflow (required)
0) Analyze first
Before writing code, Copilot must:
PlanRegistrationPayLines, existing pay code rules).1) Write a plan
Copilot must produce a short plan in the PR/commit message or as a comment in the issue describing:
2) Implement in steps (each step must be green)
For each step:
dotnet buildand all tests🧮 Engine Implementation Tasks
1️⃣ Overtime Calculation (non-breaking)
Add support for:
Use new fields from
WorkingTimeRuleSets:OvertimePeriodLengthDaysOvertimeAveragingWindowDaysMonthlyNormModeOvertimeAllocationStrategyBackward compatibility rules
OvertimeBasisindicates it AND required parameters are present (or safe defaults are explicitly defined).2️⃣ Overtime Allocation Strategies
Implement allocation strategies:
LatestFirstEarliestFirstProportionalBackward compatibility rules
3️⃣ Day-Type Resolution + Time-Bands (non-breaking)
Resolve day type:
Apply new rule tables:
PayDayTypeRulesPayTimeBandRulesBackward compatibility rules
PayDayTypeRulesexist for a ruleset → fall back to currentPayDayRules/PayTierRulesbehavior.4️⃣ Holiday Paid-Off Logic (non-breaking)
If employee does not work on public holiday:
Generate correct pay lines using configured pay codes.
Backward compatibility rules
HolidayPaidOffModeis default/None → preserve current holiday handling.5️⃣ 11-Hour Rest Rule
Use:
MinimumDailyRestSecondsFirstWorkStartUtcLastWorkEndUtcAdd deterministic violation detection logic.
(If existing logic exists, extend it; do not break current outputs.)
🌐 API: Controllers + Services (CRUD)
We need API endpoints and service layer for index + CRUD of the new rule entities so Angular frontend can be implemented later.
Entities requiring CRUD
PayRuleSets(existing)PayDayTypeRules(new)PayTimeBandRules(new)WorkingTimeRuleSets(existing, now extended)AssignedSiteRuleSetAssignments(new) — if repository includes employee rule assignment logicRequirements
GET /...list/index (paging optional)GET /.../{id}POST /...PUT /.../{id}DELETE /.../{id}(soft delete if your workflow state model requires it)🧪 Testing Requirements (must-have)
Integration tests (required for ALL controllers/services)
All controllers and services introduced/chan...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.