feat: notify request, task update
This commit is contained in:
parent
afb4a83efa
commit
17b92b4012
2 changed files with 137 additions and 105 deletions
|
|
@ -1136,7 +1136,9 @@ export class QuotationActionController extends Controller {
|
||||||
},
|
},
|
||||||
update: { value: { increment: quotation.worker.length } },
|
update: { value: { increment: quotation.worker.length } },
|
||||||
});
|
});
|
||||||
await tx.quotation.update({
|
await tx.quotation
|
||||||
|
.update({
|
||||||
|
include: { requestData: true },
|
||||||
where: { id: quotationId, isDebitNote: false },
|
where: { id: quotationId, isDebitNote: false },
|
||||||
data: {
|
data: {
|
||||||
quotationStatus: QuotationStatus.PaymentSuccess, // NOTE: change back if already complete or canceled
|
quotationStatus: QuotationStatus.PaymentSuccess, // NOTE: change back if already complete or canceled
|
||||||
|
|
@ -1170,6 +1172,16 @@ export class QuotationActionController extends Controller {
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
.then(async (ret) => {
|
||||||
|
await prisma.notification.create({
|
||||||
|
data: {
|
||||||
|
title: "New Request",
|
||||||
|
detail: "New request: " + ret.requestData.map((v) => v.code).join(", "),
|
||||||
|
registeredBranchId: ret.registeredBranchId,
|
||||||
|
groupReceiver: { create: { name: "document_checker" } },
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -433,7 +433,8 @@ export class TaskController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await prisma.$transaction(async (tx) => {
|
return await prisma
|
||||||
|
.$transaction(async (tx) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
record.taskList
|
record.taskList
|
||||||
.filter(
|
.filter(
|
||||||
|
|
@ -514,6 +515,18 @@ export class TaskController extends Controller {
|
||||||
taskProduct: { deleteMany: {}, create: body.taskProduct },
|
taskProduct: { deleteMany: {}, create: body.taskProduct },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.then(async (ret) => {
|
||||||
|
if (body.taskOrderStatus && record.taskOrderStatus !== body.taskOrderStatus) {
|
||||||
|
await prisma.notification.create({
|
||||||
|
data: {
|
||||||
|
title: "Task Submitted",
|
||||||
|
detail: "Task submitted in order: " + record.code,
|
||||||
|
receiverId: record.createdByUserId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -651,6 +664,13 @@ export class TaskActionController extends Controller {
|
||||||
},
|
},
|
||||||
data: { userTaskStatus: UserTaskStatus.Submit, submittedAt: new Date() },
|
data: { userTaskStatus: UserTaskStatus.Submit, submittedAt: new Date() },
|
||||||
}),
|
}),
|
||||||
|
prisma.notification.create({
|
||||||
|
data: {
|
||||||
|
title: "Task Submitted",
|
||||||
|
detail: "Task submitted in order: " + record.code,
|
||||||
|
receiverId: record.createdByUserId,
|
||||||
|
},
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue