Skip to content

fix(rates): assertSellable honors validFrom, validTo, and isActive - #333

Merged
telivity-otaip merged 2 commits into
mainfrom
cursor/fix-assert-sellable-validity-8b18
Aug 20, 2026
Merged

fix(rates): assertSellable honors validFrom, validTo, and isActive#333
telivity-otaip merged 2 commits into
mainfrom
cursor/fix-assert-sellable-validity-8b18

Conversation

@telivity-otaip

Copy link
Copy Markdown
Collaborator

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-supplied propertyId) and rejects when:

  • the plan is missing at that property
  • isActive is false
  • checkIn is before validFrom
  • the last consumed night (checkOut - 1 day) is after validTo

validTo is 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, and kb/HAIP_KNOWLEDGE_BASE.md is 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.ts now uses a table-aware database double and covers:

Open in Web Open in Cursor 

)

Load the property-scoped rate plan in the BOOK sellability gate and reject
inactive, not-yet-valid, or expired plans. validTo is the inclusive last
consumed night; checkout remains exclusive.

Co-authored-by: telivity-otaip <telivity-otaip@users.noreply.github.com>
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
telivity-otaip marked this pull request as ready for review August 20, 2026 14:08
@telivity-otaip
telivity-otaip merged commit bf6447b into main Aug 20, 2026
5 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(rates): assertSellable ignores validFrom and validTo

2 participants