Vés al contingut

3 min de lectura

Linking the Eligible Package to an Appointment

When a client has several packages, linking one to an appointment is more than subtracting a session from a balance. The selected package must cover the service, branch, and appointment date; have a usable right; and satisfy its validity conditions. If the wrong package is selected, the client can receive the correct service while the wrong balance changes, requiring a later reversal. Define eligibility rules before designing automatic or staff-assisted selection.

Fictional example: Eylül has a six-session clinical Pilates package expiring December 20 and a four-session manual-therapy package valid through January 31. Her December 18 Pilates appointment is eligible only for the first package. A total account balance of ten is not the decision criterion. If the appointment is moved to December 22, the Pilates package may no longer qualify under the clinic’s terms, even though it had a right when the form first opened.

Check the selected package again when the booking is committed. The user may have left the screen open while another booking consumed the final right, or a manager may have frozen the package. A stale view should not authorize a debit. If two requests compete for one right, use a server-side state check, transaction, or lock appropriate to the data model. PostgreSQL documents transactions and explicit row locking as techniques for coordinating concurrent changes: transactions, explicit locking.

Before treating a positive balance as eligible, distinguish active rights from frozen packages, payment-pending packages, and packages under dispute. Define whether each state blocks booking or requires authorized review. Also decide separately how client cancellation, late cancellation, no-show, clinic cancellation, and practitioner cancellation affect reservation and consumption; one generic “cancelled” state may not express those different policies.

The appointment record should keep the chosen package ID and the eligibility facts used at booking. If the clinic permits a client to choose among multiple valid packages, show the balance, expiry, and service scope before confirmation. If the policy automatically selects the earliest-expiring package, explain that policy and allow an authorized exception where needed. Do not use arbitrary ordering such as whichever package happened to load first.

Counterexample: A client’s combined balance is ten, so the booking screen deducts from the first package in a list. That package is for manual therapy, but the appointment is Pilates. The client may later lack the manual-therapy rights they expected, while the Pilates package remains untouched. A balance total concealed the mismatch.

Handle a change after selection

If the appointment’s service, branch, or date changes after package selection, recompute eligibility. A move to another branch may change the applicable package scope; a date shift may cross the expiry boundary; a different service may require another package. Do not carry the old selection forward without checking. If no package remains eligible, ask the client or an authorized staff member for the next step rather than forcing a debit.

When a booking is canceled, restore a right to the package that funded it if the applicable policy calls for a reversal. If the original package is no longer active, record the return movement against that package and separately determine whether it is usable. Do not migrate the right to another package simply because that package has an active balance. Transfers and corrections are distinct events.

Test eligibility and simultaneous booking

Test an eligible package, a package restricted to another service, an expired package, a frozen package, one restricted to another branch, and a zero balance. Test the same booking with two eligible packages, then exercise the clinic’s selection rule. Change the date or service after selection and verify that eligibility is recalculated. Finally, have two users attempt to consume the last right concurrently and confirm that only the allowed booking succeeds.

For every case, compare the selected package ID, appointment, ledger movement, displayed balance, and confirmation message. If the package choice cannot be established, leave the booking unconfirmed and send it to an authorized reviewer. test the actual product and clinic terms.

Tots els articlesLlegeix-ho en turc

Quan ho tinguis clar

Dona-li una setmana de veritat.

Baixa l'app, configura el teu estudi i fes-lo servir amb cites reals durant dues setmanes. No et demanem cap targeta. Si et quedes, et subscrius a la botiga d'aplicacions.