Merge branch 'develop'

This commit is contained in:
Methapon2001 2025-09-18 09:50:52 +07:00
commit 4691d559f5

View file

@ -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<Prisma.CustomerWhereInput[]>(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");