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 (matched) {
|
||||||
if (existing) {
|
if (!existing) {
|
||||||
const alreadyOpen =
|
await this.prisma.activity.create({
|
||||||
existing.status === 'open' && existing.stageId === input.openStageId;
|
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({
|
await this.prisma.activity.update({
|
||||||
where: { id: existing.id },
|
where: { id: existing.id },
|
||||||
data: {
|
data: {
|
||||||
status: 'open',
|
status: 'open',
|
||||||
stageId: input.openStageId,
|
stageId: input.openStageId,
|
||||||
completedAt: null,
|
completedAt: null,
|
||||||
|
completedByIds: [],
|
||||||
assigneeId: input.person.assigneeId,
|
assigneeId: input.person.assigneeId,
|
||||||
assignees: { set: [{ id: input.person.assigneeId }] },
|
assignees: { set: [{ id: input.person.assigneeId }] },
|
||||||
title: `مطالبه: ${input.person.fullName}`,
|
title,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return alreadyOpen && existing.assigneeId === input.person.assigneeId
|
return 'reopened';
|
||||||
? 'matched-unchanged'
|
|
||||||
: 'reopened';
|
|
||||||
}
|
}
|
||||||
await this.prisma.activity.create({
|
|
||||||
|
// هنوز داخل بازه: ستون و وضعیت (در حال انجام / انجامشده) حفظ شود
|
||||||
|
await this.prisma.activity.update({
|
||||||
|
where: { id: existing.id },
|
||||||
data: {
|
data: {
|
||||||
organizationId: input.organizationId,
|
title,
|
||||||
boardId: input.boardId,
|
...(existing.assigneeId !== input.person.assigneeId
|
||||||
stageId: input.openStageId,
|
? {
|
||||||
status: 'open',
|
assigneeId: input.person.assigneeId,
|
||||||
title: `مطالبه: ${input.person.fullName}`,
|
assignees: { set: [{ id: input.person.assigneeId }] },
|
||||||
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';
|
return 'matched-unchanged';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existing && existing.status !== 'canceled') {
|
if (existing && existing.status !== 'canceled') {
|
||||||
|
|||||||
Reference in New Issue
Block a user