masaruk Logo

analysis/04-functional-spec/providers-and-companies-module.md

Tourism Companies

Providers & Companies Module – Functional Specification

1. Purpose

The Providers & Companies Module defines how MASARUK manages tourism companies (B2B Providers) who create and manage trips, buses, hotels, and rest stops.

This includes:

  • Provider account creation & onboarding
  • Managing provider company data
  • Associating provider staff users
  • Controlling resources (trips, buses, hotels, rest stops)
  • Linking financial records & ad campaigns to providers
  • Activation/deactivation logic
  • Role-based access (Provider Admin vs Provider Staff)

4. Provider Entity Fields

FieldTypeNotes
idPK
company_nameStringCompany name
cr_numberStringCommercial register (if available)
license_numberStringTourism license
phoneStringPhone number
emailStringEmail address
addressStringAddress
logo_urlStringCompany logo
statusEnumACTIVE / INACTIVE / PENDING_APPROVAL / REJECTED
countryStringCountry (Saudi Arabia, Egypt, UAE, Jordan)
total_tripsIntegerNumber of trips
total_salesDecimalTotal sales
created_attimestamp
updated_attimestamp

5. Provider Statuses

ActiveRejectedPending
LabelEnumColorMeaning
ActiveACTIVEGreenProvider can operate normally
RejectedREJECTEDPinkApplication rejected by admin
Pending ApprovalPENDING_APPROVALOrangeAwaiting admin review

Admin Actions

ActionModal TitleConfirmation Button
ApproveAccept!Yes, Continue
Reject
PauseDeactivate!Yes, Continue
ReactivateReactivate!Yes, Continue

6. Provider Staff Fields (ProviderUser)

FieldTypeNotes
idPK
provider_idFKStaff's company
nameString
emailString
phoneString
roleEnumprovider_admin / staff
statusEnumactive / disabled
created_attimestamp
updated_attimestamp

7. Business Rules

BR-1. Provider must be activated to publish trips

If provider.status != active then: Cannot create trips, Cannot run ad campaigns, Cannot access financial reports.

BR-2. Provider Admin vs Provider Staff

  • Provider Admin: full CRUD on all provider resources
  • Staff: limited access depending on RBAC matrix

BR-3. Provider owns all created resources

Every trip, bus, hotel, rest stop is linked using provider_id

BR-4. Provider financial participation

  • Provider receives net payout after platform commission
  • Payout only if trip successfully completed
  • Payout never issued on refunded bookings

BR-5. Provider cannot modify system-level entities

VAT, Commission settings, Global notifications, System-wide settings — these are Admin-only.

BR-6. Provider account removal is soft-delete only

Because trips, buses, hotels, rest-stops, and bookings reference provider.

BR-7. Campaign payments must always be linked to provider

AdCampaign → PaymentTransaction → Provider — ensures correct financial attribution.

8. Actions & Behaviors

A-1. Provider Creation (Admin Only)

  • Create provider
  • Upload logo
  • Set status
  • Assign initial provider admin user

A-2. Provider Self-Management

  • Update profile data
  • Change logo
  • Update address
  • Add/edit/remove staff users

A-3. Provider Resource Management

  • Add/Edit/Delete Trips
  • Add/Edit/Delete Buses
  • Add/Edit/Delete Hotels
  • Add/Edit/Delete RestStops
  • Create AdCampaigns

A-4. Provider Financial Reports

  • Transactions related to their trips
  • Net revenues
  • Payout status
  • Export feature (CSV)

9. Validation Rules

VR-1. Unique Company Email

email must be unique across all providers.

VR-2. Unique Phone

phone must be unique.

VR-3. Provider License Validation

Admin must supply license_number; system stores it without interpretation.

VR-4. Provider User Role Validation

ProviderUser.role ∈ { provider_admin, staff }

VR-5. Provider cannot delete resources with active dependencies

Cannot delete hotel linked to future trips or bus assigned to active bookings.

10. Error Cases

CaseMessage
Provider inactiveCompany account is not activated
Staff tries admin actionYou do not have permission to perform this action
Duplicate email or phoneEntered data is already in use
Resource deletion blockedCannot delete this resource as it is linked to active trips
Ad campaign payment unsuccessfulCampaign creation aborted