All problems

Refund Window Time Boundary Calculation Error

Level 3 · node · Correctness · Date boundary calculation error

Scenario

An API allows refund requests for exactly seven days after an order is delivered. Most requests are handled correctly, but operations reports show that requests submitted late on the cutoff date can still be approved even after the actual seven-day limit has passed. The controller, service, policy, and repository are separated, and all timestamps are stored as ISO 8601 UTC strings.

Requirements

- The refund window is exactly 7×24 hours from deliveredAt - A request exactly at the cutoff timestamp is allowed - A request even one second after the cutoff returns 409 - Requests before the cutoff are approved normally - A nonexistent order returns 404

Acceptance criteria

  • A request one second before the cutoff is eligible for a refund
  • A request exactly at the cutoff timestamp is eligible for a refund
  • A request one second after the cutoff is rejected with 409
  • A late request on the cutoff calendar date is rejected when the actual seven-day limit has passed
  • A request for a nonexistent order returns 404