Benefits Data Model
Prisma schema (tee-sheet-data) entities involved in reciprocity and benefit tracking.
Core tables
- ReciprocityAgreement
type:BILATERALorNETWORKdirection:A_TO_B,B_TO_A,BOTH(bilateral only)networkCode: required for network agreementsstartDate/endDate/isActive
- ReciprocityRateConfig (1:1 with agreement)
discountType:PERCENT,FIXED_AMOUNT,FIXED_RATE,RATE_TIERdiscountValue,fixedRateCents,rateTierCodepriority(lower is preferred),validDaysOfWeek,validTimeStart/End,blackoutDates,minHandicap,maxHandicap
- ClubNetworkMembership
clubId,networkCode,isActive— enables network reciprocity for the club.
Benefit tracking tables
- BenefitProvider: registry of provider codes (e.g.,
SAGA_NETWORK,NEDBANK_GREENTIME,DISCOVERY_VITALITY). - BenefitProviderAssignment: assigns providers to clubs/tenants (priority, stacking policy, blackout windows).
- BenefitMembership: validation snapshots (status, tier, handicap, expiry, raw payload) per provider/member.
- BenefitApplication: audit rows for applied discounts (booking/slot context, amount/percent, provider, membership, snapshot).
Migration
- Migration name:
20251205_reciprocity_agreements- Adds reciprocity tables/enums and network membership.
- Lives at
libs/prisma/tee-sheet-data/prisma/migrations/20251205_reciprocity_agreements/.
Relations (high level)
ReciprocityAgreement 1--1 ReciprocityRateConfigReciprocityAgreement(network) relies onClubNetworkMembershipfor membership gating.BenefitProviderAssignmentdrives which providers are evaluated per tenant/club; reciprocity uses provider code as network code.BenefitApplicationreferences bookings/slots to record the applied discount result.
Operational notes
- Agreements can co-exist: bilaterals override networks; stacking can apply multiple bilaterals plus the network.
- Priorities in
ReciprocityRateConfig.prioritycontrol ordering when multiple bilaterals exist. - Keep
ClubNetworkMembershiprows in sync with real-world network participation to avoidOUT_OF_NETWORK.