feat: add cancel only and quotation id filter

This commit is contained in:
Methapon2001 2025-01-09 10:26:56 +07:00
parent 659fb325b1
commit d37f527f7d

View file

@ -292,6 +292,8 @@ export class RequestListController extends Controller {
@Query() requestDataId?: string,
@Query() workStatus?: RequestWorkStatus,
@Query() readyToTask?: boolean,
@Query() cancelOnly?: boolean,
@Query() quotationId?: string,
) {
let statusCondition: Prisma.RequestWorkWhereInput["stepStatus"] = {};
@ -313,7 +315,15 @@ export class RequestListController extends Controller {
],
},
};
} else {
}
if (cancelOnly) {
statusCondition = {
some: { workStatus: RequestWorkStatus.Canceled },
};
}
if (workStatus && !readyToTask && !cancelOnly) {
statusCondition = {
some: { workStatus },
};
@ -321,8 +331,10 @@ export class RequestListController extends Controller {
const where = {
stepStatus: readyToTask || workStatus ? statusCondition : undefined,
creditNote: cancelOnly ? null : undefined,
request: {
id: requestDataId,
quotationId,
quotation: {
registeredBranch: { OR: permissionCond(req.user) },
},