fix: search and pendingOnly get mixed
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 3s

This commit is contained in:
Methapon2001 2025-07-21 13:25:34 +07:00
parent 92762c512d
commit ccadd5ea55

View file

@ -613,10 +613,7 @@ export class LineController extends Controller {
@Query() endDate?: Date, @Query() endDate?: Date,
) { ) {
const where = { const where = {
OR: OR: queryOrNot<Prisma.QuotationWhereInput[]>(query, [
query || pendingOnly
? [
...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [
{ code: { contains: query, mode: "insensitive" } }, { code: { contains: query, mode: "insensitive" } },
{ workName: { contains: query, mode: "insensitive" } }, { workName: { contains: query, mode: "insensitive" } },
{ {
@ -631,21 +628,7 @@ export class LineController extends Controller {
], ],
}, },
}, },
]) || []), ]),
...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [
{
requestData: {
some: {
requestDataStatus: "Pending",
},
},
},
{
requestData: { none: {} },
},
]) || []),
]
: undefined,
isDebitNote: false, isDebitNote: false,
code, code,
payCondition, payCondition,
@ -667,6 +650,20 @@ export class LineController extends Controller {
}, },
} }
: undefined, : undefined,
AND: pendingOnly
? [
{
requestData: {
some: {
requestDataStatus: "Pending",
},
},
},
{
requestData: { none: {} },
},
]
: undefined,
...whereDateQuery(startDate, endDate), ...whereDateQuery(startDate, endDate),
} satisfies Prisma.QuotationWhereInput; } satisfies Prisma.QuotationWhereInput;