140 lines
7.8 KiB
Plaintext
140 lines
7.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("ORDERS_DATABASE_URL")
|
|
}
|
|
|
|
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")
|
|
amountUsd Decimal @map("amount_usd") @db.Decimal(12, 2)
|
|
minPriceUsd Decimal? @map("min_price_usd") @db.Decimal(12, 2)
|
|
etaDays Int? @map("eta_days")
|
|
priority Int @default(100)
|
|
currency String @default("USD") @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")
|
|
totalAmount Decimal @default(0) @map("total_amount") @db.Decimal(12, 2)
|
|
currency String @default("USD") @db.VarChar(10)
|
|
etaDays Int? @map("eta_days")
|
|
notes String?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
orders Order[]
|
|
changes QuotationChange[]
|
|
|
|
@@index([teamUuid, status, createdAt])
|
|
@@index([teamUuid, sourceCountryCode, destinationCountryCode])
|
|
@@map("orders_quotation")
|
|
}
|
|
|
|
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)
|
|
totalAmount Decimal @default(0) @map("total_amount") @db.Decimal(12, 2)
|
|
currency String @default("USD") @db.VarChar(10)
|
|
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)
|
|
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")
|
|
|
|
@@index([teamUuid, createdAt])
|
|
@@map("orders_order")
|
|
}
|