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

@ -36,7 +36,7 @@ import {
setFile,
} from "../utils/minio";
import { isUsedError, notFoundError, relationError } from "../utils/error";
import { queryOrNot } from "../utils/relation";
import { queryOrNot, whereDateQuery } from "../utils/relation";
import { isSystem } from "../utils/keycloak";
import { precisionRound } from "../utils/arithmetic";
@ -196,6 +196,8 @@ export class DebitNoteController extends Controller {
@Query() includeRegisteredBranch?: boolean,
@Query() code?: string,
@Body() body?: {},
@Query() startDate?: Date,
@Query() endDate?: Date,
) {
const where = {
OR: queryOrNot<Prisma.QuotationWhereInput[]>(query, [
@ -220,6 +222,7 @@ export class DebitNoteController extends Controller {
debitNoteQuotationId: quotationId,
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
quotationStatus: status,
...whereDateQuery(startDate, endDate),
} satisfies Prisma.QuotationWhereInput;
const [result, total] = await prisma.$transaction([