fix: empty array cause result to be zero
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 10s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 10s
This commit is contained in:
parent
e2023ab0ed
commit
bf9dac8d46
1 changed files with 32 additions and 31 deletions
|
|
@ -604,36 +604,39 @@ export class LineController extends Controller {
|
|||
@Query() query = "",
|
||||
) {
|
||||
const where = {
|
||||
OR: [
|
||||
...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [
|
||||
{ code: { contains: query, mode: "insensitive" } },
|
||||
{ workName: { contains: query } },
|
||||
{
|
||||
customerBranch: {
|
||||
OR: [
|
||||
OR:
|
||||
query || pendingOnly
|
||||
? [
|
||||
...(queryOrNot<Prisma.QuotationWhereInput[]>(query, [
|
||||
{ code: { contains: query, mode: "insensitive" } },
|
||||
{ customerName: { contains: query } },
|
||||
{ firstName: { contains: query } },
|
||||
{ firstNameEN: { contains: query } },
|
||||
{ lastName: { contains: query } },
|
||||
{ lastNameEN: { contains: query } },
|
||||
],
|
||||
},
|
||||
},
|
||||
]) || []),
|
||||
...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [
|
||||
{
|
||||
requestData: {
|
||||
some: {
|
||||
requestDataStatus: "Pending",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
requestData: { none: {} },
|
||||
},
|
||||
]) || []),
|
||||
],
|
||||
{ workName: { contains: query } },
|
||||
{
|
||||
customerBranch: {
|
||||
OR: [
|
||||
{ code: { contains: query, mode: "insensitive" } },
|
||||
{ customerName: { contains: query } },
|
||||
{ firstName: { contains: query } },
|
||||
{ firstNameEN: { contains: query } },
|
||||
{ lastName: { contains: query } },
|
||||
{ lastNameEN: { contains: query } },
|
||||
],
|
||||
},
|
||||
},
|
||||
]) || []),
|
||||
...(queryOrNot<Prisma.QuotationWhereInput[]>(!!pendingOnly, [
|
||||
{
|
||||
requestData: {
|
||||
some: {
|
||||
requestDataStatus: "Pending",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
requestData: { none: {} },
|
||||
},
|
||||
]) || []),
|
||||
]
|
||||
: undefined,
|
||||
isDebitNote: false,
|
||||
code,
|
||||
payCondition,
|
||||
|
|
@ -657,8 +660,6 @@ export class LineController extends Controller {
|
|||
: undefined,
|
||||
} satisfies Prisma.QuotationWhereInput;
|
||||
|
||||
console.log();
|
||||
|
||||
const [result, total] = await prisma.$transaction([
|
||||
prisma.quotation.findMany({
|
||||
where,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue