Preserve claims board stages on evaluate; reopen to first column only after cancel.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -561,45 +561,64 @@ export class BalanceClaimsService {
|
||||
},
|
||||
});
|
||||
|
||||
const title = `مطالبه: ${input.person.fullName}`;
|
||||
|
||||
if (matched) {
|
||||
if (existing) {
|
||||
const alreadyOpen =
|
||||
existing.status === 'open' && existing.stageId === input.openStageId;
|
||||
if (!existing) {
|
||||
await this.prisma.activity.create({
|
||||
data: {
|
||||
organizationId: input.organizationId,
|
||||
boardId: input.boardId,
|
||||
stageId: input.openStageId,
|
||||
status: 'open',
|
||||
title,
|
||||
type: input.baseType,
|
||||
typeDefId: input.typeDefId,
|
||||
personId: input.person.personId,
|
||||
assigneeId: input.person.assigneeId,
|
||||
assignees: { connect: [{ id: input.person.assigneeId }] },
|
||||
tags: [ACCOUNT_BALANCE_CLAIMS_TAG],
|
||||
editPolicy: 'assignees',
|
||||
completionMode: 'any',
|
||||
completedByIds: [],
|
||||
createdById: input.person.assigneeId,
|
||||
},
|
||||
});
|
||||
return 'created';
|
||||
}
|
||||
|
||||
// فقط بعد از خروج از بازه (لغو) دوباره از ستون اول بیاید؛
|
||||
// ستونهای میانی / انجامشده حفظ میشوند.
|
||||
if (existing.status === 'canceled') {
|
||||
await this.prisma.activity.update({
|
||||
where: { id: existing.id },
|
||||
data: {
|
||||
status: 'open',
|
||||
stageId: input.openStageId,
|
||||
completedAt: null,
|
||||
completedByIds: [],
|
||||
assigneeId: input.person.assigneeId,
|
||||
assignees: { set: [{ id: input.person.assigneeId }] },
|
||||
title: `مطالبه: ${input.person.fullName}`,
|
||||
title,
|
||||
},
|
||||
});
|
||||
return alreadyOpen && existing.assigneeId === input.person.assigneeId
|
||||
? 'matched-unchanged'
|
||||
: 'reopened';
|
||||
return 'reopened';
|
||||
}
|
||||
await this.prisma.activity.create({
|
||||
|
||||
// هنوز داخل بازه: ستون و وضعیت (در حال انجام / انجامشده) حفظ شود
|
||||
await this.prisma.activity.update({
|
||||
where: { id: existing.id },
|
||||
data: {
|
||||
organizationId: input.organizationId,
|
||||
boardId: input.boardId,
|
||||
stageId: input.openStageId,
|
||||
status: 'open',
|
||||
title: `مطالبه: ${input.person.fullName}`,
|
||||
type: input.baseType,
|
||||
typeDefId: input.typeDefId,
|
||||
personId: input.person.personId,
|
||||
assigneeId: input.person.assigneeId,
|
||||
assignees: { connect: [{ id: input.person.assigneeId }] },
|
||||
tags: [ACCOUNT_BALANCE_CLAIMS_TAG],
|
||||
editPolicy: 'assignees',
|
||||
completionMode: 'any',
|
||||
completedByIds: [],
|
||||
createdById: input.person.assigneeId,
|
||||
title,
|
||||
...(existing.assigneeId !== input.person.assigneeId
|
||||
? {
|
||||
assigneeId: input.person.assigneeId,
|
||||
assignees: { set: [{ id: input.person.assigneeId }] },
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
return 'created';
|
||||
return 'matched-unchanged';
|
||||
}
|
||||
|
||||
if (existing && existing.status !== 'canceled') {
|
||||
|
||||
Reference in New Issue
Block a user