Let cheques be received or paid without an invoice, and remind staff three days before due date.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-11 11:34:49 +03:30
co-authored by Cursor
parent 9a991fc1f1
commit 9beaed96e8
18 changed files with 982 additions and 61 deletions
+19 -5
View File
@@ -213,6 +213,7 @@ model User {
salesGoals SalesGoal[] @relation("SalesGoalUser")
commissionPercent Decimal @default(0) @db.Decimal(8, 2)
commissionEntries CommissionEntry[]
receivedCheques Cheque[] @relation("ChequeOwner")
assignedTickets Ticket[] @relation("TicketAssignee")
reportedTickets Ticket[] @relation("TicketReporter")
ticketMessages TicketMessage[] @relation("TicketMessageAuthor")
@@ -291,6 +292,7 @@ model Person {
accountingLinks PersonAccountingLink[]
accountingDocuments AccountingDocumentLog[]
openingBalances PartyOpeningBalance[]
cheques Cheque[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -1284,26 +1286,38 @@ model CommissionEntry {
@@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)
paymentId String? @unique
payment Payment? @relation(fields: [paymentId], references: [id], onDelete: Cascade)
invoiceId String?
invoice Invoice? @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
personId String?
person Person? @relation(fields: [personId], references: [id], onDelete: SetNull)
ownerId String?
owner User? @relation("ChequeOwner", fields: [ownerId], references: [id], onDelete: SetNull)
amount Decimal @db.Decimal(18, 2)
currency String @default("IRR")
number String
bank String
dueDate DateTime
/// pending | cleared | bounced
status String @default("pending")
/// in = دریافتی، out = پرداختی
direction String @default("in")
reminderNotifiedAt DateTime?
notes String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([organizationId, status, dueDate])
@@index([organizationId, direction, dueDate])
@@index([invoiceId])
@@index([personId])
@@index([ownerId])
}
/// مانده اول دوره طرف‌حساب (مثبت = بدهکار ما)