fix(deals): keep hot deals within the venue opening hours - #71
Merged
Merged
Conversation
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
force-pushed
the
fix/deal-ends-before-closing
branch
from
September 27, 2026 20:57
c39fc29 to
075e4f6
Compare
savikthk
enabled auto-merge (squash)
September 27, 2026 20:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
POSTandPATCH /api/v1/venue/dealsanswer422 deal_ends_after_closingwhenendsAtis 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:assertBeforeClosingincreateandupdate, usingnextClosingAtandisOpenAt.backend/src/http/routes/venue.ts,backend/src/http/schemas/deals.ts,openapi.yaml:deal_ends_after_closingdocumented forcreateDealandupdateDeal.backend/src/bot/venue/deals.ts,texts.ts: sale window, fitting durations, paused screen, recovery ondeal_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
npm run lint,npm run typecheckandnpm testpass locally (backend and frontend),npm run buildpasses.422 deal_ends_after_closing.does not offer closing time when the venue %s: thecloses in ten minutescase 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.disables discounts ... warns about a closed venue: now expects the explanation and a disabled "Опубликовать".