From 447a99e4f77e5e409c9bc62a575b0fb561f30c80 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 24 Oct 2024 15:29:09 +0700 Subject: [PATCH] feat: search quotation now cover customer name and code --- src/controllers/05-quotation-controller.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index 02d16e8..40a9738 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -183,7 +183,22 @@ export class QuotationController extends Controller { @Query() query = "", ) { const where = { - OR: [{ code: { contains: query, mode: "insensitive" } }, { workName: { contains: query } }], + OR: [ + { code: { contains: query, mode: "insensitive" } }, + { workName: { contains: query } }, + { + customerBranch: { + OR: [ + { code: { contains: query, mode: "insensitive" } }, + { customerName: { contains: query } }, + { firstName: { contains: query } }, + { firstNameEN: { contains: query } }, + { lastName: { contains: query } }, + { lastNameEN: { contains: query } }, + ], + }, + }, + ], payCondition, registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) }, } satisfies Prisma.QuotationWhereInput;