Audience: Engineers. What this answers: the rule model, how stages are composed, and how recipients resolve.
Source:
CustomNotificationService.cs(402),AdminCustom_NotificationsService.cs(671), theCustomNotification*entities (TenantDb), andweb-app/.../approval-workflow/{CustomNotifications, NewCustomNotifications}.tsx, plus a live pass 2026-07-21.
CompanyId-scoped)CustomNotificationType (Description; grouped by module in UI)
CustomNotificationStage (Description: Creation/Approval/Rejection)
│
CustomNotification CustomNotificationTypeId, CustomNotificationStageId
└──< CustomNotificationEntity RoleId (recipients)
A CustomNotification is a single rule = one type × one stage; its CustomNotificationEntity children are the roles to notify. ViewCustomNotification is the read model.
CustomNotificationService derives the three stage-records per type by name concatenation (not a pure FK lookup):
var creationModel = GetByName($"{notificationType.Description} Creation", companyId);
var approvalModel = GetByName($"{notificationType.Description} Approval", companyId);
var rejectionModel = GetByName($"{notificationType.Description} Rejection", companyId);
So the stage identity is embedded in the record's Description as "{Type} {Stage}". The frontend mirrors this: STAGES = [{id:1,Creation},{id:2,Approval},{id:3,Rejection}], and getStageIdFromDescription parses the suffix back out.
Implication: the type↔stage linkage is string-coupled. Renaming a type, or a stage keyword, risks orphaning records whose
Descriptionno longer parses. Treat the"{Type} {Stage}"naming as a contract. (RFD-001)
GROUP_CONFIG in CustomNotifications.tsx buckets types by keyword into module headings — e.g. Payroll: ["payroll","expense","payment schedule"], plus Time & Attendance, HRIS, etc. This grouping is a presentation concern; the backend just has flat CustomNotificationType rows.
GetEntities)AdminCustom_NotificationsService.GetEntities builds the pickable recipients:
Role.PRIMARY_ADMIN, SECONDARY_ADMIN, PAYROLL_ADMIN, PAYROLL_REPORTS_AND_TAX_FILINGS_ADMIN, then string literals "Benefits Admin", "IT Admin", "Assets Admin", "Performance Admin", "Loans, Salary Advance and Tax Relief Admin", …MembershipService.GetRoleList(false) → each role.Name added with an incrementing id.The chosen recipients are stored as CustomNotificationEntity.RoleId rows against the rule.
Bug: the hardcoded block assigns ids 4, 5, and 6 all to
PAYROLL_REPORTS_AND_TAX_FILINGS_ADMIN(copy-paste), and a large//-commented block shows an in-progress rework. Recipient ids 4-6 are therefore unreliable. (RFD-002)