Add account balance claims board with opt-in module and range settings.

EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-17 21:24:15 +03:30
co-authored by Cursor
parent 634af8a653
commit de23e4d505
16 changed files with 1162 additions and 14 deletions
@@ -0,0 +1,22 @@
-- AlterTable
ALTER TABLE "Organization" ADD COLUMN "accountBalanceSettings" JSONB NOT NULL DEFAULT '{}';
ALTER TABLE "Organization" ADD COLUMN "accountBalanceClaimsLastSlot" TEXT;
-- AlterTable
ALTER TABLE "CustomerGroup" ADD COLUMN "assigneeIds" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[];
-- Backfill ordered assignee ids from existing M2M (alphabetical until re-saved)
UPDATE "CustomerGroup" AS g
SET "assigneeIds" = COALESCE((
SELECT ARRAY_AGG(link."B" ORDER BY u."fullName")
FROM "_CustomerGroupAssignees" AS link
INNER JOIN "User" AS u ON u."id" = link."B"
WHERE link."A" = g."id"
), ARRAY[]::TEXT[])
WHERE COALESCE(cardinality(g."assigneeIds"), 0) = 0;
-- AlterTable
ALTER TABLE "ActivityBoard" ADD COLUMN "systemKey" TEXT;
-- CreateIndex (NULLs allowed multiple times in PostgreSQL)
CREATE UNIQUE INDEX "ActivityBoard_organizationId_systemKey_key" ON "ActivityBoard"("organizationId", "systemKey");
+9
View File
@@ -164,6 +164,10 @@ model Organization {
enabledModules String[] @default([])
/// برچسب/رنگ اولویت فعالیت و روتین (کلیدهای enum ثابت؛ فقط ظاهر)
activityPriorities Json @default("{}")
/// تنظیم محدوده مانده حساب برای کاریز مطالبات
accountBalanceSettings Json @default("{}")
/// آخرین اسلات اجرای جاب مطالبات مانده (YYYY-MM-DD-HH تهران)
accountBalanceClaimsLastSlot String?
/// قالب‌های آمادهٔ پیامک دستی ([{ id, name, body }, …])
smsTemplates Json @default("[]")
/// تاریخ قطع بایگانی اطلاعات قبل (شروع روز انتخاب‌شده)؛ null = بدون فیلتر
@@ -583,6 +587,8 @@ model CustomerGroup {
companies CompanyGroupLink[]
/// مسئولان گروه — اختیاری؛ اعضای گروه را مثل مشتریان خود می‌بینند
assignees User[] @relation("CustomerGroupAssignees")
/// ترتیب انتخاب مسئولان در فرم (اولین = مسئول اصلی مطالبات)
assigneeIds String[] @default([])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -813,6 +819,8 @@ model ActivityBoard {
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
name String
isDefault Boolean @default(false)
/// مثلاً balance_claims — گروه سیستمی
systemKey String?
position Int @default(0)
stages ActivityStage[]
activities Activity[]
@@ -821,6 +829,7 @@ model ActivityBoard {
updatedAt DateTime @updatedAt
@@unique([organizationId, name])
@@unique([organizationId, systemKey])
@@index([organizationId, position])
}