Add salesperson commissions on issued invoices and a cheque register.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -183,6 +183,8 @@ model Organization {
|
||||
warehouses Warehouse[]
|
||||
stockMovements StockMovement[]
|
||||
partyOpenings PartyOpeningBalance[]
|
||||
commissionEntries CommissionEntry[]
|
||||
cheques Cheque[]
|
||||
}
|
||||
|
||||
model User {
|
||||
@@ -209,6 +211,8 @@ model User {
|
||||
noteAttachments NoteAttachment[] @relation("NoteAttachmentUploader")
|
||||
notifications Notification[]
|
||||
salesGoals SalesGoal[] @relation("SalesGoalUser")
|
||||
commissionPercent Decimal @default(0) @db.Decimal(8, 2)
|
||||
commissionEntries CommissionEntry[]
|
||||
assignedTickets Ticket[] @relation("TicketAssignee")
|
||||
reportedTickets Ticket[] @relation("TicketReporter")
|
||||
ticketMessages TicketMessage[] @relation("TicketMessageAuthor")
|
||||
@@ -731,6 +735,10 @@ model Invoice {
|
||||
payments Payment[]
|
||||
installments InvoiceInstallment[]
|
||||
stockMovements StockMovement[]
|
||||
commissionPercent Decimal? @db.Decimal(8, 2)
|
||||
commissionFixedAmount Decimal? @db.Decimal(18, 2)
|
||||
commissionEntry CommissionEntry?
|
||||
cheques Cheque[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -772,6 +780,7 @@ model Payment {
|
||||
notes String?
|
||||
installmentId String? @unique
|
||||
installment InvoiceInstallment? @relation(fields: [installmentId], references: [id], onDelete: SetNull)
|
||||
cheque Cheque?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -1254,6 +1263,49 @@ model StockMovement {
|
||||
@@index([warehouseId])
|
||||
}
|
||||
|
||||
/// پورسانت کارشناس بعد از صدور فاکتور
|
||||
model CommissionEntry {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
invoiceId String @unique
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
|
||||
percent Decimal @db.Decimal(8, 2)
|
||||
amount Decimal @db.Decimal(18, 2)
|
||||
currency String @default("IRR")
|
||||
/// posted | void
|
||||
status String @default("posted")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([organizationId, userId, createdAt])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
/// چک دریافتی وصل به پرداخت فاکتور
|
||||
model Cheque {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
paymentId String @unique
|
||||
payment Payment @relation(fields: [paymentId], references: [id], onDelete: Cascade)
|
||||
invoiceId String
|
||||
invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
|
||||
number String
|
||||
bank String
|
||||
dueDate DateTime
|
||||
/// pending | cleared | bounced
|
||||
status String @default("pending")
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([organizationId, status, dueDate])
|
||||
@@index([invoiceId])
|
||||
}
|
||||
|
||||
/// مانده اول دوره طرفحساب (مثبت = بدهکار ما)
|
||||
model PartyOpeningBalance {
|
||||
id String @id @default(cuid())
|
||||
|
||||
Reference in New Issue
Block a user