feat: customer groups for people and companies with tahesab group sync and bulk register
Multiple groups per contact, legacy group text migrated, excel import/export, contacts filter and column, richer create-in-tahesab, match-first bulk export
This commit is contained in:
@@ -160,6 +160,7 @@ model Organization {
|
||||
orgRoles OrgRole[]
|
||||
teams Team[]
|
||||
companies Company[]
|
||||
customerGroups CustomerGroup[]
|
||||
people Person[]
|
||||
attendanceEvents AttendanceEvent[]
|
||||
discAssessments DiscAssessment[]
|
||||
@@ -477,11 +478,13 @@ model Company {
|
||||
city String?
|
||||
postalCode String?
|
||||
address String?
|
||||
/// قدیمی؛ از نسخهٔ گروهبندی، گروهها در CompanyGroupLink هستند
|
||||
groupName String?
|
||||
notes String?
|
||||
registeredAt DateTime?
|
||||
tags String[] @default([])
|
||||
customFields Json @default("{}")
|
||||
groupLinks CompanyGroupLink[]
|
||||
people Person[]
|
||||
deals Deal[]
|
||||
activities Activity[]
|
||||
@@ -505,6 +508,51 @@ model Company {
|
||||
@@index([ownerId])
|
||||
}
|
||||
|
||||
/// گروه مشتری (مشترک بین اشخاص و شرکتها؛ هر مشتری چند گروه)
|
||||
model CustomerGroup {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
color String @default("teal")
|
||||
position Int @default(0)
|
||||
/// گروه متناظر در تهحساب (GID) روی همان اتصال
|
||||
tahesabConnectionId String?
|
||||
tahesabGid String?
|
||||
people PersonGroupLink[]
|
||||
companies CompanyGroupLink[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([organizationId, name])
|
||||
@@index([organizationId, position])
|
||||
@@index([tahesabConnectionId, tahesabGid])
|
||||
}
|
||||
|
||||
model PersonGroupLink {
|
||||
personId String
|
||||
person Person @relation(fields: [personId], references: [id], onDelete: Cascade)
|
||||
groupId String
|
||||
group CustomerGroup @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
/// manual | tahesab — گروهِ تهحسابی با همگامسازی جایگزین میشود؛ دستی دست نمیخورد
|
||||
source String @default("manual")
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@id([personId, groupId])
|
||||
@@index([groupId])
|
||||
}
|
||||
|
||||
model CompanyGroupLink {
|
||||
companyId String
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
groupId String
|
||||
group CustomerGroup @relation(fields: [groupId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@id([companyId, groupId])
|
||||
@@index([groupId])
|
||||
}
|
||||
|
||||
model Person {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
@@ -541,6 +589,7 @@ model Person {
|
||||
mood PersonMood @default(newcomer)
|
||||
tags String[] @default([])
|
||||
customFields Json @default("{}")
|
||||
groupLinks PersonGroupLink[]
|
||||
loyaltyPoints Int @default(0)
|
||||
loyaltyTierId String?
|
||||
loyaltyTier LoyaltyTier? @relation(fields: [loyaltyTierId], references: [id], onDelete: SetNull)
|
||||
|
||||
Reference in New Issue
Block a user