fix: empty array cause result to be zero
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 10s

This commit is contained in:
Methapon2001 2025-02-26 14:13:28 +07:00
parent e2023ab0ed
commit bf9dac8d46

View file

@ -604,36 +604,39 @@ export class LineController extends Controller {
@Query() query = "", @Query() query = "",
) { ) {
const where = { const where = {
OR: [ OR:
...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [ query || pendingOnly
{ code: { contains: query, mode: "insensitive" } }, ? [
{ workName: { contains: query } }, ...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [
{
customerBranch: {
OR: [
{ code: { contains: query, mode: "insensitive" } }, { code: { contains: query, mode: "insensitive" } },
{ customerName: { contains: query } }, { workName: { contains: query } },
{ firstName: { contains: query } }, {
{ firstNameEN: { contains: query } }, customerBranch: {
{ lastName: { contains: query } }, OR: [
{ lastNameEN: { contains: query } }, { code: { contains: query, mode: "insensitive" } },
], { customerName: { contains: query } },
}, { firstName: { contains: query } },
}, { firstNameEN: { contains: query } },
]) || []), { lastName: { contains: query } },
...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [ { lastNameEN: { contains: query } },
{ ],
requestData: { },
some: { },
requestDataStatus: "Pending", ]) || []),
}, ...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [
}, {
}, requestData: {
{ some: {
requestData: { none: {} }, requestDataStatus: "Pending",
}, },
]) || []), },
], },
{
requestData: { none: {} },
},
]) || []),
]
: undefined,
isDebitNote: false, isDebitNote: false,
code, code,
payCondition, payCondition,
@ -657,8 +660,6 @@ export class LineController extends Controller {
: undefined, : undefined,
} satisfies Prisma.QuotationWhereInput; } satisfies Prisma.QuotationWhereInput;
console.log();
const [result, total] = await prisma.$transaction([ const [result, total] = await prisma.$transaction([
prisma.quotation.findMany({ prisma.quotation.findMany({
where, where,