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
@@ -51,7 +51,7 @@ export class CustomerGroupsService {
include: {
_count: { select: { people: true, companies: true } },
parent: { select: { name: true } },
assignees: { select: { id: true, fullName: true }, orderBy: { fullName: 'asc' } },
assignees: { select: { id: true, fullName: true } },
},
});
return rows.map((r) => this.toDto(r));
@@ -77,6 +77,7 @@ export class CustomerGroupsService {
name,
color: this.cleanColor(dto.color),
position: (max._max.position ?? -1) + 1,
assigneeIds,
...(assigneeIds.length
? { assignees: { connect: assigneeIds.map((id) => ({ id })) } }
: {}),
@@ -116,7 +117,10 @@ export class CustomerGroupsService {
...(dto.color != null ? { color: this.cleanColor(dto.color) } : {}),
...(parentId !== undefined ? { parentId } : {}),
...(assigneeIds !== undefined
? { assignees: { set: assigneeIds.map((uid) => ({ id: uid })) } }
? {
assigneeIds,
assignees: { set: assigneeIds.map((uid) => ({ id: uid })) },
}
: {}),
},
});
@@ -336,8 +340,15 @@ export class CustomerGroupsService {
parentId: string | null;
parent?: { name: string } | null;
_count: { people: number; companies: number };
assigneeIds: string[];
assignees: Array<{ id: string; fullName: string }>;
}): CustomerGroupDto {
const order = new Map(r.assigneeIds.map((id, index) => [id, index]));
const assignees = [...r.assignees].sort((a, b) => {
const ai = order.get(a.id) ?? Number.MAX_SAFE_INTEGER;
const bi = order.get(b.id) ?? Number.MAX_SAFE_INTEGER;
return ai - bi || a.fullName.localeCompare(b.fullName, 'fa');
});
return {
id: r.id,
name: r.name,
@@ -348,7 +359,8 @@ export class CustomerGroupsService {
companyCount: r._count.companies,
parentId: r.parentId,
parentName: r.parent?.name ?? null,
assignees: r.assignees.map((a) => ({ id: a.id, fullName: a.fullName })),
assigneeIds: assignees.map((a) => a.id),
assignees: assignees.map((a) => ({ id: a.id, fullName: a.fullName })),
};
}
@@ -366,7 +378,8 @@ export class CustomerGroupsService {
if (rows.length !== unique.length) {
throw new BadRequestException('یکی از مسئولان انتخاب‌شده معتبر نیست');
}
return rows.map((r) => r.id);
const found = new Set(rows.map((r) => r.id));
return unique.filter((id) => found.has(id));
}
private async require(organizationId: string, id: string) {