1636 lines
44 KiB
Text
1636 lines
44 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
previewFeatures = ["relationJoins"]
|
|
}
|
|
|
|
generator kysely {
|
|
provider = "prisma-kysely"
|
|
output = "../src/generated/kysely"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Notification {
|
|
id String @id @default(cuid())
|
|
|
|
title String
|
|
detail String
|
|
|
|
groupReceiver NotificationGroup[]
|
|
|
|
receiver User? @relation(name: "NotificationReceiver", fields: [receiverId], references: [id], onDelete: Cascade)
|
|
receiverId String?
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
readByUser User[]
|
|
}
|
|
|
|
model NotificationGroup {
|
|
id String @id @default(cuid())
|
|
|
|
name String
|
|
|
|
notification Notification[]
|
|
}
|
|
|
|
model Menu {
|
|
id String @id @default(cuid())
|
|
|
|
caption String
|
|
captionEN String
|
|
menuType String
|
|
url String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
parent Menu? @relation(name: "MenuRelation", fields: [parentId], references: [id])
|
|
parentId String?
|
|
|
|
children Menu[] @relation(name: "MenuRelation")
|
|
roleMenuPermission RoleMenuPermission[]
|
|
userMenuPermission UserMenuPermission[]
|
|
userComponent MenuComponent[]
|
|
}
|
|
|
|
model RoleMenuPermission {
|
|
id String @id @default(cuid())
|
|
|
|
userRole String
|
|
permission String
|
|
|
|
menu Menu @relation(fields: [menuId], references: [id])
|
|
menuId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model UserMenuPermission {
|
|
id String @id @default(cuid())
|
|
|
|
permission String
|
|
|
|
menu Menu @relation(fields: [menuId], references: [id])
|
|
menuId String
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model MenuComponent {
|
|
id String @id @default(cuid())
|
|
|
|
componentId String
|
|
componentTag String
|
|
|
|
menu Menu @relation(fields: [menuId], references: [id])
|
|
menuId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
roleMenuComponentPermission RoleMenuComponentPermission[]
|
|
userMennuComponentPermission UserMenuComponentPermission[]
|
|
}
|
|
|
|
model RoleMenuComponentPermission {
|
|
id String @id @default(cuid())
|
|
|
|
userRole String
|
|
permission String
|
|
|
|
menuComponent MenuComponent @relation(fields: [menuComponentId], references: [id])
|
|
menuComponentId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model RunningNo {
|
|
key String @id @unique
|
|
value Int
|
|
}
|
|
|
|
model UserMenuComponentPermission {
|
|
id String @id @default(cuid())
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
menuComponent MenuComponent @relation(fields: [menuComponentId], references: [id])
|
|
menuComponentId String
|
|
|
|
permission String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Province {
|
|
id String @id @default(cuid())
|
|
name String
|
|
nameEN String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
district District[]
|
|
branch Branch[]
|
|
user User[]
|
|
customerBranch CustomerBranch[]
|
|
employee Employee[]
|
|
employeeCheckup EmployeeCheckup[]
|
|
customerBranchCitizen CustomerBranchCitizen[]
|
|
customerBranchHouseRegis CustomerBranchHouseRegis[]
|
|
institution Institution[]
|
|
employmentOffice EmploymentOffice[]
|
|
}
|
|
|
|
model District {
|
|
id String @id @default(cuid())
|
|
name String
|
|
nameEN String
|
|
|
|
provinceId String
|
|
province Province @relation(fields: [provinceId], references: [id], onDelete: Cascade)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
subDistrict SubDistrict[]
|
|
branch Branch[]
|
|
user User[]
|
|
customerBranch CustomerBranch[]
|
|
employee Employee[]
|
|
customerBranchCitizen CustomerBranchCitizen[]
|
|
customerBranchHouseRegis CustomerBranchHouseRegis[]
|
|
institution Institution[]
|
|
employmentOffice EmploymentOfficeDistrict[]
|
|
}
|
|
|
|
model SubDistrict {
|
|
id String @id @default(cuid())
|
|
name String
|
|
nameEN String
|
|
zipCode String
|
|
|
|
district District @relation(fields: [districtId], references: [id], onDelete: Cascade)
|
|
districtId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
branch Branch[]
|
|
user User[]
|
|
customerBranch CustomerBranch[]
|
|
employee Employee[]
|
|
customerBranchCitizen CustomerBranchCitizen[]
|
|
customerBranchHouseRegis CustomerBranchHouseRegis[]
|
|
institution Institution[]
|
|
}
|
|
|
|
model EmploymentOffice {
|
|
id String @id @default(cuid())
|
|
|
|
name String
|
|
nameEN String
|
|
|
|
provinceId String
|
|
province Province @relation(fields: [provinceId], references: [id])
|
|
|
|
district EmploymentOfficeDistrict[]
|
|
}
|
|
|
|
model EmploymentOfficeDistrict {
|
|
areaId String
|
|
area EmploymentOffice @relation(fields: [areaId], references: [id])
|
|
|
|
districtId String
|
|
district District @relation(fields: [districtId], references: [id])
|
|
|
|
@@id([areaId, districtId])
|
|
}
|
|
|
|
enum Status {
|
|
CREATED
|
|
ACTIVE
|
|
INACTIVE
|
|
}
|
|
|
|
model Branch {
|
|
id String @id @default(cuid())
|
|
code String
|
|
taxNo String
|
|
name String
|
|
nameEN String
|
|
telephoneNo String
|
|
|
|
permitNo String
|
|
permitIssueDate DateTime? @db.Date
|
|
permitExpireDate DateTime? @db.Date
|
|
|
|
address String
|
|
addressEN String
|
|
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
email String
|
|
contactName String?
|
|
lineId String?
|
|
webUrl String?
|
|
|
|
latitude String
|
|
longitude String
|
|
|
|
isHeadOffice Boolean @default(false)
|
|
|
|
headOffice Branch? @relation(name: "HeadOfficeRelation", fields: [headOfficeId], references: [id])
|
|
headOfficeId String?
|
|
|
|
virtual Boolean?
|
|
|
|
selectedImage String?
|
|
|
|
remark String?
|
|
|
|
bank BranchBank[]
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "BranchCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "BranchUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
branch Branch[] @relation(name: "HeadOfficeRelation")
|
|
contact BranchContact[]
|
|
user BranchUser[]
|
|
|
|
customerRegistration Customer[]
|
|
productGroup ProductGroup[]
|
|
quotation Quotation[]
|
|
workflowTemplate WorkflowTemplate[]
|
|
taskOrder TaskOrder[]
|
|
}
|
|
|
|
model BranchBank {
|
|
id String @id @default(cuid())
|
|
bankName String
|
|
bankBranch String
|
|
accountName String
|
|
accountNumber String
|
|
accountType String
|
|
currentlyUse Boolean
|
|
|
|
branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade)
|
|
branchId String
|
|
}
|
|
|
|
model BranchContact {
|
|
id String @id @default(cuid())
|
|
telephoneNo String
|
|
|
|
branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade)
|
|
branchId String
|
|
}
|
|
|
|
model BranchUser {
|
|
id String @id @default(cuid())
|
|
|
|
branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade)
|
|
branchId String
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "BranchUserCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "BranchUserUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
}
|
|
|
|
enum UserType {
|
|
USER
|
|
MESSENGER
|
|
DELEGATE
|
|
AGENCY
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
|
|
code String?
|
|
namePrefix String?
|
|
firstName String
|
|
firstNameEN String
|
|
middleName String?
|
|
middleNameEN String?
|
|
lastName String
|
|
lastNameEN String
|
|
username String
|
|
gender String
|
|
|
|
address String
|
|
addressEN String
|
|
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
email String
|
|
telephoneNo String
|
|
|
|
registrationNo String?
|
|
|
|
startDate DateTime? @db.Date
|
|
retireDate DateTime? @db.Date
|
|
|
|
checkpoint String?
|
|
checkpointEN String?
|
|
|
|
userType UserType
|
|
userRole String
|
|
|
|
citizenId String
|
|
citizenIssue DateTime @db.Date
|
|
citizenExpire DateTime? @db.Date
|
|
|
|
discountCondition String?
|
|
|
|
licenseNo String?
|
|
licenseIssueDate DateTime? @db.Date
|
|
licenseExpireDate DateTime? @db.Date
|
|
|
|
sourceNationality String?
|
|
importNationality String?
|
|
|
|
trainingPlace String?
|
|
responsibleArea UserResponsibleArea[]
|
|
|
|
birthDate DateTime? @db.Date
|
|
|
|
selectedImage String?
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "UserCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "UserUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
branch BranchUser[]
|
|
userMenuPermission UserMenuPermission[]
|
|
userMenuComponentPermission UserMenuComponentPermission[]
|
|
workflowTemplateStepUser WorkflowTemplateStepUser[]
|
|
requestWork RequestWork[]
|
|
customerBranch CustomerBranch[]
|
|
|
|
userCreated User[] @relation("UserCreatedByUser")
|
|
userUpdated User[] @relation("UserUpdatedByUser")
|
|
branchCreated Branch[] @relation("BranchCreatedByUser")
|
|
branchUpdated Branch[] @relation("BranchUpdatedByUser")
|
|
branchUserCreated BranchUser[] @relation("BranchUserCreatedByUser")
|
|
branchUserUpdated BranchUser[] @relation("BranchUserUpdatedByUser")
|
|
customerCreated Customer[] @relation("CustomerCreatedByUser")
|
|
customerUpdated Customer[] @relation("CustomerUpdatedByUser")
|
|
customerBranchCreated CustomerBranch[] @relation("CustomerBranchCreatedByUser")
|
|
customerBranchUpdated CustomerBranch[] @relation("CustomerBranchUpdatedByUser")
|
|
employeeCreated Employee[] @relation("EmployeeCreatedByUser")
|
|
employeeUpdated Employee[] @relation("EmployeeUpdatedByUser")
|
|
employeeHistoryUpdated EmployeeHistory[] @relation("EmployeeHistoryUpdatedByUser")
|
|
employeeCheckupCreated EmployeeCheckup[] @relation("EmployeeCheckupCreatedByUser")
|
|
employeeCheckupUpdated EmployeeCheckup[] @relation("EmployeeCheckupUpdatedByUser")
|
|
employeeWorkCreated EmployeeWork[] @relation("EmployeeWorkCreatedByUser")
|
|
employeeWorkUpdated EmployeeWork[] @relation("EmployeeWorkUpdatedByUser")
|
|
employeeOtherInfoCreated EmployeeOtherInfo[] @relation("EmployeeOtherInfoCreatedByUser")
|
|
employeeOtherInfoUpdated EmployeeOtherInfo[] @relation("EmployeeOtherInfoUpdatedByUser")
|
|
serviceCreated Service[] @relation("ServiceCreatedByUser")
|
|
serviceUpdated Service[] @relation("ServiceUpdatedByUser")
|
|
workCreated Work[] @relation("WorkCreatedByUser")
|
|
workUpdated Work[] @relation("WorkUpdatedByUser")
|
|
workProductCreated WorkProduct[] @relation("WorkProductCreatedByUser")
|
|
workProductUpdated WorkProduct[] @relation("WorkProductUpdatedByUser")
|
|
productGroupCreated ProductGroup[] @relation("ProductGroupCreatedByUser")
|
|
productGroupUpdated ProductGroup[] @relation("ProductGroupUpdatedByUser")
|
|
productCreated Product[] @relation("ProductCreatedByUser")
|
|
productUpdated Product[] @relation("ProductUpdatedByUser")
|
|
quotationCreated Quotation[] @relation("QuotationCreatedByUser")
|
|
quotationUpdated Quotation[] @relation("QuotationUpdatedByUser")
|
|
flowCreated WorkflowTemplate[] @relation("FlowCreatedByUser")
|
|
flowUpdated WorkflowTemplate[] @relation("FlowUpdatedByUser")
|
|
invoiceCreated Invoice[]
|
|
paymentCreated Payment[]
|
|
notificationReceive Notification[] @relation("NotificationReceiver")
|
|
notificationRead Notification[]
|
|
taskOrderCreated TaskOrder[] @relation("TaskOrderCreatedByUser")
|
|
creditNoteCreated CreditNote[] @relation("CreditNoteCreatedByUser")
|
|
|
|
requestWorkStepStatus RequestWorkStepStatus[]
|
|
userTask UserTask[]
|
|
}
|
|
|
|
model UserResponsibleArea {
|
|
id String @id @default(cuid())
|
|
area String
|
|
|
|
user User[]
|
|
}
|
|
|
|
enum CustomerType {
|
|
CORP
|
|
PERS
|
|
}
|
|
|
|
model Customer {
|
|
id String @id @default(cuid())
|
|
|
|
customerType CustomerType
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
registeredBranchId String
|
|
registeredBranch Branch @relation(fields: [registeredBranchId], references: [id])
|
|
|
|
selectedImage String?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "CustomerCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "CustomerUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
branch CustomerBranch[]
|
|
}
|
|
|
|
model CustomerBranch {
|
|
id String @id @default(cuid())
|
|
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
|
customerId String
|
|
customerName String?
|
|
|
|
code String
|
|
codeCustomer String
|
|
|
|
telephoneNo String
|
|
|
|
// NOTE: About (Natural Person)
|
|
namePrefix String?
|
|
firstName String?
|
|
firstNameEN String?
|
|
lastName String?
|
|
lastNameEN String?
|
|
gender String?
|
|
birthDate DateTime? @db.Date
|
|
citizenId String?
|
|
|
|
// NOTE: About (Legal Entity)
|
|
legalPersonNo String?
|
|
registerName String?
|
|
registerNameEN String?
|
|
registerDate DateTime? @db.Date
|
|
authorizedCapital String?
|
|
authorizedName String?
|
|
authorizedNameEN String?
|
|
|
|
// NOTE: Address
|
|
homeCode String
|
|
employmentOffice String
|
|
employmentOfficeEN String
|
|
address String
|
|
addressEN String
|
|
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
// NOTE: contact
|
|
email String
|
|
contactTel String
|
|
officeTel String
|
|
contactName String
|
|
agentUserId String?
|
|
agentUser User? @relation(fields: [agentUserId], references: [id], onDelete: SetNull)
|
|
|
|
// NOTE: Business
|
|
businessType String
|
|
jobPosition String
|
|
jobDescription String
|
|
payDate String
|
|
payDateEN String
|
|
wageRate Int
|
|
wageRateText String
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "CustomerBranchCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "CustomerBranchUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
employee Employee[]
|
|
quotation Quotation[]
|
|
|
|
citizen CustomerBranchCitizen[]
|
|
poa CustomerBranchPoa[]
|
|
houseRegis CustomerBranchHouseRegis[]
|
|
commercialRegis CustomerBranchCommercialRegis[]
|
|
vatRegis CustomerBranchVatRegis[]
|
|
}
|
|
|
|
model CustomerBranchCitizen {
|
|
id String @id @default(cuid())
|
|
citizenId String
|
|
birthDate DateTime? @db.Date
|
|
namePrefix String?
|
|
firstName String
|
|
firstNameEN String?
|
|
middleName String?
|
|
middleNameEN String?
|
|
lastName String
|
|
lastNameEN String?
|
|
issueDate DateTime @db.Date
|
|
expireDate DateTime @db.Date
|
|
nationality String
|
|
religion String
|
|
gender String
|
|
|
|
address String?
|
|
addressEN String?
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
customerBranchId String
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model CustomerBranchPoa {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
customerBranchId String
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model CustomerBranchHouseRegis {
|
|
id String @id @default(cuid())
|
|
|
|
registrationOffice String
|
|
houseId String
|
|
houseNo String
|
|
villageNo String
|
|
|
|
address String?
|
|
addressEN String?
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
namePrefix String?
|
|
firstName String
|
|
firstNameEN String?
|
|
middleName String?
|
|
middleNameEN String?
|
|
lastName String
|
|
lastNameEN String?
|
|
issueDate DateTime @db.Date
|
|
expireDate DateTime @db.Date
|
|
nationality String
|
|
religion String
|
|
gender String
|
|
marriageStatus String
|
|
citizenId String
|
|
birthDate DateTime @db.Date
|
|
motherFullName String
|
|
motherFullNameEN String?
|
|
motherCitizenId String
|
|
motherNationality String?
|
|
fatherFullName String
|
|
fatherFullNameEN String?
|
|
fatherCitizenId String
|
|
fatherNationality String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
customerBranchId String
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum CommercialType {
|
|
CORP
|
|
PERS
|
|
}
|
|
|
|
model CustomerBranchCommercialRegis {
|
|
id String @id @default(cuid())
|
|
registrationNo String
|
|
registrationType CommercialType
|
|
requestNo String? // NOTE: CORP only
|
|
namePrefix String? // NOTE: PERS only
|
|
fullName String
|
|
fullNameEN String
|
|
registrationDate String
|
|
romanLetter String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
customerBranchId String
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model CustomerBranchVatRegis {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
customerBranchId String
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Employee {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
nrcNo String?
|
|
|
|
namePrefix String?
|
|
firstName String
|
|
firstNameEN String
|
|
middleName String?
|
|
middleNameEN String?
|
|
lastName String
|
|
lastNameEN String
|
|
|
|
dateOfBirth DateTime @db.Date
|
|
gender String
|
|
nationality String
|
|
|
|
address String?
|
|
addressEN String?
|
|
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
workerType String?
|
|
workerStatus String?
|
|
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id], onDelete: Cascade)
|
|
customerBranchId String
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
selectedImage String?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "EmployeeCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "EmployeeUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
employeePassport EmployeePassport[]
|
|
employeeVisa EmployeeVisa[]
|
|
employeeCheckup EmployeeCheckup[]
|
|
employeeWork EmployeeWork[]
|
|
employeeOtherInfo EmployeeOtherInfo?
|
|
|
|
editHistory EmployeeHistory[]
|
|
quotationWorker QuotationWorker[]
|
|
quotationProductServiceWorker QuotationProductServiceWorker[]
|
|
requestData RequestData[]
|
|
}
|
|
|
|
model EmployeeHistory {
|
|
id String @id @default(cuid())
|
|
field String
|
|
valueBefore Json
|
|
valueAfter Json
|
|
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "EmployeeHistoryUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
masterId String
|
|
master Employee @relation(fields: [masterId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model EmployeePassport {
|
|
id String @id @default(cuid())
|
|
|
|
number String
|
|
type String
|
|
issueDate DateTime @db.Date
|
|
expireDate DateTime @db.Date
|
|
issueCountry String
|
|
issuePlace String
|
|
previousPassportRef String?
|
|
|
|
workerStatus String?
|
|
nationality String?
|
|
namePrefix String?
|
|
firstName String?
|
|
firstNameEN String?
|
|
middleName String?
|
|
middleNameEN String?
|
|
lastName String?
|
|
lastNameEN String?
|
|
gender String?
|
|
birthDate String?
|
|
birthCountry String?
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model EmployeeVisa {
|
|
id String @id @default(cuid())
|
|
|
|
number String
|
|
type String
|
|
entryCount Int
|
|
issueCountry String
|
|
issuePlace String
|
|
issueDate DateTime @db.Date
|
|
expireDate DateTime @db.Date
|
|
mrz String?
|
|
remark String?
|
|
|
|
arrivalTM String?
|
|
arrivalTMNo String?
|
|
arrivalAt String?
|
|
workerType String?
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model EmployeeCheckup {
|
|
id String @id @default(cuid())
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
checkupResult String?
|
|
checkupType String?
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
hospitalName String?
|
|
remark String?
|
|
medicalBenefitScheme String?
|
|
insuranceCompany String?
|
|
coverageStartDate DateTime? @db.Date
|
|
coverageExpireDate DateTime? @db.Date
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "EmployeeCheckupCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "EmployeeCheckupUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
}
|
|
|
|
model EmployeeWork {
|
|
id String @id @default(cuid())
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
ownerName String?
|
|
positionName String?
|
|
jobType String?
|
|
workplace String?
|
|
identityNo String?
|
|
workPermitNo String?
|
|
workPermitIssueDate DateTime? @db.Date
|
|
workPermitExpireDate DateTime? @db.Date
|
|
workPermitAt String?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "EmployeeWorkCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "EmployeeWorkUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
}
|
|
|
|
model EmployeeOtherInfo {
|
|
id String @id @default(cuid())
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String @unique
|
|
|
|
telephoneNo String?
|
|
citizenId String?
|
|
|
|
fatherBirthPlace String?
|
|
fatherFirstName String?
|
|
fatherLastName String?
|
|
motherBirthPlace String?
|
|
motherFirstName String?
|
|
motherLastName String?
|
|
|
|
fatherFirstNameEN String?
|
|
fatherLastNameEN String?
|
|
motherFirstNameEN String?
|
|
motherLastNameEN String?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "EmployeeOtherInfoCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "EmployeeOtherInfoUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
}
|
|
|
|
model Institution {
|
|
id String @id @default(cuid())
|
|
code String
|
|
group String // Use for grouping, but not use relation
|
|
name String
|
|
nameEN String
|
|
|
|
address String
|
|
addressEN String
|
|
|
|
soi String?
|
|
soiEN String?
|
|
moo String?
|
|
mooEN String?
|
|
street String?
|
|
streetEN String?
|
|
|
|
province Province @relation(fields: [provinceId], references: [id], onDelete: Cascade)
|
|
provinceId String
|
|
|
|
district District @relation(fields: [districtId], references: [id], onDelete: Cascade)
|
|
districtId String
|
|
|
|
subDistrict SubDistrict @relation(fields: [subDistrictId], references: [id], onDelete: Cascade)
|
|
subDistrictId String
|
|
|
|
selectedImage String?
|
|
|
|
taskOrder TaskOrder[]
|
|
}
|
|
|
|
model WorkflowTemplate {
|
|
id String @id @default(cuid())
|
|
name String
|
|
|
|
step WorkflowTemplateStep[]
|
|
|
|
registeredBranch Branch @relation(fields: [registeredBranchId], references: [id])
|
|
registeredBranchId String
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "FlowCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "FlowUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
service Service[]
|
|
}
|
|
|
|
model WorkflowTemplateStepInstitution {
|
|
id String @id @default(cuid())
|
|
|
|
group String
|
|
|
|
workflowTemplateStep WorkflowTemplateStep @relation(fields: [workflowTemplateStepId], references: [id], onDelete: Cascade)
|
|
workflowTemplateStepId String
|
|
}
|
|
|
|
model WorkflowTemplateStep {
|
|
id String @id @default(cuid())
|
|
|
|
order Int
|
|
name String
|
|
detail String?
|
|
type String?
|
|
value WorkflowTemplateStepValue[] // NOTE: For enum or options type
|
|
responsiblePerson WorkflowTemplateStepUser[]
|
|
responsibleInstitution WorkflowTemplateStepInstitution[]
|
|
messengerByArea Boolean @default(false)
|
|
|
|
attributes Json?
|
|
|
|
workflowTemplate WorkflowTemplate? @relation(fields: [workflowTemplateId], references: [id], onDelete: Cascade)
|
|
workflowTemplateId String?
|
|
}
|
|
|
|
model WorkflowTemplateStepValue {
|
|
id String @id @default(cuid())
|
|
|
|
value String
|
|
|
|
workflowTemplateStep WorkflowTemplateStep @relation(fields: [workflowTemplateStepId], references: [id])
|
|
workflowTemplateStepId String
|
|
}
|
|
|
|
model WorkflowTemplateStepUser {
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
workflowTemplateStep WorkflowTemplateStep @relation(fields: [workflowTemplateStepId], references: [id], onDelete: Cascade)
|
|
workflowTemplateStepId String
|
|
|
|
@@id([userId, workflowTemplateStepId])
|
|
}
|
|
|
|
model ProductGroup {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
remark String
|
|
shared Boolean @default(false)
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
registeredBranchId String
|
|
registeredBranch Branch @relation(fields: [registeredBranchId], references: [id])
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "ProductGroupCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "ProductGroupUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
service Service[]
|
|
product Product[]
|
|
}
|
|
|
|
model ProductDocument {
|
|
id String @id @default(cuid())
|
|
name String
|
|
|
|
product Product? @relation(fields: [productId], references: [id])
|
|
productId String?
|
|
}
|
|
|
|
model Product {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
process Int
|
|
price Float
|
|
agentPrice Float
|
|
serviceCharge Float
|
|
vatIncluded Boolean?
|
|
expenseType String?
|
|
|
|
calcVat Boolean @default(true)
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
shared Boolean @default(false)
|
|
|
|
remark String?
|
|
selectedImage String?
|
|
|
|
document ProductDocument[]
|
|
|
|
productGroup ProductGroup @relation(fields: [productGroupId], references: [id], onDelete: Cascade)
|
|
productGroupId String
|
|
|
|
workProduct WorkProduct[]
|
|
quotationProductServiceList QuotationProductServiceList[]
|
|
taskProduct TaskProduct[]
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "ProductCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "ProductUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
}
|
|
|
|
model Service {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
attributes Json?
|
|
installments Int @default(0)
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
workflowId String?
|
|
workflow WorkflowTemplate? @relation(fields: [workflowId], references: [id])
|
|
|
|
shared Boolean @default(false)
|
|
selectedImage String?
|
|
|
|
work Work[]
|
|
quotationProductServiceList QuotationProductServiceList[]
|
|
|
|
productGroup ProductGroup @relation(fields: [productGroupId], references: [id], onDelete: Cascade)
|
|
productGroupId String
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "ServiceCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "ServiceUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
}
|
|
|
|
model Work {
|
|
id String @id @default(cuid())
|
|
|
|
order Int
|
|
name String
|
|
attributes Json?
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
service Service? @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
|
serviceId String?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "WorkCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "WorkUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
productOnWork WorkProduct[]
|
|
quotationProductServiceList QuotationProductServiceList[]
|
|
}
|
|
|
|
model WorkProduct {
|
|
order Int
|
|
work Work @relation(fields: [workId], references: [id], onDelete: Cascade)
|
|
workId String
|
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
productId String
|
|
installmentNo Int @default(0)
|
|
stepCount Int @default(0)
|
|
attributes Json?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "WorkProductCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
updatedAt DateTime @updatedAt
|
|
updatedBy User? @relation(name: "WorkProductUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
|
|
updatedByUserId String?
|
|
|
|
@@id([workId, productId])
|
|
}
|
|
|
|
enum QuotationStatus {
|
|
Issued
|
|
Accepted
|
|
PaymentPending
|
|
PaymentInProcess // For Installments / Split Payment
|
|
PaymentSuccess
|
|
ProcessComplete
|
|
Canceled
|
|
Expired
|
|
}
|
|
|
|
enum PayCondition {
|
|
Full
|
|
Split
|
|
SplitCustom
|
|
BillFull
|
|
BillSplit
|
|
BillSplitCustom
|
|
}
|
|
|
|
model Quotation {
|
|
id String @id @default(cuid())
|
|
|
|
registeredBranch Branch @relation(fields: [registeredBranchId], references: [id])
|
|
registeredBranchId String
|
|
|
|
customerBranchId String
|
|
customerBranch CustomerBranch @relation(fields: [customerBranchId], references: [id])
|
|
|
|
status Status @default(CREATED)
|
|
statusOrder Int @default(0)
|
|
|
|
quotationStatus QuotationStatus @default(Issued)
|
|
|
|
remark String?
|
|
|
|
code String
|
|
|
|
workName String
|
|
contactName String
|
|
contactTel String
|
|
dueDate DateTime @db.Date
|
|
|
|
date DateTime @default(now())
|
|
payCondition PayCondition
|
|
|
|
paySplitCount Int?
|
|
paySplit QuotationPaySplit[]
|
|
|
|
payBillDate DateTime? @db.Date
|
|
|
|
worker QuotationWorker[]
|
|
|
|
workerMax Int?
|
|
|
|
urgent Boolean @default(false)
|
|
|
|
productServiceList QuotationProductServiceList[]
|
|
|
|
agentPrice Boolean @default(false)
|
|
|
|
totalPrice Float
|
|
totalDiscount Float
|
|
vat Float
|
|
vatExcluded Float @default(0)
|
|
discount Float @default(0)
|
|
finalPrice Float
|
|
|
|
isDebitNote Boolean @default(false)
|
|
debitNoteQuotationId String?
|
|
debitNoteQuotation Quotation? @relation(name: "QuotationDebitNote", fields: [debitNoteQuotationId], references: [id])
|
|
debitNote Quotation[] @relation(name: "QuotationDebitNote")
|
|
|
|
requestData RequestData[]
|
|
|
|
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?
|
|
|
|
invoice Invoice[]
|
|
creditNote CreditNote[]
|
|
}
|
|
|
|
model QuotationPaySplit {
|
|
id String @id @default(cuid())
|
|
|
|
no Int
|
|
name String?
|
|
amount Float
|
|
|
|
quotation Quotation? @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
|
quotationId String?
|
|
|
|
invoice Invoice? @relation(fields: [invoiceId], references: [id])
|
|
invoiceId String?
|
|
}
|
|
|
|
model QuotationWorker {
|
|
id String @id @default(cuid())
|
|
|
|
no Int
|
|
employee Employee @relation(fields: [employeeId], references: [id])
|
|
employeeId String
|
|
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
|
quotationId String
|
|
}
|
|
|
|
model QuotationProductServiceList {
|
|
id String @id @default(cuid())
|
|
quotationId String
|
|
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
|
|
|
order Int
|
|
|
|
vat Float
|
|
amount Int
|
|
discount Float
|
|
pricePerUnit Float
|
|
|
|
installmentNo Int?
|
|
|
|
productId String
|
|
product Product @relation(fields: [productId], references: [id])
|
|
|
|
workId String?
|
|
work Work? @relation(fields: [workId], references: [id])
|
|
|
|
serviceId String?
|
|
service Service? @relation(fields: [serviceId], references: [id])
|
|
|
|
attributes Json?
|
|
|
|
worker QuotationProductServiceWorker[]
|
|
requestWork RequestWork[]
|
|
}
|
|
|
|
model QuotationProductServiceWorker {
|
|
productService QuotationProductServiceList @relation(fields: [productServiceId], references: [id], onDelete: Cascade)
|
|
productServiceId String
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
@@id([productServiceId, employeeId])
|
|
}
|
|
|
|
model Invoice {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
|
|
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
|
quotationId String
|
|
|
|
installments QuotationPaySplit[]
|
|
|
|
amount Float?
|
|
|
|
payment Payment?
|
|
|
|
flowAccountRecordId String?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User @relation(fields: [createdByUserId], references: [id])
|
|
createdByUserId String
|
|
}
|
|
|
|
enum PaymentStatus {
|
|
PaymentWait
|
|
PaymentInProcess
|
|
PaymentRetry
|
|
PaymentSuccess
|
|
}
|
|
|
|
model Payment {
|
|
id String @id @default(cuid())
|
|
|
|
code String?
|
|
|
|
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
|
|
invoiceId String @unique
|
|
|
|
paymentStatus PaymentStatus
|
|
|
|
amount Float
|
|
date DateTime?
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
createdByUserId String?
|
|
}
|
|
|
|
enum RequestDataStatus {
|
|
Pending
|
|
Ready
|
|
InProgress
|
|
Completed
|
|
Canceled
|
|
}
|
|
|
|
model RequestData {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
|
quotationId String
|
|
|
|
requestDataStatus RequestDataStatus @default(Pending)
|
|
|
|
flow Json?
|
|
|
|
requestWork RequestWork[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
enum RequestWorkStatus {
|
|
Pending
|
|
Ready
|
|
Waiting
|
|
InProgress
|
|
Validate
|
|
Ended
|
|
Completed
|
|
Canceled
|
|
}
|
|
|
|
model RequestWork {
|
|
id String @id @default(cuid())
|
|
|
|
request RequestData @relation(fields: [requestDataId], references: [id], onDelete: Cascade)
|
|
requestDataId String
|
|
|
|
productService QuotationProductServiceList @relation(fields: [productServiceId], references: [id], onDelete: Cascade)
|
|
productServiceId String
|
|
|
|
processByUser User? @relation(fields: [processByUserId], references: [id])
|
|
processByUserId String?
|
|
|
|
attributes Json?
|
|
|
|
stepStatus RequestWorkStepStatus[]
|
|
|
|
creditNote CreditNote? @relation(fields: [creditNoteId], references: [id], onDelete: SetNull)
|
|
creditNoteId String?
|
|
}
|
|
|
|
model RequestWorkStepStatus {
|
|
step Int
|
|
workStatus RequestWorkStatus @default(Pending)
|
|
|
|
requestWork RequestWork @relation(fields: [requestWorkId], references: [id], onDelete: Cascade)
|
|
requestWorkId String
|
|
|
|
attributes Json?
|
|
|
|
customerDuty Boolean?
|
|
customerDutyCost Float?
|
|
companyDuty Boolean?
|
|
companyDutyCost Float?
|
|
individualDuty Boolean?
|
|
individualDutyCost Float?
|
|
|
|
responsibleUserLocal Boolean?
|
|
responsibleUserId String?
|
|
responsibleUser User? @relation(fields: [responsibleUserId], references: [id], onDelete: SetNull)
|
|
|
|
task Task[]
|
|
|
|
@@id([step, requestWorkId])
|
|
}
|
|
|
|
enum TaskOrderStatus {
|
|
Pending
|
|
InProgress
|
|
Validate
|
|
Complete
|
|
Canceled
|
|
}
|
|
|
|
enum TaskStatus {
|
|
Pending
|
|
InProgress
|
|
|
|
Success
|
|
Failed
|
|
Restart
|
|
Redo
|
|
|
|
Validate
|
|
|
|
Complete
|
|
Canceled
|
|
}
|
|
|
|
model Task {
|
|
id String @id @default(cuid())
|
|
|
|
taskStatus TaskStatus @default(Pending)
|
|
|
|
step Int
|
|
requestWorkId String
|
|
requestWorkStep RequestWorkStepStatus @relation(fields: [step, requestWorkId], references: [step, requestWorkId])
|
|
|
|
failedType String?
|
|
failedComment String?
|
|
|
|
taskOrder TaskOrder @relation(fields: [taskOrderId], references: [id], onDelete: Cascade)
|
|
taskOrderId String
|
|
}
|
|
|
|
model TaskProduct {
|
|
taskOrderId String
|
|
taskOrder TaskOrder @relation(fields: [taskOrderId], references: [id], onDelete: Cascade)
|
|
productId String
|
|
product Product @relation(fields: [productId], references: [id])
|
|
discount Float?
|
|
|
|
@@id([taskOrderId, productId])
|
|
}
|
|
|
|
model TaskOrder {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
|
|
taskName String
|
|
taskOrderStatus TaskOrderStatus @default(Pending)
|
|
taskList Task[]
|
|
|
|
remark String?
|
|
|
|
contactName String
|
|
contactTel String
|
|
|
|
urgent Boolean @default(false)
|
|
|
|
institution Institution @relation(fields: [institutionId], references: [id])
|
|
institutionId String
|
|
|
|
registeredBranch Branch @relation(fields: [registeredBranchId], references: [id])
|
|
registeredBranchId String
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "TaskOrderCreatedByUser", fields: [createdByUserId], references: [id])
|
|
createdByUserId String?
|
|
|
|
userTask UserTask[]
|
|
taskProduct TaskProduct[]
|
|
}
|
|
|
|
enum UserTaskStatus {
|
|
Pending // Should not be use but define here for type
|
|
Restart
|
|
Accept
|
|
Submit
|
|
}
|
|
|
|
model UserTask {
|
|
id String @id @default(cuid())
|
|
|
|
userTaskStatus UserTaskStatus
|
|
|
|
taskOrder TaskOrder @relation(fields: [taskOrderId], references: [id], onDelete: Cascade)
|
|
taskOrderId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
|
|
acceptedAt DateTime?
|
|
submittedAt DateTime?
|
|
}
|
|
|
|
enum CreditNoteStatus {
|
|
Pending
|
|
Success
|
|
}
|
|
|
|
enum CreditNotePaybackType {
|
|
Cash
|
|
BankTransfer
|
|
}
|
|
|
|
enum PaybackStatus {
|
|
Pending
|
|
Verify
|
|
Done
|
|
}
|
|
|
|
model CreditNote {
|
|
id String @id @default(cuid())
|
|
|
|
code String
|
|
|
|
creditNoteStatus CreditNoteStatus @default(Pending)
|
|
|
|
value Float @default(0)
|
|
reason String?
|
|
detail String?
|
|
remark String?
|
|
|
|
paybackType CreditNotePaybackType?
|
|
paybackBank String?
|
|
paybackAccount String?
|
|
paybackAccountName String?
|
|
paybackStatus PaybackStatus @default(Pending)
|
|
paybackDate DateTime?
|
|
|
|
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
|
|
quotationId String
|
|
|
|
// NOTE: only status cancel
|
|
requestWork RequestWork[]
|
|
|
|
createdAt DateTime @default(now())
|
|
createdBy User? @relation(name: "CreditNoteCreatedByUser", fields: [createdByUserId], references: [id])
|
|
createdByUserId String?
|
|
}
|