updated events
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { SuperusersService } from './superusers.service';
|
||||
|
||||
describe('SuperusersService', () => {
|
||||
let service: SuperusersService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SuperusersService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<SuperusersService>(SuperusersService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
30
ServicesApi/src/accounts/superusers/superusers.service.ts
Normal file
30
ServicesApi/src/accounts/superusers/superusers.service.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { PaginationHelper } from '@/src/utils/pagination-helper';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PaginationInfo } from '@/src/utils/pagination-helper';
|
||||
import { PrismaService } from '@/src/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class SuperUsersService {
|
||||
constructor(
|
||||
private paginationHelper: PaginationHelper,
|
||||
private prisma: PrismaService,
|
||||
) { }
|
||||
|
||||
async filter(query: any & { page?: number; pageSize?: number }): Promise<{ pagination: PaginationInfo; data: any[] }> {
|
||||
console.log("supersServiceFilter query", query)
|
||||
const result = await this.paginationHelper.findWithPagination(query, this.prisma.account_records);
|
||||
const { pagination, data } = result;
|
||||
|
||||
if (data.length === 0) { return { pagination, data: [] } }
|
||||
const resultRefined = data.map((rec: any) => ({
|
||||
...rec,
|
||||
build_decision_book_payments: rec.build_decision_book_payments?.map(
|
||||
(pmt: any) => ({
|
||||
...pmt,
|
||||
ratePercent: ((pmt.payment_amount / rec.currency_value) * 100).toFixed(2) + '%',
|
||||
}),
|
||||
),
|
||||
}));
|
||||
return { pagination, data: resultRefined };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user