Skip to content

Online booking: consider session reserved numbers when assigning appointment numbers#20428

Open
OsaVS wants to merge 3 commits intodevelopmentfrom
channel-onlinebooking-save-reserved-number-check
Open

Online booking: consider session reserved numbers when assigning appointment numbers#20428
OsaVS wants to merge 3 commits intodevelopmentfrom
channel-onlinebooking-save-reserved-number-check

Conversation

@OsaVS
Copy link
Copy Markdown
Collaborator

@OsaVS OsaVS commented May 4, 2026

Issue: Previously, session reserved numbers could be assigned for online bookings.

Expected: Session reserved numbers should not be assigned for online bookings.

Files Changed:

  • ChannelService
  • ChannelBean

ChannelBean was modified to ensure reserved numbers are assigned when sessionInstances are created via ServiceSession.

getAllBillSessionSerialNumbersForSessionInstance(), method defined to get the BillSession's serialNo` directly.

Ensure that appointment number for online booking is not a reserved number.

ChannelService.saveBillItem() modified, because null pointer exception was caused as BIllItem Id generation was changed.

Summary by CodeRabbit

  • Bug Fixes

    • Appointment allocation now respects reserved appointment slots when creating session instances.
    • API booking availability excludes both already-used and explicitly reserved numbers to prevent conflicts.
  • Performance

    • Reduced database work for paid appointments by removing an unnecessary lookup, speeding up booking confirmation.

@OsaVS OsaVS requested a review from buddhika75 May 4, 2026 04:54
@OsaVS OsaVS self-assigned this May 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54bd3b71-2788-439c-aa46-f788bfb66c17

📥 Commits

Reviewing files that changed from the base of the PR and between e431ede and c34dd0e.

📒 Files selected for processing (1)
  • src/main/java/com/divudi/service/ChannelService.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/divudi/service/ChannelService.java

Walkthrough

Reserved appointment numbers are propagated from ServiceSession into created SessionInstance objects and integrated into appointment-number allocation and API booking availability calculations; DB-derived bill-session serials and session reserveNumbers are combined to determine released/next appointment numbers.

Changes

Reserved Appointment Numbers Flow

Layer / File(s) Summary
Data Propagation
src/main/java/com/divudi/ejb/ChannelBean.java
New newSs.setReserveNumbers(ss.getReserveNumbers()) call copies reserved numbers from the source ServiceSession into each created SessionInstance.
Allocation Logic
src/main/java/com/divudi/service/ChannelService.java (nextAvailableAppoinmentNumberForSession)
nextAvailableAppoinmentNumberForSession now parses session.getReserveNumbers() into a Set and advances nextNumber past any reserved values.
DB Extraction Helper
src/main/java/com/divudi/service/ChannelService.java (getAllBillSessionSerialNumbersForSessionInstance)
Added getAllBillSessionSerialNumbersForSessionInstance(SessionInstance) to query and return existing BillSession.serialNo values for a session instance.
API Booking Availability
src/main/java/com/divudi/service/ChannelService.java (getReleasedAppoinmentNumbersForApiBookings)
getReleasedAppoinmentNumbersForApiBookings signature changed to accept reservedNumbers; it now excludes DB serials plus provided reserved numbers when computing released appointment numbers.
Integration / Fallback
src/main/java/com/divudi/service/ChannelService.java (createBillSession)
createBillSession parses session.getReserveNumbers(), passes them to getReleasedAppoinmentNumbersForApiBookings, and falls back to serviceSessionBean.getNextNonReservedSerialNumber(session, reservedNumbers) when no released numbers are found.
Small Optimization
src/main/java/com/divudi/service/ChannelService.java (savePaidBillItem)
savePaidBillItem now returns the created BillItem directly, removing an extra find lookup.
Build Files (manifest)
pom.xml, build.gradle, build.gradle.kts
Minor manifest/build file edits present in the diff.

Sequence Diagram

sequenceDiagram
    participant ChannelBean
    participant SessionInstance
    participant ChannelService
    participant Database

    ChannelBean->>SessionInstance: setReserveNumbers(ss.getReserveNumbers())
    Note over SessionInstance: reservedNumbers stored

    ChannelService->>ChannelService: nextAvailableAppoinmentNumberForSession(session)
    ChannelService->>ChannelService: build reserved Set from session.reserveNumbers
    ChannelService->>ChannelService: increment nextNumber past reserved values

    ChannelService->>Database: getAllBillSessionSerialNumbersForSessionInstance(ss)
    Database-->>ChannelService: existing serial numbers

    ChannelService->>ChannelService: getReleasedAppoinmentNumbersForApiBookings(ss, reservedNumbers)
    ChannelService->>ChannelService: compute unavailable = DB serials ∪ reservedNumbers
    ChannelService-->>ChannelService: return released numbers excluding unavailable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: ensuring session reserved numbers are considered when assigning appointment numbers for online bookings, which matches the core objective of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch channel-onlinebooking-save-reserved-number-check

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/divudi/service/ChannelService.java`:
- Around line 377-378: Replace the current reserve-number parsing that calls
CommonFunctions.convertStringToIntegerList(session.getOriginatingSession().getReserveNumbers())
with a null-safe parse of the booking-time SessionInstance snapshot (not the
originating template): obtain the SessionInstance reserve string (e.g.,
session.getReserveNumbers() or the instance accessor used in this class), guard
against null or empty by normalizing to an empty list, call
CommonFunctions.convertStringToIntegerList on that safe value, and then create
the Set via new HashSet<>(reservedNumbersList); apply the same change to the
other occurrences around methods/blocks referenced near lines 1085-1087 and
1297-1301 to avoid NPEs and ensure instance-based behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f45381b-ad0b-49c7-8351-8694f9df1241

📥 Commits

Reviewing files that changed from the base of the PR and between 17a3f04 and e431ede.

📒 Files selected for processing (2)
  • src/main/java/com/divudi/ejb/ChannelBean.java
  • src/main/java/com/divudi/service/ChannelService.java

Comment thread src/main/java/com/divudi/service/ChannelService.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant