Sixième Étoile — Documentation

Core Entities

Reference for the principal Prisma models — tenancy, CRM, commercial layer, operations, fleet, and pricing.

This page describes the main Prisma models. All monetary values are in EUR unless noted otherwise.

Tenancy & Identity

Organization

Top-level tenant. Every VTC business model is scoped to an Organization via organizationId.

FieldTypeNotes
idStringBetter Auth-managed CUID
nameStringDisplay name
slugString?URL-safe unique identifier
primaryColorString?Hex brand color for tracking pages (default #1e40af)
gracePeriodMinutesIntMinutes before tracking link expires after mission completion (default 30)
timezoneStringDisplay timezone (default Europe/Paris)

Relations: members, contacts, vehicles, drivers, quotes, invoices, missions, and all other VTC entities.

User

A Better Auth user. One User can belong to multiple organizations via Member.

FieldTypeNotes
idStringBetter Auth-managed
emailStringUnique
roleString?Organization-level role
twoFactorEnabledBooleanTOTP enabled flag (default false)
onboardingCompleteBooleanWhether first-login wizard is done

Member

Junction between User and Organization. Carries the role and granular permission maps.

FieldTypeNotes
roleStringowner / admin / member
permissionsJsonLegacy array of permission keys
permissionsMapJsonFine-grained PermissionMap overrides
statusStringPENDING / ACTIVE / INACTIVE

CRM

Contact

Unified contact model for customers, corporate clients, and agency partners.

FieldTypeNotes
typeContactTypePRIVATE / BUSINESS / PARTNER / AGENCY
displayNameStringDisplay name (required)
firstName, lastNameString?Person fields
companyName, vatNumber, siretString?Company fields
isHotelBooleanSub-flag for hotel-type PARTNER/AGENCY contacts
defaultClientTypeClientTypePARTNER / PRIVATE — drives pricing path
difficultyScoreInt?1–5 patience-tax multiplier (null = no adjustment)
preferredLanguageStringISO-2 code (fr / en); drives PDF language
autoValidationModeValidationModeMANUAL / AUTO_GRID_MATCH / AUTO_ALL
isArchivedBooleanSoft-archive flag (default false)

A PARTNER or AGENCY contact has an associated PartnerContract (1:1) and may have AgencyPortalUser members.

EndCustomer

Individual passenger within an agency partner's portfolio.

FieldTypeNotes
contactIdStringOwning agency/partner Contact
ownerContactIdString?Explicit owner contact (for delegation)
firstName, lastNameStringRequired
difficultyScoreInt?1–5 patience-tax override
preferredLanguageStringOverrides owning contact's language preference

Commercial Layer

Quote

Central commercial object. Every service request starts as a Quote.

FieldTypeNotes
statusQuoteStatusDRAFTSENTACCEPTEDINVOICED (see full enum)
sourceQuoteSourceOPERATOR_DIRECT / AGENCY_PORTAL
pricingModePricingModeFIXED_GRID / DYNAMIC / PARTNER_GRID / CLIENT_DIRECT / MANUAL
tripTypeTripTypeTRANSFER / EXCURSION / DISPO / OFF_GRID
pickupAtDateTimePlanned pickup date/time
pickupAddressStringDeparture address
dropoffAddressString?Null for DISPO and OFF_GRID
durationHoursDecimal?For DISPO — duration in hours
suggestedPriceDecimalEngine-calculated price HT
finalPriceDecimalOperator-confirmed price HT
commissionPercentDecimal?Snapshot from PartnerContract at quote time
tripAnalysisJson?Shadow calculation (segments, distances, cost breakdown)
appliedRulesJson?Grids, multipliers, promotions applied
referenceString?Sequential reference, e.g. QT-2026-001 (unique per org)
awaitingOperatorPricingBooleanAgency submitted, pending operator price
autoValidatedBooleanAuto-validated by agency booking wizard

Key indexes: (organizationId), (contactId), (status), (pickupAt), (organizationId, status), (source, awaitingOperatorPricing)

Quotes may also carry one persisted StaffingPlan. The plan is a snapshot of the predictive RSE/staffing decision chosen in the cockpit (AUTO or OPERATOR_OVERRIDE) and is the source of truth for dispatch pre-staging.

QuoteLine

Structured line item within a Quote (Hybrid Blocks architecture).

FieldTypeNotes
typeQuoteLineTypeCALCULATED / MANUAL / GROUP / FEE / PROMOTION
labelStringDisplay label (e.g. "Transfert CDG → Paris")
quantityDecimalDefault 1, precision (10,3)
unitPriceDecimalHT unit price (excl. tax), precision (10,2)
totalPriceDecimalunitPrice × quantity, HT, precision (10,2)
vatRateDecimalDefault 10.00 — stored as decimal percent (10.00 = 10 %)
vatAmountDecimal?totalTtc - totalPrice
totalTtcDecimal?unitPriceTtc × quantity
unitPriceTtcDecimal?TTC source of truth from user input
priceSourcePriceSource?DYNAMIC / FIXED_GRID / PARTNER_GRID / MANUAL_OVERRIDE
dispatchableBooleanWhether this line spawns a Mission (default true)
parentIdString?Parent line for GROUP hierarchy
sortOrderIntDisplay order

Critical semantics: unitPrice and totalPrice are always HT (excl. tax). vatRate is a decimal percentage — 10.00 means 10 %, not 0.10.

Order

Groups multiple quotes, missions, and invoices under a "Dossier de commande".

FieldTypeNotes
referenceStringUnique sequential ref, e.g. ORD-2026-001
statusOrderStatusDRAFTQUOTEDCONFIRMEDINVOICEDPAID
contactIdStringCustomer contact (onDelete: Restrict)

Operations

Mission

Operational unit linking a QuoteLine to a driver + vehicle assignment.

FieldTypeNotes
quoteIdString?Nullable — internal tasks have no parent quote
quoteLineIdString?The specific line that generated this mission
statusMissionStatusPENDING / ASSIGNED / IN_PROGRESS / COMPLETED / CANCELLED / BILLED
startAtDateTimePlanned start
endAtDateTime?Planned end (null for open-ended)
driverIdString?Primary driver (nullable until assigned)
vehicleIdString?Assigned vehicle (nullable until assigned)
driverModeDriverModeSIMPLE / DOUBLE_EQUIPAGE / RELAIS
isInternalBooleanNon-billable internal mission (default false)
kmStart, kmEnd, kmActualDecimal?Odometer readings from driver sheet
actualPickupAt, actualDropoffAtDateTime?Actual execution timestamps
refString?Sequential ref, e.g. ORD-2026-001-01
liveTrackingShareEnabledBooleanWhether the tracking link is active

Notable: Mission.quoteId is nullable. Commercial missions always have a quoteId; internal tasks (created directly by operators without a quote) leave it null.

MissionTransition

Typed audit log for every mission status change (9-stage lifecycle).

FieldTypeNotes
fromStage, toStageMissionStageOne of 11 granular stages
triggerTypeTransitionTriggerMANUAL / AUTOMATIC / FORCE
actorId, actorNameString?Who triggered the transition

StaffingPlan

Predictive crew decision attached to one Quote or one Mission.

FieldTypeNotes
planTypeStaffingPlanTypeNONE / OVERNIGHT_RETURN / RELAY_DRIVER / DOUBLE_CREW / MULTI_DAY
additionalCostDecimalStaffing surcharge snapshot used by the pricing result
modeProfileJsonRSE mode profile snapshot (TRANSFER, ROUND_TRIP, MULTI_STOP, MAD, SEJOUR)
sourceStaffingPlanSourceAUTO or OPERATOR_OVERRIDE
regulatoryRiskAcknowledgedBooleanOperator acknowledgement snapshot when an override accepts risk
quoteId, missionIdString?Unique optional links; at most one plan per quote or mission

StaffingAssignment

One crew slot inside a StaffingPlan.

FieldTypeNotes
driverIndexIntSlot order: 0 primary, 1 second/relay
roleStaffingAssignmentRoleSOLO / RELAY / DOUBLE
sharePercentDecimalFrozen relay/double split, e.g. 60.00 / 40.00
legScopeJson?Optional leg or time-scope metadata for relay partitioning
driverIdString?Filled later during dispatch; nullable so the quote can be accepted before drivers are known

Fleet

Vehicle

FieldTypeNotes
vehicleCategoryIdStringRequired — links to VehicleCategory
operatingBaseIdStringHome base/garage
registrationNumberStringUnique per org
statusVehicleStatusACTIVE / MAINTENANCE / OUT_OF_SERVICE / ARCHIVED / SOLD
consumptionLPer100KmDecimal?For fuel cost calculation
purchasePriceDecimal?TCO field
expectedLifespanKmInt?For depreciation calculation

VehicleCategory

Groups vehicles commercially and regulatorily.

FieldTypeNotes
codeStringUnique per org (e.g. SEDAN, VAN)
regulatoryCategoryVehicleRegulatoryCategoryLIGHT / HEAVY
maxPassengersIntCapacity constraint
priceMultiplierDecimalMultiplier applied in the pricing engine (default 1.0)
defaultLicenseCategoryIdString?Predictive RSE resolution link: category → license category → organization rule
tollClassIntProvider toll class, constrained by regulatory category
vehicleHeightCm, axleCountInt?Optional provider metadata for class-aware toll estimates
averageSpeedKmhInt?Category-level predictive speed used when no specific vehicle is assigned

Driver

FieldTypeNotes
employmentStatusDriverEmploymentStatusEMPLOYEE / CONTRACTOR / FREELANCE
hourlyCostDecimal?For cost calculations
isActiveBooleanSoft-delete flag
homeLat, homeLngDecimal?Home location for deadhead distance
preferredLanguageStringISO-2 code for driver-facing documents

Related models: DriverLicense (M:N with LicenseCategory), DriverCalendarEvent (absences), DriverRSECounter (daily RSE compliance counters).


Finance

Invoice

Immutable financial document derived from accepted quotes.

FieldTypeNotes
numberStringUnique per org (e.g. INV-2026-001)
invoiceTypeInvoiceTypeSTANDARD / DEPOSIT / CREDIT_NOTE / SUPPLEMENT
parentInvoiceIdString?Chain link: final invoices point to the deposit root; credit notes point to the invoice they offset
statusInvoiceStatusDRAFT / ISSUED / PARTIAL / PAID / CANCELLED
totalExclVatDecimalTotal HT
totalVatDecimalTotal VAT amount
totalInclVatDecimalTotal TTC
paidAmountDecimalRunning paid amount (for partial payment tracking)
commissionHTDecimal?Partner commission excl. tax
commissionTTCDecimal?Partner commission incl. tax
languageStringPDF rendering language
prestationSummaryString?Fiscal snapshot of pickup/dropoff/date/vehicle captured at creation time

Deposit invoices are revenue invoices. The final invoice bills only the remaining balance, so deposit + final + credit notes is the auditable chain total without double counting.

InvoiceLine

FieldTypeNotes
unitPriceExclVatDecimalHT unit price, precision (10,4)
vatRateDecimalDecimal percent (e.g. 20.00 = 20 %), precision (5,2)
totalExclVatDecimalStored for immutability
quoteLineIdString?Traceability back to source QuoteLine

BankAccount

Multi-account support per organization, with per-contact and per-document overrides.

FieldTypeNotes
ibanStringIBAN (max 34 chars)
isDefaultBooleanOrg-wide default account
isActiveBooleanSoft-delete flag
currencyStringISO 4217 (default EUR)

Phase 2 — Real-time & Portal Entities

AgencyPortalUser

Links a Better Auth User to an agency Contact with granular portal permissions.

FieldTypeNotes
agencyIdStringThe PARTNER/AGENCY Contact this user belongs to
rolePortalUserRoleADMIN / OPERATOR / MEMBER
statusPortalUserStatusPENDING / ACTIVE / INACTIVE
canCreateQuotesBooleanPortal permission flags
canViewInvoicesBooleanPortal permission flags

DriverLocation

Latest driver GPS position (upsert pattern — one row per driver).

FieldTypeNotes
driverIdStringUnique — one row per driver
lat, lngFloatCurrent position
heading, speedFloat?Optional motion data

DriverLocationHistory stores the full breadcrumb trail. missionId is nullable so the trail records even between missions.

TrackingToken

Public magic link for customer tracking.

FieldTypeNotes
tokenStringcuid(2), URL-safe unique
missionIdStringLinked mission
expiresAtDateTimeAuto-expire after gracePeriodMinutes past completion
languageStringISO-2, resolved at mint time from contact preference
langLockedBooleanOperator-pinned language — ignores URL param auto-resolution

Pricing Engine Entities

OrganizationPricingSettings

Single-row settings per organization (1:1 with Organization).

Key fields: baseRatePerKm, baseRatePerHour, defaultMarginPercent, defaultVatRate (default 10.00), zone conflict/aggregation strategies, MAD configuration, round-trip auto-switch settings, and staffing cost parameters.

OrganizationLicenseRule

Per-license RSE rules for one organization. These rules now include both hard limits and soft staffing levers:

Field groupExamples
Hard limitsmax daily driving, amplitude, rest, break intervals, capped average speed
Soft leversextendedDrivingHours, extendedDaysPerWeek, lightVehicleDerogationHours, bufferTrafficPercent, defaultRelaySharePercent, relayTriggerHours, amplitudeTriggerHours

OrganizationRSEPolicy

Singleton organization-level policy for RSE/staffing levers that are not tied to a specific vehicle category. The pricing engine resolves a single RSEConfig by merging category/license rules with this policy, falling back only to documented last-resort defaults when configuration is missing.

PricingZone

Geographic zone used in Method 1 (fixed-grid) pricing.

FieldTypeNotes
codeStringUnique per org (e.g. PARIS_0, CDG)
zoneTypeZoneTypePOLYGON / RADIUS / POINT / CORRIDOR
priceMultiplierDecimalApplied to base fare (default 1.0)
isCentralZoneBooleanPriority-1 flat rate zone flag
priorityIntConflict resolution priority

ZoneRoute

Zone-to-zone fixed price grid entry for TRANSFER trips.

FieldTypeNotes
vehicleCategoryIdStringRequired
fixedPriceDecimalGrid price
priceModePriceModeHT / TTC — indicates how fixedPrice is stored
vatRateDecimalDecimal percent (default 10.00)
directionRouteDirectionBIDIRECTIONAL / A_TO_B / B_TO_A

Grid prices (ZoneRoute.fixedPrice, ExcursionPackage.price, DispoPackage.basePrice) may be stored as HT or TTC depending on priceMode. Check priceMode before interpreting the value.

Was this page helpful?

On this page