masaruk Logo
analysis/04-functional-spec/trips-module.md

Trips Management

Trips Module – Functional Specification

1. Purpose

The Trips Module is the core of the MASARUK system. It defines how tourism programs (trips) are created, managed, displayed, booked, and synchronized across:

  • Provider Portal (B2B)
  • Admin Panel
  • B2C Web Platform
  • Mobile Apps (Flutter)
  • REST API Layer

2. Involved Entities

2.1 Primary Entity

EntityDescription
TripMain tourism program containing all details required for booking, pricing, transportation, accommodation, itinerary, services, and activation status.

4. Trip Data Model

4.1 Basic Trip Information

Field (English)Arabic UI LabelType
trip_nameاسم الرحلةstring
trip_typeنوع الرحلة (عمرة/سياحية)enum
nights_countعدد اللياليinteger
days_countعدد الأيامinteger
visited_citiesالمدن المزارةstring
departure_dateتاريخ المغادرةdate
return_dateتاريخ العودةdate
departure_cityمدينة المغادرةstring
arrival_cityمدينة الوصولstring
base_priceالسعرdecimal
currencyالعملةstring (SAR fixed)
max_capacityالعدد الأقصى للحجوزاتinteger
descriptionتفاصيل البرنامجlongtext
statusالحالةenum

4.2 Accommodation (Hotel)

FieldArabic LabelType
hotel_idالفندقFK (hotel)
hotel_room_typeنوع الغرفةstring
stay_durationمدة الإقامةinteger
hotel_image_listصور الفندقarray/files

4.3 Transportation (Bus + Driver)

FieldArabic LabelType
bus_idوسيلة النقلFK (bus)
driver_nameاسم السائقderived from bus
driver_mobileرقم الجوالderived from bus
bus_featuresالخدمات المتوفرةarray

4.4 Rest Stops (Go & Return)

FieldDescription
rest_stop_idRest stop FK
sequenceOrder in trip
typeGO / RETURN

4.5 Media & Assets

FieldDescription
image_listTrip images (PNG, JPG, GIF – max 10MB each)

5. Trip Status & Lifecycle

UI LabelEnumMeaning
نشطةACTIVEVisible + bookable
غير نشطةINACTIVEHidden from B2C
ملغاهCANCELLEDNot bookable
منتهيةCOMPLETEDEnd date passed

Derived Transitions

INACTIVE → ACTIVE
ACTIVE → CANCELLED
ACTIVE → COMPLETED (auto by date)
CANCELLED → INACTIVE (optional manual)

6. Functional Requirements

6.1 CRUD Operations

OperationProviderAdmin
Create Trip
Edit Trip✅ (own only)
Delete Trip✅ (own only)
View All Trips❌ (own only)
Change Status

6.2 B2C Display Requirements

Trips List
  • Filter by trip type (عمرة / سياحية)
  • Sort by price, popularity, date
  • Search by destination
  • Show only ACTIVE trips
Trip Details (Slice 7 + 8 SSOT)

3 Tabs + Date Selection — No Random Dates:

  • عرض الرحلة (Overview): Hero images, summary, price, duration
  • التفاصيل (Details): Hotel + 'View on Map', Transport, Rest Stops, Terms
  • عن البرنامج (About Program): Program intro + Daily itinerary (NOT under transport)
  • Date Selector (Slice 8): Dropdown/list of scheduled dates ONLY — NO calendar picker
Scheduled Dates (Slice 8 SSOT)

CRITICAL: No arbitrary date selection in B2C

  • DEC-S8-01: No calendar/date picker in booking flow
  • DEC-S8-02: User selects from provider-defined dates only
  • DEC-S8-04: Dropdown shows: Date + Status + Remaining capacity
  • AC-S8-05: CTA disabled if no dates available
  • Booking binds to: scheduled_date_id (FK)
Scheduled Dates Management (Slice 9 SSOT) ✅ OFFICIAL

Admin/Provider can manage dates. B2C is read-only. All decisions OFFICIAL.

  • CRUD: Create single, Bulk generate, Edit, Delete, Status change
  • Statuses: ACTIVE (🟢), INACTIVE (⚪), SOLD_OUT (🟠), CANCELLED (🔴)
  • DEC-S9-01: Approval inherits from Trip (no separate approval)
  • DEC-S9-02: CANCELLED dates hidden in B2C (not shown)
  • DEC-S9-03: cutoff_hours range: 0..168
  • DEC-S9-04: capacity: NULL=unlimited, ≥1=valid, 0=INVALID
  • DEC-S9-05: Auto SOLD_OUT on booking confirmation
  • DEC-S9-06: CANCELLED is terminal (no reactivation)
  • DEC-S9-07: Manual SOLD_OUT allowed (audit logged)
  • Validation: S9-V-01..S9-V-08 (see trips-module.md §12.9)
  • RBAC: PROVIDER_STAFF cannot bulk/delete/cancel

7. UI Bugs Noted

UI Bugs Preserved Verbatim
FieldExpected PlaceholderActual (Bug)
عدد اللياليادخل عدد اللياليادخل رقم الهوية/الإقامة
نوع الغرفةادخل نوع الغرفةادخل رقم الطوارئ

These bugs are documented in admin-provider-ui-inventory.md.