Skip to content

fix(deals): keep hot deals within the venue opening hours - #71

Merged
savikthk merged 1 commit into
mainfrom
fix/deal-ends-before-closing
Sep 27, 2026
Merged

savikthk merged 1 commit into
mainfrom
fix/deal-ends-before-closing

Conversation

@savikthk

Copy link
Copy Markdown
Collaborator

Closes #68

Summary

A hot deal can no longer run past the venue closing. The rule lives in the service, so the bot, the mini app and the HTTP API agree: POST and PATCH /api/v1/venue/deals answer 422 deal_ends_after_closing when endsAt is later than the nearest closing or the venue is closed now (rejected rather than cut, so the client knows the term was not accepted). A scheduled deal is checked against the closing after its start. Round the clock venues have no closing limit and hours past midnight work.

The wizard in the bot and the mini app offer "1 час" and "2 часа" only when they end before the closing, just "До закрытия, ЧЧ:ММ" in the last hour, and less than 15 minutes before the closing or while the venue is closed explain when a deal can be published instead of starting.

Changes

  • backend/src/services/deals.ts: assertBeforeClosing in create and update, using nextClosingAt and isOpenAt.
  • backend/src/http/routes/venue.ts, backend/src/http/schemas/deals.ts, openapi.yaml: deal_ends_after_closing documented for createDeal and updateDeal.
  • backend/src/bot/venue/deals.ts, texts.ts: sale window, fitting durations, paused screen, recovery on deal_ends_after_closing; the old closed venue warning is gone.
  • frontend/src/features/venue/dealModel.ts, DealScreens.tsx, frontend/src/api/messages.ts: the same window for creating and changing a deal, including "Другое время".
  • docs/scenario.md: step C7.

Testing

  • Tests added or updated for the change: service (closing, before opening, after closing, PATCH, scheduled deal, past midnight, round the clock), routes, bot, mini app.
  • npm run lint, npm run typecheck and npm test pass locally (backend and frontend), npm run build passes.
  • Manual, local API with demo data at 23:16 MSK: creating a deal in the closed «Зерно» answered 422 deal_ends_after_closing.
  • Tests changed on purpose:
    • does not offer closing time when the venue %s: the closes in ten minutes case pinned the defect and is rewritten; the round the clock case still offers 1 and 2 hours.
    • warns that guests cannot book while the venue is closed: deals can no longer be published while the venue is closed, including before opening.
    • needs an end in the future and within 24 hours: the accepted 24 hour deal moved to a round the clock venue.
    • Mini app disables discounts ... warns about a closed venue: now expects the explanation and a disabled "Опубликовать".

@savikthk savikthk added bug Something isn't working backend Сервер: API, сервисы, база данных frontend Мини-приложение MAX bot Чат-бот MAX labels Sep 27, 2026
@savikthk savikthk self-assigned this Sep 27, 2026
The deal wizard offered "1 час" and "2 часа" without looking at the
closing time and the service only checked the 24 hour window, so a deal
published at 21:48 in a venue closing at 22:00 ran until 22:50.

The service now rejects a deal that ends after the nearest closing or
starts while the venue is closed with 422 deal_ends_after_closing, for
POST and PATCH /api/v1/venue/deals alike. A scheduled deal is checked
against the closing after its start. Round the clock venues have no
closing limit and hours past midnight keep working.

The bot and the mini app show only the durations that end before the
closing, offer just "До закрытия" in the last hour, and less than 15
minutes before the closing or while the venue is closed explain when a
deal can be published instead of starting the wizard.
@savikthk
savikthk force-pushed the fix/deal-ends-before-closing branch from c39fc29 to 075e4f6 Compare September 27, 2026 20:57
@savikthk
savikthk enabled auto-merge (squash) September 27, 2026 20:57
@savikthk
savikthk merged commit d4ea0f7 into main Sep 27, 2026
5 checks passed
@savikthk
savikthk deleted the fix/deal-ends-before-closing branch September 27, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Сервер: API, сервисы, база данных bot Чат-бот MAX bug Something isn't working frontend Мини-приложение MAX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[B16] Горящее предложение можно выставить за пределами часов работы заведения

1 participant