search startDate and endDate

This commit is contained in:
Kanjana 2025-04-17 13:41:22 +07:00
parent ee610c5686
commit 0aba9f9865
20 changed files with 123 additions and 32 deletions

View file

@ -35,7 +35,7 @@ import {
} from "../utils/minio";
import { notFoundError } from "../utils/error";
import { CreditNotePaybackType, CreditNoteStatus, Prisma, RequestDataStatus } from "@prisma/client";
import { queryOrNot } from "../utils/relation";
import { queryOrNot, whereDateQuery } from "../utils/relation";
import { PaybackStatus, RequestWorkStatus } from "../generated/kysely/types";
const MANAGE_ROLES = [
@ -143,6 +143,8 @@ export class CreditNoteController extends Controller {
@Query() quotationId?: string,
@Query() creditNoteStatus?: CreditNoteStatus,
@Body() body?: {},
@Query() startDate?: Date,
@Query() endDate?: Date,
) {
const where = {
OR: queryOrNot<Prisma.CreditNoteWhereInput[]>(query, [
@ -199,6 +201,7 @@ export class CreditNoteController extends Controller {
},
},
},
...whereDateQuery(startDate, endDate),
} satisfies Prisma.CreditNoteWhereInput;
const [result, total] = await prisma.$transaction([