Skip to main content

Benefits Data Model

Prisma schema (tee-sheet-data) entities involved in reciprocity and benefit tracking.

Core tables

  • ReciprocityAgreement
    • type: BILATERAL or NETWORK
    • direction: A_TO_B, B_TO_A, BOTH (bilateral only)
    • networkCode: required for network agreements
    • startDate / endDate / isActive
  • ReciprocityRateConfig (1:1 with agreement)
    • discountType: PERCENT, FIXED_AMOUNT, FIXED_RATE, RATE_TIER
    • discountValue, fixedRateCents, rateTierCode
    • priority (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 ReciprocityRateConfig
  • ReciprocityAgreement (network) relies on ClubNetworkMembership for membership gating.
  • BenefitProviderAssignment drives which providers are evaluated per tenant/club; reciprocity uses provider code as network code.
  • BenefitApplication references 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.priority control ordering when multiple bilaterals exist.
  • Keep ClubNetworkMembership rows in sync with real-world network participation to avoid OUT_OF_NETWORK.