feat: add quotation structure
This commit is contained in:
parent
be8f8d462f
commit
d0e207de7e
2 changed files with 231 additions and 4 deletions
|
|
@ -375,6 +375,8 @@ model User {
|
|||
productTypeUpdated ProductType[] @relation("ProductTypeUpdatedByUser")
|
||||
productCreated Product[] @relation("ProductCreatedByUser")
|
||||
productUpdated Product[] @relation("ProductUpdatedByUser")
|
||||
quotationCreated Quotation[] @relation("QuotationCreatedByUser")
|
||||
quotationUpdated Quotation[] @relation("QuotationUpdatedByUser")
|
||||
}
|
||||
|
||||
enum CustomerType {
|
||||
|
|
@ -405,7 +407,8 @@ model Customer {
|
|||
updatedBy User? @relation(name: "CustomerUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
branch CustomerBranch[]
|
||||
branch CustomerBranch[]
|
||||
quotation Quotation[]
|
||||
}
|
||||
|
||||
model CustomerBranch {
|
||||
|
|
@ -462,7 +465,8 @@ model CustomerBranch {
|
|||
updatedBy User? @relation(name: "CustomerBranchUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
|
||||
employee Employee[]
|
||||
employee Employee[]
|
||||
quotation Quotation[]
|
||||
}
|
||||
|
||||
model Employee {
|
||||
|
|
@ -528,7 +532,8 @@ model Employee {
|
|||
employeeWork EmployeeWork[]
|
||||
employeeOtherInfo EmployeeOtherInfo[]
|
||||
|
||||
editHistory EmployeeHistory[]
|
||||
editHistory EmployeeHistory[]
|
||||
quotationWorker QuotationWorker[]
|
||||
}
|
||||
|
||||
model EmployeeHistory {
|
||||
|
|
@ -691,7 +696,8 @@ model Product {
|
|||
registeredBranchId String?
|
||||
registeredBranch Branch? @relation(fields: [registeredBranchId], references: [id])
|
||||
|
||||
workProduct WorkProduct[]
|
||||
workProduct WorkProduct[]
|
||||
quotationServiceWorkProduct QuotationServiceWorkProduct[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "ProductCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
|
|
@ -767,3 +773,116 @@ model WorkProduct {
|
|||
|
||||
@@id([workId, productId])
|
||||
}
|
||||
|
||||
enum PayCondition {
|
||||
Full
|
||||
Split
|
||||
BillFull
|
||||
BillSplit
|
||||
}
|
||||
|
||||
model Quotation {
|
||||
id String @id @default(uuid())
|
||||
|
||||
customerId String
|
||||
customer Customer @relation(fields: [customerId], references: [id])
|
||||
|
||||
customerBranchId String
|
||||
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id])
|
||||
|
||||
code String
|
||||
date DateTime @default(now())
|
||||
payCondition PayCondition
|
||||
|
||||
paySplitCount Int?
|
||||
paySplit QuotationPaySplit[]
|
||||
|
||||
payBillDate DateTime?
|
||||
|
||||
workerCount Int
|
||||
worker QuotationWorker[]
|
||||
|
||||
service QuotationService[]
|
||||
|
||||
urgent Boolean @default(false)
|
||||
|
||||
totalPrice Float
|
||||
totalDiscount Float
|
||||
vat Int
|
||||
vatExcluded Int
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
createdBy User? @relation(name: "QuotationCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||
createdByUserId String?
|
||||
updatedAt DateTime @updatedAt
|
||||
updatedBy User? @relation(name: "QuotationUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
||||
updatedByUserId String?
|
||||
}
|
||||
|
||||
model QuotationPaySplit {
|
||||
id String @id @default(uuid())
|
||||
|
||||
no Int
|
||||
date DateTime
|
||||
|
||||
quotation Quotation? @relation(fields: [quotationId], references: [id])
|
||||
quotationId String?
|
||||
}
|
||||
|
||||
model QuotationWorker {
|
||||
id String @id @default(uuid())
|
||||
|
||||
no Int
|
||||
code String
|
||||
employee Employee @relation(fields: [employeeId], references: [id])
|
||||
employeeId String
|
||||
quotation Quotation @relation(fields: [quotationId], references: [id])
|
||||
quotationId String
|
||||
}
|
||||
|
||||
model QuotationService {
|
||||
id String @id @default(uuid())
|
||||
|
||||
code String
|
||||
name String
|
||||
detail String
|
||||
attributes Json?
|
||||
|
||||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
work QuotationServiceWork[]
|
||||
|
||||
quotation Quotation @relation(fields: [quotationId], references: [id])
|
||||
quotationId String
|
||||
}
|
||||
|
||||
model QuotationServiceWork {
|
||||
id String @id @default(uuid())
|
||||
|
||||
order Int
|
||||
name String
|
||||
attributes Json?
|
||||
|
||||
status Status @default(CREATED)
|
||||
statusOrder Int @default(0)
|
||||
|
||||
service QuotationService @relation(fields: [serviceId], references: [id])
|
||||
serviceId String
|
||||
|
||||
productOnWork QuotationServiceWorkProduct[]
|
||||
}
|
||||
|
||||
model QuotationServiceWorkProduct {
|
||||
order Int
|
||||
work QuotationServiceWork @relation(fields: [workId], references: [id])
|
||||
workId String
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
productId String
|
||||
|
||||
amount Int
|
||||
discount Float
|
||||
pricePerUnit Float
|
||||
|
||||
@@id([workId, productId])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue