generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" } model TariffReference { id Int @id @default(autoincrement()) uuid String @unique @default(uuid()) teamUuid String @map("team_uuid") @db.VarChar(100) name String @db.VarChar(255) status String @default("active") @db.VarChar(20) operationCode String? @map("operation_code") @db.VarChar(50) incotermsCode String? @map("incoterms_code") @db.VarChar(20) transportTypeCode String? @map("transport_type_code") @db.VarChar(50) tareTypeCode String? @map("tare_type_code") @db.VarChar(50) sourceCountryCode String? @map("source_country_code") @db.VarChar(10) destinationCountryCode String? @map("destination_country_code") @db.VarChar(10) sourceHubUuid String? @map("source_hub_uuid") @db.VarChar(100) destinationHubUuid String? @map("destination_hub_uuid") @db.VarChar(100) minWeightKg Decimal? @map("min_weight_kg") @db.Decimal(12, 2) maxWeightKg Decimal? @map("max_weight_kg") @db.Decimal(12, 2) minVolumeCbm Decimal? @map("min_volume_cbm") @db.Decimal(12, 3) maxVolumeCbm Decimal? @map("max_volume_cbm") @db.Decimal(12, 3) minDistanceKm Int? @map("min_distance_km") maxDistanceKm Int? @map("max_distance_km") sourceAmount Decimal @map("amount_usd") @db.Decimal(12, 2) minSourcePrice Decimal? @map("min_price_usd") @db.Decimal(12, 2) etaDays Int? @map("eta_days") priority Int @default(100) sourceCurrency String @default("USD") @map("currency") @db.VarChar(10) dmnExpression String? @map("dmn_expression") notes String? createdByUserId String? @map("created_by_user_id") @db.VarChar(255) createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") quotations Quotation[] @relation("QuotationSelectedTariff") @@index([teamUuid, status, priority]) @@index([teamUuid, sourceCountryCode, destinationCountryCode]) @@map("orders_tariff_reference") } model Quotation { id Int @id @default(autoincrement()) uuid String @unique @default(uuid()) teamUuid String @map("team_uuid") @db.VarChar(100) createdByUserId String? @map("created_by_user_id") @db.VarChar(255) title String @default("Quotation") @db.VarChar(255) status String @default("draft") @db.VarChar(30) operationCode String? @map("operation_code") @db.VarChar(50) incotermsCode String? @map("incoterms_code") @db.VarChar(20) transportTypeCode String? @map("transport_type_code") @db.VarChar(50) tareTypeCode String? @map("tare_type_code") @db.VarChar(50) sourceCountryCode String? @map("source_country_code") @db.VarChar(10) sourceHubUuid String? @map("source_hub_uuid") @db.VarChar(100) sourceLocationUuid String? @map("source_location_uuid") @db.VarChar(100) sourceLocationName String? @map("source_location_name") @db.VarChar(255) sourceLatitude Float? @map("source_latitude") sourceLongitude Float? @map("source_longitude") destinationCountryCode String? @map("destination_country_code") @db.VarChar(10) destinationHubUuid String? @map("destination_hub_uuid") @db.VarChar(100) destinationLocationUuid String? @map("destination_location_uuid") @db.VarChar(100) destinationLocationName String? @map("destination_location_name") @db.VarChar(255) destinationLatitude Float? @map("destination_latitude") destinationLongitude Float? @map("destination_longitude") chargeableWeightKg Decimal? @map("chargeable_weight_kg") @db.Decimal(12, 2) grossWeightKg Decimal? @map("gross_weight_kg") @db.Decimal(12, 2) volumeCbm Decimal? @map("volume_cbm") @db.Decimal(12, 3) unitsCount Int? @map("units_count") routeDistanceKm Int? @map("route_distance_km") selectedTariffId Int? @map("selected_tariff_id") selectedTariff TariffReference? @relation("QuotationSelectedTariff", fields: [selectedTariffId], references: [id], onDelete: SetNull) tariffMatchSummary String? @map("tariff_match_summary") tariffSnapshot String? @map("tariff_snapshot") sourceAmount Decimal? @map("source_amount") @db.Decimal(12, 2) sourceCurrency String? @map("source_currency") @db.VarChar(10) clientAmount Decimal @default(0) @map("total_amount") @db.Decimal(12, 2) clientCurrency String @default("USD") @map("currency") @db.VarChar(10) exchangeRate Decimal? @map("exchange_rate") @db.Decimal(24, 10) exchangeRateSnapshotUuid String? @map("exchange_rate_snapshot_uuid") @db.VarChar(100) exchangeRateProvider String? @map("exchange_rate_provider") @db.VarChar(255) exchangeRateEffectiveDate DateTime? @map("exchange_rate_effective_date") @db.Date exchangeRateQuotedAt DateTime? @map("exchange_rate_quoted_at") exchangeRateLockedAt DateTime? @map("exchange_rate_locked_at") pricingCountryCode String? @map("pricing_country_code") @db.VarChar(2) pricingKycProfileUuid String? @map("pricing_kyc_profile_uuid") @db.VarChar(100) etaDays Int? @map("eta_days") notes String? createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") orders Order[] changes QuotationChange[] routeStages QuotationRouteStage[] @@index([teamUuid, status, createdAt]) @@index([teamUuid, sourceCountryCode, destinationCountryCode]) @@map("orders_quotation") } model QuotationRouteStage { id Int @id @default(autoincrement()) uuid String @unique @default(uuid()) quotationId Int @map("quotation_id") quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade) sequence Int stageType String @map("stage_type") @db.VarChar(30) transportType String? @map("transport_type") @db.VarChar(50) sourcePointUuid String? @map("source_point_uuid") @db.VarChar(100) sourcePointType String @map("source_point_type") @db.VarChar(30) sourceLocationName String @map("source_location_name") @db.VarChar(255) sourceLatitude Float? @map("source_latitude") sourceLongitude Float? @map("source_longitude") destinationPointUuid String? @map("destination_point_uuid") @db.VarChar(100) destinationPointType String @map("destination_point_type") @db.VarChar(30) destinationLocationName String @map("destination_location_name") @db.VarChar(255) destinationLatitude Float? @map("destination_latitude") destinationLongitude Float? @map("destination_longitude") distanceKm Float? @map("distance_km") travelTimeSeconds Int? @map("travel_time_seconds") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@unique([quotationId, sequence]) @@index([quotationId, sequence]) @@map("orders_quotation_route_stage") } model QuotationChange { id Int @id @default(autoincrement()) uuid String @unique @default(uuid()) quotationId Int @map("quotation_id") quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade) actorUserId String? @map("actor_user_id") @db.VarChar(255) actorLabel String? @map("actor_label") @db.VarChar(255) source String @db.VarChar(50) summary String? payloadJson String? @map("payload_json") createdAt DateTime @default(now()) @map("created_at") @@index([quotationId, createdAt]) @@map("orders_quotation_change") } model Order { id Int @id @default(autoincrement()) uuid String @unique @default(uuid()) teamUuid String @map("team_uuid") @db.VarChar(100) quotationId Int? @unique @map("quotation_id") quotation Quotation? @relation(fields: [quotationId], references: [id], onDelete: SetNull) createdByUserId String? @map("created_by_user_id") @db.VarChar(255) name String @db.VarChar(255) status String @default("draft") @db.VarChar(30) sourceAmount Decimal? @map("source_amount") @db.Decimal(12, 2) sourceCurrency String? @map("source_currency") @db.VarChar(10) clientAmount Decimal @default(0) @map("total_amount") @db.Decimal(12, 2) clientCurrency String @default("USD") @map("currency") @db.VarChar(10) exchangeRate Decimal? @map("exchange_rate") @db.Decimal(24, 10) exchangeRateSnapshotUuid String? @map("exchange_rate_snapshot_uuid") @db.VarChar(100) exchangeRateProvider String? @map("exchange_rate_provider") @db.VarChar(255) exchangeRateEffectiveDate DateTime? @map("exchange_rate_effective_date") @db.Date exchangeRateQuotedAt DateTime? @map("exchange_rate_quoted_at") exchangeRateLockedAt DateTime? @map("exchange_rate_locked_at") pricingCountryCode String? @map("pricing_country_code") @db.VarChar(2) pricingKycProfileUuid String? @map("pricing_kyc_profile_uuid") @db.VarChar(100) sourceHubUuid String? @map("source_hub_uuid") @db.VarChar(100) sourceLocationUuid String? @map("source_location_uuid") @db.VarChar(100) sourceLocationName String? @map("source_location_name") @db.VarChar(255) sourceCountryCode String? @map("source_country_code") @db.VarChar(10) sourceLatitude Float? @map("source_latitude") sourceLongitude Float? @map("source_longitude") destinationLocationUuid String? @map("destination_location_uuid") @db.VarChar(100) destinationLocationName String? @map("destination_location_name") @db.VarChar(255) destinationCountryCode String? @map("destination_country_code") @db.VarChar(10) destinationHubUuid String? @map("destination_hub_uuid") @db.VarChar(100) destinationLatitude Float? @map("destination_latitude") destinationLongitude Float? @map("destination_longitude") etaDays Int? @map("eta_days") notes String? createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") routeStages OrderRouteStage[] @@index([teamUuid, createdAt]) @@map("orders_order") } model OrderRouteStage { id Int @id @default(autoincrement()) uuid String @unique @default(uuid()) orderId Int @map("order_id") order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) quotationRouteStageUuid String? @map("quotation_route_stage_uuid") @db.VarChar(100) sequence Int stageType String @map("stage_type") @db.VarChar(30) transportType String? @map("transport_type") @db.VarChar(50) sourcePointUuid String? @map("source_point_uuid") @db.VarChar(100) sourcePointType String @map("source_point_type") @db.VarChar(30) sourceLocationName String @map("source_location_name") @db.VarChar(255) sourceLatitude Float? @map("source_latitude") sourceLongitude Float? @map("source_longitude") destinationPointUuid String? @map("destination_point_uuid") @db.VarChar(100) destinationPointType String @map("destination_point_type") @db.VarChar(30) destinationLocationName String @map("destination_location_name") @db.VarChar(255) destinationLatitude Float? @map("destination_latitude") destinationLongitude Float? @map("destination_longitude") distanceKm Float? @map("distance_km") travelTimeSeconds Int? @map("travel_time_seconds") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@unique([orderId, sequence]) @@index([orderId, sequence]) @@map("orders_order_route_stage") }