refactor!: payment sys

This commit is contained in:
Methapon Metanipat 2024-10-25 13:58:29 +07:00
parent 3cbc157028
commit 02e17fcde4
7 changed files with 675 additions and 279 deletions

View file

@ -423,6 +423,8 @@ model User {
quotationUpdated Quotation[] @relation("QuotationUpdatedByUser")
flowCreated WorkflowTemplate[] @relation("FlowCreatedByUser")
flowUpdated WorkflowTemplate[] @relation("FlowUpdatedByUser")
invoiceCreated Invoice[]
paymentCreated Payment[]
}
enum CustomerType {
@ -1106,8 +1108,7 @@ model Quotation {
status Status @default(CREATED)
statusOrder Int @default(0)
quotationStatus QuotationStatus @default(PaymentPending)
quotationPaymentData QuotationPayment[]
quotationStatus QuotationStatus @default(PaymentPending)
remark String?
@ -1152,26 +1153,8 @@ model Quotation {
updatedAt DateTime @updatedAt
updatedBy User? @relation(name: "QuotationUpdatedByUser", fields: [updatedByUserId], references: [id], onDelete: SetNull)
updatedByUserId String?
}
enum PaymentStatus {
PaymentWait
PaymentInProcess
PaymentRetry
PaymentSuccess
}
model QuotationPayment {
id String @id @default(cuid())
paymentStatus PaymentStatus
date DateTime
amount Float
remark String?
quotation Quotation @relation(fields: [quotationId], references: [id], onDelete: Cascade)
quotationId String
invoice Invoice[]
}
model QuotationPaySplit {
@ -1221,6 +1204,9 @@ model QuotationProductServiceList {
worker QuotationProductServiceWorker[]
requestWork RequestWork[]
invoice Invoice? @relation(fields: [invoiceId], references: [id])
invoiceId String?
}
model QuotationProductServiceWorker {
@ -1233,6 +1219,46 @@ model QuotationProductServiceWorker {
@@id([productServiceId, employeeId])
}
model Invoice {
id String @id @default(cuid())
quotation Quotation @relation(fields: [quotationId], references: [id])
quotationId String
productServiceList QuotationProductServiceList[]
amount Float?
payment Payment?
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())
invoice Invoice @relation(fields: [invoiceId], references: [id])
invoiceId String @unique
paymentStatus PaymentStatus
amount Float
date DateTime?
createdAt DateTime @default(now())
createdBy User? @relation(fields: [createdByUserId], references: [id])
createdByUserId String?
}
model RequestData {
id String @id @default(cuid())