add pricing feature
This commit is contained in:
@@ -205,6 +205,28 @@ enum FuelType {
|
||||
HYBRID
|
||||
}
|
||||
|
||||
enum VehiclePricingMode {
|
||||
MANUAL
|
||||
AUTOMATIC
|
||||
}
|
||||
|
||||
enum VehiclePricingRuleType {
|
||||
DATE_RANGE
|
||||
SEASONAL
|
||||
HOLIDAY
|
||||
WEEKEND
|
||||
SPECIAL_EVENT
|
||||
MANUAL_OVERRIDE
|
||||
}
|
||||
|
||||
enum VehiclePriceChangeSource {
|
||||
CONFIG_UPDATE
|
||||
RULE_CREATED
|
||||
RULE_UPDATED
|
||||
RULE_DELETED
|
||||
MANUAL_OVERRIDE
|
||||
}
|
||||
|
||||
enum OfferType {
|
||||
PERCENTAGE
|
||||
FIXED_AMOUNT
|
||||
@@ -996,6 +1018,8 @@ model Vehicle {
|
||||
maintenance MaintenanceLog[]
|
||||
offerVehicles OfferVehicle[]
|
||||
calendarBlocks VehicleCalendarBlock[]
|
||||
pricingConfiguration VehiclePricingConfiguration?
|
||||
priceHistory VehiclePriceHistory[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -1006,6 +1030,80 @@ model Vehicle {
|
||||
@@map("vehicles")
|
||||
}
|
||||
|
||||
model VehiclePricingConfiguration {
|
||||
id String @id @default(cuid())
|
||||
vehicleId String @unique
|
||||
vehicle Vehicle @relation(fields: [vehicleId], references: [id], onDelete: Cascade)
|
||||
pricingMode VehiclePricingMode @default(MANUAL)
|
||||
baseDailyRate Int?
|
||||
weeklyRate Int?
|
||||
weekendRate Int?
|
||||
holidayRate Int?
|
||||
monthlyRate Int?
|
||||
longTermDailyRate Int?
|
||||
minimumDailyRate Int?
|
||||
maximumDailyRate Int?
|
||||
maxDailyPriceMovementPct Int @default(10)
|
||||
automaticPricingEnabled Boolean @default(false)
|
||||
approvalRequired Boolean @default(false)
|
||||
|
||||
rules VehiclePricingRule[]
|
||||
history VehiclePriceHistory[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("vehicle_pricing_configurations")
|
||||
}
|
||||
|
||||
model VehiclePricingRule {
|
||||
id String @id @default(cuid())
|
||||
configurationId String
|
||||
configuration VehiclePricingConfiguration @relation(fields: [configurationId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
ruleType VehiclePricingRuleType @default(DATE_RANGE)
|
||||
startDate DateTime
|
||||
endDate DateTime
|
||||
dailyRate Int?
|
||||
weeklyRate Int?
|
||||
weekendRate Int?
|
||||
monthlyRate Int?
|
||||
minDailyRate Int?
|
||||
maxDailyRate Int?
|
||||
automaticAdjustmentPct Int?
|
||||
priceAdjustment Int?
|
||||
isActive Boolean @default(true)
|
||||
sortOrder Int @default(0)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([configurationId])
|
||||
@@index([configurationId, startDate, endDate])
|
||||
@@map("vehicle_pricing_rules")
|
||||
}
|
||||
|
||||
model VehiclePriceHistory {
|
||||
id String @id @default(cuid())
|
||||
configurationId String
|
||||
configuration VehiclePricingConfiguration @relation(fields: [configurationId], references: [id], onDelete: Cascade)
|
||||
vehicleId String
|
||||
vehicle Vehicle @relation(fields: [vehicleId], references: [id], onDelete: Cascade)
|
||||
source VehiclePriceChangeSource @default(CONFIG_UPDATE)
|
||||
changedByEmployeeId String?
|
||||
previousDailyRate Int?
|
||||
nextDailyRate Int?
|
||||
previousWeeklyRate Int?
|
||||
nextWeeklyRate Int?
|
||||
note String?
|
||||
effectiveFrom DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([vehicleId, createdAt])
|
||||
@@index([configurationId, createdAt])
|
||||
@@map("vehicle_price_history")
|
||||
}
|
||||
|
||||
model Offer {
|
||||
id String @id @default(cuid())
|
||||
companyId String
|
||||
|
||||
Reference in New Issue
Block a user