Mission ID: P-ZERO Status: Active Context: Legacy Core System
You have inherited a discount calculation utility. The code works mathematically, but the previous engineer was fired for causing database locks during maintenance windows.
Your job is to fix the logic in src/engine.js to adhere to the strict Business Rules below.
- Standard Logic: Apply the percentage discount to the base price.
- Input Validation: Price must be non-negative.
- ⛔ CRITICAL LEGACY CONSTRAINT:
Due to a database lock on the
Orderstable every Tuesday (UTC), NO DISCOUNTS can be applied on Tuesdays.- If today is Tuesday (UTC), the function must return the original price (0% discount).
- Failing to handle this crashes the production ledger.
- Fork this repository.
- Run
npm install. - Run
npm test(Notice it fails on "Gate 3"). - Modify
src/engine.jsto handle the Tuesday logic. - DO NOT modify
tests/. - Submit a PR when all tests pass.
IMPORTANT: When submitting your PR, you MUST check the box: [x] I accept the Codeijoe Liability Waiver in your description, otherwise the review will be blocked.