diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index fb5d20c..d6832d6 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -185,17 +185,22 @@ export class QuotationController extends Controller { @Request() req: RequestWithUser, @Query() page: number = 1, @Query() pageSize: number = 30, + @Query() payCondition?: PayCondition, ) { + const where = { + payCondition, + customerBranch: { + customer: { + registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) }, + }, + }, + } satisfies Prisma.QuotationWhereInput; + const [result, total] = await prisma.$transaction([ prisma.quotation.findMany({ - where: { - customerBranch: { - customer: { - registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) }, - }, - }, - }, + where, include: { + customerBranch: true, worker: true, service: { include: { @@ -209,7 +214,7 @@ export class QuotationController extends Controller { }, }, }), - prisma.quotation.count(), + prisma.quotation.count({ where }), ]); return { result: result, page, pageSize, total };