fix(rates): assertSellable honors validFrom, validTo, and isActive - #333
Merged
Conversation
CI fails when Vitest counts drift from README. This PR added seven assertSellable cases (1520 → 1527); refresh the badge and docs stats. Co-authored-by: telivity-otaip <telivity-otaip@users.noreply.github.com>
telivity-otaip
marked this pull request as ready for review
August 20, 2026 14:08
cursor Bot
pushed a commit
that referenced
this pull request
Aug 20, 2026
Simple badge/count conflicts after #333 landed on main. Re-synced to 1532 tests / 216 files (main’s assertSellable suite + property-id.spec). Co-authored-by: telivity-otaip <telivity-otaip@users.noreply.github.com>
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.
Fixes #331.
RatePlanService.assertSellable()was the BOOK write gate for PMS create, Connect book, and the booking engine, but it only inspected overlapping restriction rows. An inactive, future, or expired rate plan could still be sold.This PR loads the property-scoped plan (
ratePlanId+ caller-suppliedpropertyId) and rejects when:isActiveis falsecheckInis beforevalidFromcheckOut - 1 day) is aftervalidTovalidTois treated as the inclusive last consumed night. Checkout stays exclusive, which matches how HAIP already counts nights ([checkIn, checkOut)). The in-repo schema comments do not define a different boundary, andkb/HAIP_KNOWLEDGE_BASE.mdis not present in this tree.Restriction, LOS, CTA, and CTD behavior is unchanged. Search response shaping is unchanged.
Tests
apps/api/src/modules/rate-plan/assert-sellable.spec.tsnow uses a table-aware database double and covers:validTo)validFromlower boundvalidTo