1
0
forked from Yara724/api

YARA-1110

This commit is contained in:
SepehrYahyaee
2026-07-13 11:53:47 +03:30
parent 72dec7a917
commit 5595083e86
21 changed files with 413 additions and 653 deletions

View File

@@ -14,7 +14,6 @@ import {
CreateClaimExpertByInsurerDto,
CreateFileMakerByInsurerDto,
CreateFileReviewerByInsurerDto,
CreateFinancialExpertByInsurerDto,
CreateInsurerExpertDto,
} from "./dto/create-insurer-expert.dto";
import {
@@ -30,7 +29,6 @@ import { ExpertDbService } from "src/users/entities/db-service/expert.db.service
import { FieldExpertDbService } from "src/users/entities/db-service/field-expert.db.service";
import { FileMakerDbService } from "src/users/entities/db-service/file-maker.db.service";
import { FileReviewerDbService } from "src/users/entities/db-service/file-reviewer.db.service";
import { FinancialExpertDbService } from "src/users/entities/db-service/financial-expert.db.service";
import { ExpertFileActivityDbService } from "src/users/entities/db-service/expert-file-activity.db.service";
import { ExpertFileActivityType } from "src/users/entities/schema/expert-file-activity.schema";
import { HashService } from "src/utils/hash/hash.service";
@@ -97,7 +95,6 @@ export class ExpertInsurerService {
private readonly claimSignDbService: ClaimSignDbService,
private readonly fileMakerDbService: FileMakerDbService,
private readonly fileReviewerDbService: FileReviewerDbService,
private readonly financialExpertDbService: FinancialExpertDbService,
) {}
/**
@@ -1769,58 +1766,6 @@ export class ExpertInsurerService {
};
}
async addFinancialExpert(
insurerClientKey: string,
payload: CreateFinancialExpertByInsurerDto,
) {
const clientObjectId = this.getClientId(insurerClientKey);
const branch = await this.assertBranchBelongsToClient(
payload.branchId,
clientObjectId,
);
const email = payload.email.trim().toLowerCase();
const existing = await this.financialExpertDbService.findOne({ email });
if (existing) {
throw new ConflictException(
"A FinancialExpert with this email already exists.",
);
}
const nationalCode = payload.nationalCode.trim();
const existingByNational = await this.financialExpertDbService.findOne({
nationalCode,
});
if (existingByNational) {
throw new ConflictException(
"A FinancialExpert with this national code already exists.",
);
}
const hashedPassword = await this.hashService.hash(payload.password);
const created = await this.financialExpertDbService.create({
...payload,
email,
nationalCode,
password: hashedPassword,
role: RoleEnum.FINANCIAL_EXPERT,
clientKey: clientObjectId,
branchId: new Types.ObjectId(payload.branchId),
});
return {
financialExpert: this.sanitizeExpertResponse(created),
branch: {
_id: (branch as any)._id,
name: branch.name,
code: branch.code,
city: branch.city,
state: branch.state,
address: branch.address,
},
};
}
/**
* Get comprehensive statistics for all experts of a client
* Returns: