Skip to content

US-313: Leave Request Cancellation

1. Story Title

Cancel pending leave request and restore balance

2. Context / Background

Enhances leave lifecycle by allowing employees to retract requests before approval/start.

3. User Persona

Primary: Mark – Employee Secondary: Manager (receives cancellation notification)

4. Problem Statement

Without cancellation, employees require HR intervention for changes causing manual adjustments.

5. Desired Outcome

Employee cancels a Pending request prior to start date; balance restored; events logged; manager notified.

6. Business Value

Reduces HR workload; ensures balance accuracy; improves UX flexibility.

7. Scope (In / Out)

In: cancel endpoint, validation (status & date), balance restoration, notification event. Out: Cancellation after partial consumption, multi-level approval retraction.

8. Acceptance Criteria (BDD)

Scenario: Cancel pending request
  Given a pending leave request starting next week
  When employee cancels
  Then request status becomes Cancelled
  And balance is restored

Scenario: Cancel after start date blocked
  Given request start date is today
  When employee attempts cancel
  Then error shown

Scenario: Manager notified
  Given cancellation occurs
  When processing completes
  Then manager receives notification event

Scenario: Already cancelled prevented
  Given request status Cancelled
  When cancel endpoint called
  Then idempotent no-op response

9. UX Notes / References

Cancel button on request detail view; confirmation modal with warning.

10. Data / Domain Model Impact

LeaveRequest add status Cancelled; balance restoration logic.

11. NFR Touchpoints

  • Performance: cancel operation < 300ms.
  • Observability: LeaveCancelled event, balance change audit.
  • Security: self-cancel only.

12. Dependencies

Existing leave request & balance models (US-312); notification adapter.

13. Risks & Mitigations

Risk Impact Probability Mitigation
Race with accrual adjustments Incorrect balance Low Transactional update + locking
Spam cancel actions Noise in notifications Low Idempotent guard + cooldown (later)

14. Estimation Support

  1. Status transition validation
  2. Balance restoration
  3. Event emission
  4. UI action

15. Analytics / Success Metrics

Cancellation rate; time between request and cancellation.

16. Rollout / Release Strategy

Enable universally; monitor for abuse patterns.

17. Definition of Ready Checklist

  • Cancel eligibility rules agreed

18. Definition of Done Checklist

  • Scenario tests pass
  • Events visible
  • Docs updated

19. Open Questions

  1. Allow manager-driven cancellation?
  2. Need cancellation reason capture?

Version: 1.0