-
Notifications
You must be signed in to change notification settings - Fork 0
[BE/UI] Business rule enforcement — deletion blocking and task unassignment (Phase 11) #437
Copy link
Copy link
Open
Milestone
Description
Phase 11 — Business Rule Enforcement
Implement business rule enforcement for deletion blocking and automatic task unassignment. This is split from #410 which covered the entire MVP Polish epic.
POL-10: Block Deletion of Properties/Units with Active Tasks
UI-level blocking:
- Delete button for a Unit must be disabled if the unit has any tasks with status Open or InProgress
- Disabled button shows tooltip: "Cannot delete unit with [N] active tasks. Complete or cancel them first."
- Delete button for a Property must be disabled if any unit in that property has active tasks
Backend-level enforcement:
- When a delete request is received for a unit or property with active tasks, return HTTP 409 Conflict:
{ "error": "ACTIVE_TASKS_EXIST", "message": "Cannot delete. [N] active task(s) must be resolved first.", "activeTaskCount": N } - App shows dialog: "Cannot delete. Resolve all active tasks first."
- Applies to both soft and hard deletes
POL-11: Auto-Unassign Open Tasks on Staff Removal
When a Staff member is removed from the org:
- Query all tasks:
assignee_id = removedUserId AND status IN ('Open', 'InProgress') - Set
assignee_id = NULLon all matching tasks - Create admin notification for each unassigned task
Must run within the same database transaction as the membership removal (no partial failure).
Unit test requirements:
- Remove staff with 3 open tasks: verify all 3 unassigned
- Remove staff with 0 open tasks: verify no side effects
- Remove staff with Completed/Cancelled tasks: verify those not modified
Dependencies
- [BE] TaskController + TaskService + TaskDatastore (Phase 0) #387 — Task API backend (for active task count query)
- [BE] Organization Membership API Contracts and Backend Services (Phase 0) #426 — Org Membership backend (removeMember side effect implementation point)
- [UI] Team Management and Pending Invites (Phase 10) #434 — Team Management screen (trigger point for staff removal in UI)
What type of task is this?
Development
Reactions are currently unavailable