mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
refactor(nestjs): list resources
This commit is contained in:
@@ -77,7 +77,7 @@ export class PaymentReceivesApplication {
|
||||
* @param {IPaymentsReceivedFilter} filterDTO
|
||||
* @returns
|
||||
*/
|
||||
public async getPaymentsReceived(filterDTO: IPaymentsReceivedFilter) {
|
||||
public async getPaymentsReceived(filterDTO: Partial<IPaymentsReceivedFilter>) {
|
||||
return this.getPaymentsReceivedService.getPaymentReceives(filterDTO);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
@@ -17,7 +18,6 @@ import {
|
||||
IPaymentsReceivedFilter,
|
||||
PaymentReceiveMailOptsDTO,
|
||||
} from './types/PaymentReceived.types';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('payments-received')
|
||||
@ApiTags('payments-received')
|
||||
@@ -88,7 +88,7 @@ export class PaymentReceivesController {
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Retrieves the payment received list.' })
|
||||
public getPaymentsReceived(@Query() filterDTO: IPaymentsReceivedFilter) {
|
||||
public getPaymentsReceived(@Query() filterDTO: Partial<IPaymentsReceivedFilter>) {
|
||||
return this.paymentReceivesApplication.getPaymentsReceived(filterDTO);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,22 @@ export class GetPaymentsReceivedService {
|
||||
* Retrieve payment receives paginated and filterable list.
|
||||
* @param {IPaymentsReceivedFilter} filterDTO
|
||||
*/
|
||||
public async getPaymentReceives(filterDTO: IPaymentsReceivedFilter): Promise<{
|
||||
public async getPaymentReceives(
|
||||
filterDTO: Partial<IPaymentsReceivedFilter>,
|
||||
): Promise<{
|
||||
paymentReceives: PaymentReceived[];
|
||||
pagination: IPaginationMeta;
|
||||
filterMeta: IFilterMeta;
|
||||
}> {
|
||||
const _filterDto = {
|
||||
sortOrder: 'desc',
|
||||
columnSortBy: 'created_at',
|
||||
page: 1,
|
||||
pageSize: 12,
|
||||
...filterDTO,
|
||||
};
|
||||
// Parses filter DTO.
|
||||
const filter = this.parseListFilterDTO(filterDTO);
|
||||
const filter = this.parseListFilterDTO(_filterDto);
|
||||
|
||||
// Dynamic list service.
|
||||
const dynamicList = await this.dynamicListService.dynamicList(
|
||||
@@ -44,7 +53,7 @@ export class GetPaymentsReceivedService {
|
||||
builder.withGraphFetched('depositAccount');
|
||||
|
||||
dynamicList.buildQuery()(builder);
|
||||
filterDTO?.filterQuery && filterDTO.filterQuery(builder as any);
|
||||
_filterDto?.filterQuery && _filterDto.filterQuery(builder as any);
|
||||
})
|
||||
.pagination(filter.page - 1, filter.pageSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user