fix bug
This commit is contained in:
@@ -100,7 +100,7 @@ export class PaymentController {
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(PermissionEnum.MANAGE_PAYMENTS)
|
||||
@ApiOperation({ summary: 'get all payments as admin' })
|
||||
findAllPayments(@Body() dto: FindPaymentsDto) {
|
||||
findAllPayments(@Query() dto: FindPaymentsDto) {
|
||||
return this.paymentService.findAll(dto);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,19 +68,17 @@ export class PaymentRepository extends EntityRepository<Payment> {
|
||||
}
|
||||
}
|
||||
|
||||
// Search by order number or user information
|
||||
if (search) {
|
||||
const searchPattern = `%${search}%`;
|
||||
const searchConditions: any[] = [
|
||||
{ user: { firstName: { $ilike: searchPattern } } },
|
||||
{ user: { lastName: { $ilike: searchPattern } } },
|
||||
{ user: { phone: { $ilike: searchPattern } } },
|
||||
const searchConditions: FilterQuery<Payment>[] = [
|
||||
{ invoice: { user: { firstName: { $ilike: searchPattern } } } },
|
||||
{ invoice: { user: { lastName: { $ilike: searchPattern } } } },
|
||||
{ invoice: { user: { phone: { $ilike: searchPattern } } } },
|
||||
];
|
||||
|
||||
// If search is numeric, also search by orderNumber
|
||||
const numericSearch = Number(search);
|
||||
if (!isNaN(numericSearch) && isFinite(numericSearch)) {
|
||||
searchConditions.push({ orderNumber: numericSearch });
|
||||
searchConditions.push({ invoice: { invoiceNumber: numericSearch } });
|
||||
}
|
||||
|
||||
where.$or = searchConditions;
|
||||
@@ -91,7 +89,7 @@ export class PaymentRepository extends EntityRepository<Payment> {
|
||||
limit,
|
||||
offset,
|
||||
orderBy: { [orderBy]: order.toLowerCase() as 'asc' | 'desc' },
|
||||
populate: [],
|
||||
populate: ['invoice', 'invoice.user', 'creator'],
|
||||
});
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
Reference in New Issue
Block a user