Implement PayRuleSet CRUD with time-threshold tiers matching backend schema#1339
Implement PayRuleSet CRUD with time-threshold tiers matching backend schema#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
| using System; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using BackendConfiguration.Pn.Integration.Test; |
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>
… tiers with upToSeconds Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…s correctly 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>
…factoring complete! Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…with MatTableDataSource Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…er button works Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…tence Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
…e issue Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
Angular implementation used percentage-based tier allocation (
tierPercent: 70%) while backend schema expects time-threshold tiers (upToSeconds: 28800). Additionally, nested tier data wasn't persisting.Schema Alignment
Day identification:
dayOfWeek: number (0-6)→dayCode: string(SUNDAY, MONDAY, WEEKDAY, HOLIDAY, GRUNDLOVSDAG)Tier structure:
tierNumber,tierPercent,payCodeIdorder: int,upToSeconds: int?,payCode: stringUpdated components: PayDayRuleForm, PayDayRuleList, PayDayRuleDialog, Create/Edit modals.
UI Fixes
Add Tier button not working:
mat-tabledoesn't auto-detect FormArray changesMatTableDataSourcewith explicitupdateTable()callsFormControltype casting to prevent binding errorsForm validation:
markAsDirty()andupdateValueAndValidity()after FormArray modificationsData Persistence
Added missing
payTierRules: PayTierRuleModel[]toPayDayRuleModel. Tier data was being dropped during serialization.Diagnostics
Added console logging to create/edit flows for troubleshooting save issues (form validity, data structure, API responses).
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.