diff --git a/src/controllers/03-customer-controller.ts b/src/controllers/03-customer-controller.ts index 1854842..95e2df6 100644 --- a/src/controllers/03-customer-controller.ts +++ b/src/controllers/03-customer-controller.ts @@ -170,6 +170,10 @@ export class CustomerController extends Controller { @Query() activeBranchOnly?: boolean, @Query() startDate?: Date, @Query() endDate?: Date, + @Query() businessType?: string, + @Query() province?: string, + @Query() district?: string, + @Query() subDistrict?: string, ) { const where = { OR: queryOrNot(query, [ @@ -192,6 +196,35 @@ export class CustomerController extends Controller { : permissionCond(req.user, { activeOnly: activeBranchOnly }), }, }, + branch: { + some: { + AND: [ + businessType + ? { + OR: [{ businessType: { id: businessType } }], + } + : {}, + + province + ? { + OR: [{ province: { id: province } }], + } + : {}, + + district + ? { + OR: [{ district: { id: district } }], + } + : {}, + + subDistrict + ? { + OR: [{ subDistrict: { id: subDistrict } }], + } + : {}, + ], + }, + }, ...whereDateQuery(startDate, endDate), } satisfies Prisma.CustomerWhereInput; @@ -597,6 +630,10 @@ export class CustomerExportController extends CustomerController { @Query() activeBranchOnly?: boolean, @Query() startDate?: Date, @Query() endDate?: Date, + @Query() businessType?: string, + @Query() province?: string, + @Query() district?: string, + @Query() subDistrict?: string, ) { const ret = await this.list( req, @@ -610,6 +647,10 @@ export class CustomerExportController extends CustomerController { activeBranchOnly, startDate, endDate, + businessType, + province, + district, + subDistrict, ); this.setHeader("Content-Type", "text/csv");