refactor: enhance customer creation code

This commit is contained in:
Abdalhamid Alhamad
2025-01-13 16:42:27 +03:00
parent 221f3bae4f
commit 5aa3d3774d
6 changed files with 70 additions and 66 deletions

View File

@ -2,7 +2,6 @@ import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { Transactional } from 'typeorm-transactional';
import { Roles } from '~/auth/enums';
import { PageOptionsRequestDto } from '~/core/dtos';
import { CustomerNotificationSettings } from '~/customer/entities/customer-notification-settings.entity';
import { CustomerService } from '~/customer/services';
import { DocumentService, OciService } from '~/document/services';
import { UserService } from '~/user/services';
@ -42,22 +41,7 @@ export class JuniorService {
roles: [Roles.JUNIOR],
});
await this.customerService.createCustomer(
{
firstName: body.firstName,
lastName: body.lastName,
dateOfBirth: body.dateOfBirth,
junior: Junior.create({
id: user.id,
guardianId,
relationship: body.relationship,
civilIdFrontId: body.civilIdFrontId,
civilIdBackId: body.civilIdBackId,
}),
notificationSettings: new CustomerNotificationSettings(),
},
user,
);
await this.customerService.createJuniorCustomer(guardianId, user.id, body);
this.logger.log(`Junior ${user.id} created successfully`);