forked from Yara724/api
Enforce claim beneficiary access and retire unused legacy APIs
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
} from "@nestjs/common";
|
||||
import { Types } from "mongoose";
|
||||
import { ClaimRequestManagementService } from "./claim-request-management.service";
|
||||
import {
|
||||
canUserCreateClaim,
|
||||
resolveClaimBeneficiary,
|
||||
} from "src/helpers/blame-claim-eligibility";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
|
||||
const firstId = "650000000000000000000001";
|
||||
const secondId = "650000000000000000000002";
|
||||
const blameId = "650000000000000000000003";
|
||||
const claimId = "650000000000000000000004";
|
||||
const payerId = "650000000000000000000005";
|
||||
const outsiderId = "650000000000000000000006";
|
||||
const signed = { accepted: true, signature: { fileId: "signed" } };
|
||||
|
||||
function source(guiltyId = firstId): any {
|
||||
return {
|
||||
_id: new Types.ObjectId(blameId),
|
||||
type: "THIRD_PARTY",
|
||||
status: "COMPLETED",
|
||||
publicId: "A100",
|
||||
requestNo: "A100",
|
||||
expert: { decision: { guiltyPartyId: guiltyId } },
|
||||
parties: [
|
||||
{
|
||||
role: "FIRST",
|
||||
person: {
|
||||
userId: firstId,
|
||||
clientId: payerId,
|
||||
phoneNumber: "09120000001",
|
||||
},
|
||||
confirmation: signed,
|
||||
},
|
||||
{
|
||||
role: "SECOND",
|
||||
person: { userId: secondId, phoneNumber: "09120000002" },
|
||||
confirmation: signed,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function serviceFor(blame: any): any {
|
||||
const service = Object.create(ClaimRequestManagementService.prototype);
|
||||
service.blameRequestDbService = {
|
||||
findById: jest.fn().mockResolvedValue(blame),
|
||||
};
|
||||
service.claimCaseDbService = {
|
||||
findOne: jest.fn().mockResolvedValue(null),
|
||||
create: jest.fn().mockResolvedValue({ _id: claimId }),
|
||||
};
|
||||
service.userDbService = { findAllByPhone: jest.fn().mockResolvedValue([]) };
|
||||
service.generateUniqueClaimNumber = jest.fn().mockResolvedValue("C100");
|
||||
service.autoSubmitToFanavaranV2OnClaimCreated = jest
|
||||
.fn()
|
||||
.mockResolvedValue({});
|
||||
service.withFanavaranAutoSubmitMessage = (message: string) => message;
|
||||
service.logger = { log: jest.fn(), error: jest.fn() };
|
||||
return service;
|
||||
}
|
||||
|
||||
describe("claim beneficiary authorization across shared user flows", () => {
|
||||
it.each([firstId, secondId])(
|
||||
"allows only the other party when guilt belongs to %s",
|
||||
async (guiltyId) => {
|
||||
const beneficiaryId = guiltyId === firstId ? secondId : firstId;
|
||||
const blame = source(guiltyId);
|
||||
const service = serviceFor(blame);
|
||||
for (const actorId of [guiltyId, outsiderId]) {
|
||||
await expect(
|
||||
service.createClaimFromBlameV2(blameId, actorId),
|
||||
).rejects.toBeInstanceOf(ForbiddenException);
|
||||
}
|
||||
expect(service.claimCaseDbService.create).not.toHaveBeenCalled();
|
||||
await expect(
|
||||
service.createClaimFromBlameV2(blameId, beneficiaryId),
|
||||
).resolves.toMatchObject({ claimRequestId: claimId });
|
||||
const saved = service.claimCaseDbService.create.mock.calls[0][0];
|
||||
expect(String(saved.owner.userId)).toBe(beneficiaryId);
|
||||
expect(String(saved.damagedPartyUserId)).toBe(beneficiaryId);
|
||||
const payer = blame.parties.find((p: any) => p.person.userId === guiltyId)
|
||||
.person.clientId;
|
||||
expect(saved.owner.userClientKey).toBe(payer);
|
||||
expect(
|
||||
service.autoSubmitToFanavaranV2OnClaimCreated,
|
||||
).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
);
|
||||
|
||||
it("blocks incomplete, unsigned, rejected, and unresolved cases without creating or submitting a claim", async () => {
|
||||
const invalid = [
|
||||
{ ...source(), status: "WAITING_FOR_SIGNATURES" },
|
||||
{ ...source(), expert: { decision: { guiltyPartyId: outsiderId } } },
|
||||
{ ...source(), expert: {} },
|
||||
];
|
||||
for (const confirmation of [
|
||||
{ accepted: true },
|
||||
{ accepted: false, signature: { fileId: "signed" } },
|
||||
]) {
|
||||
const blame = source();
|
||||
blame.parties[0].confirmation = confirmation;
|
||||
invalid.push(blame);
|
||||
}
|
||||
const duplicated = source();
|
||||
duplicated.parties[1].person.userId = firstId;
|
||||
invalid.push(duplicated);
|
||||
for (const blame of invalid) {
|
||||
const service = serviceFor(blame);
|
||||
expect(canUserCreateClaim(blame, secondId)).toBe(false);
|
||||
await expect(
|
||||
service.createClaimFromBlameV2(blameId, secondId),
|
||||
).rejects.toBeInstanceOf(BadRequestException);
|
||||
expect(service.claimCaseDbService.create).not.toHaveBeenCalled();
|
||||
expect(
|
||||
service.autoSubmitToFanavaranV2OnClaimCreated,
|
||||
).not.toHaveBeenCalled();
|
||||
}
|
||||
});
|
||||
|
||||
it("never grants eligibility to an empty identity or an unknown case type", () => {
|
||||
expect(canUserCreateClaim({ status: "COMPLETED", parties: [] }, "")).toBe(
|
||||
false,
|
||||
);
|
||||
expect(canUserCreateClaim({ ...source(), type: "UNKNOWN" }, secondId)).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("retains existing-claim conflict handling for its legitimate beneficiary", async () => {
|
||||
const service = serviceFor(source());
|
||||
service.claimCaseDbService.findOne.mockResolvedValue({ _id: claimId });
|
||||
await expect(
|
||||
service.createClaimFromBlameV2(blameId, secondId),
|
||||
).rejects.toBeInstanceOf(ConflictException);
|
||||
expect(service.claimCaseDbService.create).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps body-insurance creation restricted to the first party and persists its beneficiary", async () => {
|
||||
const blame = source();
|
||||
blame.type = "CAR_BODY";
|
||||
blame.parties = [blame.parties[0]];
|
||||
const service = serviceFor(blame);
|
||||
expect(resolveClaimBeneficiary(blame)?.person?.userId).toBe(firstId);
|
||||
await expect(
|
||||
service.createClaimFromBlameV2(blameId, secondId),
|
||||
).rejects.toBeInstanceOf(ForbiddenException);
|
||||
await service.createClaimFromBlameV2(blameId, firstId);
|
||||
const saved = service.claimCaseDbService.create.mock.calls[0][0];
|
||||
expect(String(saved.damagedPartyUserId)).toBe(firstId);
|
||||
expect(String(saved.owner.clientId)).toBe(payerId);
|
||||
});
|
||||
|
||||
it("denies historical guilty owners while allowing the damaged party and its phone-linked identity", async () => {
|
||||
const service = serviceFor(source());
|
||||
const claim = {
|
||||
blameRequestId: blameId,
|
||||
owner: { userId: firstId },
|
||||
damagedPartyUserId: secondId,
|
||||
};
|
||||
const check = (id: string, actor?: { username?: string }) =>
|
||||
service.assertEffectiveUserIsDamagedPartyOnClaim(claim, id, actor);
|
||||
await expect(check(firstId)).rejects.toBeInstanceOf(ForbiddenException);
|
||||
await expect(check(outsiderId)).rejects.toBeInstanceOf(ForbiddenException);
|
||||
await expect(check(secondId)).resolves.toBeUndefined();
|
||||
service.userDbService.findAllByPhone.mockResolvedValue([{ _id: secondId }]);
|
||||
await expect(
|
||||
check(outsiderId, { username: "989120000002" }),
|
||||
).resolves.toBeUndefined();
|
||||
service.blameRequestDbService.findById.mockResolvedValue({
|
||||
...source(),
|
||||
expert: {},
|
||||
});
|
||||
await expect(check(firstId)).rejects.toBeInstanceOf(ForbiddenException);
|
||||
});
|
||||
|
||||
it("returns read-only details for the guilty party and actionable guidance for the beneficiary", async () => {
|
||||
const service = serviceFor(source());
|
||||
const claim = {
|
||||
_id: new Types.ObjectId(claimId),
|
||||
blameRequestId: new Types.ObjectId(blameId),
|
||||
publicId: "A100",
|
||||
requestNo: "C100",
|
||||
owner: { userId: firstId },
|
||||
damagedPartyUserId: secondId,
|
||||
status: "SELECTING_OUTER_PARTS",
|
||||
};
|
||||
service.claimCaseDbService.findById = jest.fn().mockResolvedValue(claim);
|
||||
service.blameRequestDbService.find = jest
|
||||
.fn()
|
||||
.mockResolvedValue([source()]);
|
||||
const guilty = await service.getClaimDetailsV2(claimId, firstId, {
|
||||
sub: firstId,
|
||||
role: RoleEnum.USER,
|
||||
});
|
||||
expect(guilty.canAct).toBe(false);
|
||||
expect(guilty).not.toHaveProperty("ownerGuidance");
|
||||
const damaged = await service.getClaimDetailsV2(claimId, secondId, {
|
||||
sub: secondId,
|
||||
role: RoleEnum.USER,
|
||||
});
|
||||
expect(damaged.canAct).toBe(true);
|
||||
expect(damaged.ownerGuidance).toBeDefined();
|
||||
});
|
||||
|
||||
it("uses a persisted beneficiary when the source is unavailable, never guesses from snapshot non-ownership", async () => {
|
||||
const service = serviceFor(null);
|
||||
const claim = {
|
||||
blameRequestId: blameId,
|
||||
owner: { userId: firstId },
|
||||
damagedPartyUserId: secondId,
|
||||
};
|
||||
await expect(
|
||||
service.assertEffectiveUserIsDamagedPartyOnClaim(claim, firstId),
|
||||
).rejects.toBeInstanceOf(ForbiddenException);
|
||||
await expect(
|
||||
service.assertEffectiveUserIsDamagedPartyOnClaim(claim, secondId),
|
||||
).resolves.toBeUndefined();
|
||||
const ambiguous = {
|
||||
blameRequestId: blameId,
|
||||
snapshot: { parties: source().parties },
|
||||
owner: { userId: secondId },
|
||||
};
|
||||
await expect(
|
||||
service.assertEffectiveUserIsDamagedPartyOnClaim(ambiguous, firstId),
|
||||
).rejects.toBeInstanceOf(ForbiddenException);
|
||||
await expect(
|
||||
service.assertEffectiveUserIsDamagedPartyOnClaim(
|
||||
{ owner: { userId: secondId } },
|
||||
secondId,
|
||||
),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps the authorized in-person expert acting for the beneficiary in reorganized flows", async () => {
|
||||
const blame = {
|
||||
...source(),
|
||||
creationMethod: "IN_PERSON",
|
||||
expertInitiated: true,
|
||||
initiatedByFieldExpertId: outsiderId,
|
||||
};
|
||||
const service = serviceFor(blame);
|
||||
const claim = {
|
||||
blameRequestId: blameId,
|
||||
owner: { userId: secondId },
|
||||
damagedPartyUserId: secondId,
|
||||
};
|
||||
const effectiveId = await service.resolveClaimEffectiveUserId(
|
||||
claim,
|
||||
outsiderId,
|
||||
RoleEnum.FIELD_EXPERT,
|
||||
);
|
||||
expect(effectiveId).toBe(secondId);
|
||||
await expect(
|
||||
service.assertEffectiveUserIsDamagedPartyOnClaim(claim, effectiveId),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -6,16 +6,6 @@ describe("optional accident sketch", () => {
|
||||
ClaimRequestManagementService.prototype,
|
||||
) as ClaimRequestManagementService;
|
||||
|
||||
it("is excluded from legacy required-document completion", () => {
|
||||
const requiredTypes = (service as any).getRequiredDocumentTypes({
|
||||
blameFile: { type: "THIRD_PARTY" },
|
||||
});
|
||||
|
||||
expect(requiredTypes).not.toContain(
|
||||
ClaimRequiredDocumentType.ACCIDENT_SKETCH,
|
||||
);
|
||||
});
|
||||
|
||||
it("does not gate V2 owner-document completion", () => {
|
||||
const mandatoryKeys = (service as any).requiredDocumentKeysV2(false);
|
||||
const requiredDocuments = Object.fromEntries(
|
||||
|
||||
@@ -1,86 +1,17 @@
|
||||
import { Controller, Get, UseGuards } from "@nestjs/common";
|
||||
import { ApiBearerAuth, ApiExcludeController } from "@nestjs/swagger";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { extname, parse } from "node:path";
|
||||
import {
|
||||
BadRequestException,
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
UploadedFile,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from "@nestjs/common";
|
||||
import { FileInterceptor } from "@nestjs/platform-express";
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiBody,
|
||||
ApiConsumes,
|
||||
ApiParam,
|
||||
ApiQuery,
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiExcludeController,
|
||||
} from "@nestjs/swagger";
|
||||
import { diskStorage } from "multer";
|
||||
import { ClaimAccessGuard } from "src/auth/guards/claim-access.guard";
|
||||
import { RolesGuard } from "src/auth/guards/role.guard";
|
||||
import { Roles } from "src/decorators/roles.decorator";
|
||||
import { CurrentUser } from "src/decorators/user.decorator";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { DEFAULT_MEDIA_MAX_BYTES } from "src/client/client.service";
|
||||
import { ClaimRequestManagementService } from "./claim-request-management.service";
|
||||
import { ClaimRequiredDocumentType } from "src/Types&Enums/claim-request-management/required-document-type.enum";
|
||||
import { CarDamagePartDto, OtherCarDamagePartDto } from "./dto/car-part.dto";
|
||||
import { UserCommentDto } from "./dto/user-comment.dto";
|
||||
import { UserObjectionDto } from "./dto/user-objection.dto";
|
||||
import { UserRatingDto } from "./dto/user-rating.dto";
|
||||
|
||||
@ApiExcludeController()
|
||||
@Controller("claim-request-management")
|
||||
// @ApiTags("claim-request-management")
|
||||
@Roles(RoleEnum.USER, RoleEnum.EXPERT, RoleEnum.DAMAGE_EXPERT)
|
||||
@UseGuards(ClaimAccessGuard, RolesGuard)
|
||||
@ApiBearerAuth()
|
||||
export class ClaimRequestManagementController {
|
||||
constructor(
|
||||
private readonly claimRequestManagementService: ClaimRequestManagementService,
|
||||
) {}
|
||||
|
||||
// @ApiParam({ name: "blameId" })
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("/:blameId")
|
||||
async createClaimRequest(
|
||||
@Param("blameId") requestId: string,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return await this.claimRequestManagementService.createClaimRequest(
|
||||
requestId,
|
||||
user.role === RoleEnum.USER ? user.sub : undefined,
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiBody({ type: CarDamagePartDto })
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("/car-part-damage/:claimRequestID")
|
||||
// @ApiParam({ name: "claimRequestID" })
|
||||
async carPartDamage(
|
||||
@Param("claimRequestID") requestId: string,
|
||||
@Body() body: CarDamagePartDto,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return await this.claimRequestManagementService.selectCarPartDamage(
|
||||
requestId,
|
||||
body,
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("/car-other-part")
|
||||
async getCarOtherParts() {
|
||||
const carOtherPart = await readFile(
|
||||
@@ -89,417 +20,4 @@ export class ClaimRequestManagementController {
|
||||
);
|
||||
return carOtherPart;
|
||||
}
|
||||
|
||||
// @ApiBody({ type: OtherCarDamagePartDto })
|
||||
// @ApiParam({ name: "claimRequestID" })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: {
|
||||
fileSize: DEFAULT_MEDIA_MAX_BYTES,
|
||||
},
|
||||
storage: diskStorage({
|
||||
destination: "./files/car-green-cards",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const ex = extname(file.originalname);
|
||||
const filename = `${file.originalname.split(" ")[0]}-${unique}${ex}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
@ApiConsumes("multipart/form-data")
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("/car-other-part-damage/:claimRequestID")
|
||||
async carOtherPartDamage(
|
||||
@Param("claimRequestID") requestId: string,
|
||||
@UploadedFile() file,
|
||||
@Body() body: OtherCarDamagePartDto,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return await this.claimRequestManagementService.selectCarOtherPartDamage(
|
||||
requestId,
|
||||
body,
|
||||
file,
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("required-documents-status/:claimRequestID")
|
||||
// @ApiParam({ name: "claimRequestID" })
|
||||
async getRequiredDocumentsStatus(@Param("claimRequestID") requestId: string) {
|
||||
return await this.claimRequestManagementService.getRequiredDocumentsStatus(
|
||||
requestId,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("car-part-image-required/:claimRequestID")
|
||||
// @ApiParam({ name: "claimRequestID" })
|
||||
async getImageRequired(@Param("claimRequestID") requestId) {
|
||||
return await this.claimRequestManagementService.getImageRequiredList(
|
||||
requestId,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// file: { type: "string", format: "binary" },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
storage: diskStorage({
|
||||
destination: "./files/claim-required-documents/",
|
||||
filename: (req, file, callback) => {
|
||||
const extension = extname(file.originalname);
|
||||
const basename = parse(file.originalname).name;
|
||||
const unique = Date.now();
|
||||
const sanitizedBasename = basename
|
||||
.replace(/\s/g, "_")
|
||||
.replace(/[^\w\-_]/g, "")
|
||||
.substring(0, 50);
|
||||
const filename = `${sanitizedBasename}-${unique}${extension}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// // @ApiParam({ name: "claimRequestID" })
|
||||
// @ApiQuery({
|
||||
// name: "documentType",
|
||||
// enum: ClaimRequiredDocumentType,
|
||||
// description: "Type of required document to upload",
|
||||
// })
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("upload-required-document/:claimRequestID")
|
||||
async uploadRequiredDocument(
|
||||
@Param("claimRequestID") requestId: string,
|
||||
@Query("documentType") documentType: string,
|
||||
@UploadedFile("file") file: Express.Multer.File,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
if (!file) {
|
||||
throw new BadRequestException("File is required");
|
||||
}
|
||||
return await this.claimRequestManagementService.uploadRequiredDocument(
|
||||
requestId,
|
||||
documentType as any,
|
||||
file,
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// file: { type: "string", format: "binary" },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
storage: diskStorage({
|
||||
destination: "./files/car-parts/",
|
||||
filename: (req, file, callback) => {
|
||||
const extension = extname(file.originalname);
|
||||
const basename = parse(file.originalname).name;
|
||||
const unique = Date.now();
|
||||
// Sanitize filename: remove non-ASCII characters and special chars to avoid encoding issues
|
||||
const sanitizedBasename = basename
|
||||
.replace(/\s/g, "_")
|
||||
.replace(/[^\w\-_]/g, "") // Remove all non-word characters except hyphens and underscores
|
||||
.substring(0, 50); // Limit length
|
||||
const filename = `${sanitizedBasename}-${unique}${extension}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiParam({ name: "claimRequestID" })
|
||||
// @ApiParam({
|
||||
// name: "partId",
|
||||
// description: "The ID of the specific car part being photographed.",
|
||||
// })
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("capture-car-part-damage/:claimRequestID/:partId")
|
||||
async captureCarPartDamage(
|
||||
@Param("partId") partId: string,
|
||||
@Param("claimRequestID") requestId: string,
|
||||
@UploadedFile("file") file: Express.Multer.File,
|
||||
) {
|
||||
if (!file) {
|
||||
throw new BadRequestException("Image file is required.");
|
||||
}
|
||||
return await this.claimRequestManagementService.setDamageImage(
|
||||
requestId,
|
||||
partId,
|
||||
file,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// file: { type: "string", format: "binary" },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
storage: diskStorage({
|
||||
destination: "./files/car-capture-videos/",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const ex = extname(file.originalname);
|
||||
const filename = `claim-video-${unique}${ex}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiParam({ name: "claimRequestID" })
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("car-capture/:claimRequestID")
|
||||
async captureVideoCapture(
|
||||
@Param("claimRequestID") requestId: string,
|
||||
@UploadedFile("file") file: Express.Multer.File,
|
||||
) {
|
||||
return await this.claimRequestManagementService.setVideoCapture(
|
||||
requestId,
|
||||
file,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("requests/")
|
||||
async getRequest(@CurrentUser() currentUser) {
|
||||
return await this.claimRequestManagementService.myRequests(currentUser);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("request/:claimRequestId")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
myRequests(@Param("claimRequestId") requestId: string, @CurrentUser() user) {
|
||||
return this.claimRequestManagementService.requestDetails(requestId, user);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Put("request/reply/:claimRequestId")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: {
|
||||
fileSize: DEFAULT_MEDIA_MAX_BYTES,
|
||||
},
|
||||
storage: diskStorage({
|
||||
destination: "./files/claim-sign",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const ex = extname(file.originalname);
|
||||
const filename = `${file.originalname.split(" ")[0]}-${unique}${ex}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiBody({
|
||||
// type: UserCommentDto,
|
||||
// description: "if partId null , you can upload video capture",
|
||||
// })
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
async submitReply(
|
||||
@Param("claimRequestId") requestId,
|
||||
@Body() body,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
// return await this.claimRequestManagementService.submitUserReply(
|
||||
// requestId,
|
||||
// body,
|
||||
// file,
|
||||
// user,
|
||||
// );
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Put("request/resend/:claimRequestId/objection")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
// @ApiConsumes("application/json")
|
||||
// @ApiBody({
|
||||
// type: UserObjectionDto,
|
||||
// description: "Objection details with optional new parts",
|
||||
// })
|
||||
async handleUserObjection(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() userObjectionDto: UserObjectionDto,
|
||||
) {
|
||||
return await this.claimRequestManagementService.handleUserObjectionAndParts(
|
||||
claimRequestId,
|
||||
userObjectionDto,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("request/resend/:claimRequestId")
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
// @ApiQuery({ name: "fields", enum: ["resendDocuments", "resendCarParts"] })
|
||||
// @ApiQuery({ name: "partId", required: false })
|
||||
// @ApiQuery({ name: "documentName", required: false })
|
||||
// @ApiQuery({ name: "side", required: false })
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// file: {
|
||||
// type: "string",
|
||||
// format: "binary",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
storage: diskStorage({
|
||||
destination: "./files/claim-resend-documents",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const ext = extname(file.originalname);
|
||||
const filename = `${file.originalname.split(" ")[0]}-${unique}${ext}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
}),
|
||||
)
|
||||
async uploadDocuments(
|
||||
@Param("claimRequestId") claimId: string,
|
||||
@Query() query: string,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return await this.claimRequestManagementService.resendFiles(
|
||||
claimId,
|
||||
file,
|
||||
query,
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* User satisfaction rating for a completed claim file.
|
||||
* Only the damaged user (claim owner) can rate their claim after it is closed.
|
||||
*/
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Put("request/:claimRequestId/user-rating")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
// @ApiBody({ type: UserRatingDto })
|
||||
async addUserRating(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() ratingDto: UserRatingDto,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return await this.claimRequestManagementService.addUserRating(
|
||||
claimRequestId,
|
||||
user,
|
||||
ratingDto,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch("request/reply/:claimRequestId/:partId/upload-factor")
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
// @ApiParam({ name: "partId" })
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// file: {
|
||||
// type: "string",
|
||||
// format: "binary",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
storage: diskStorage({
|
||||
destination: "./files/claim-factors",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const filename = `-${unique}-${file.originalname}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
}),
|
||||
)
|
||||
async uploadFactorForPart(
|
||||
@Param("claimRequestId") claimId: string,
|
||||
@Param("partId") partId: string,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@CurrentUser() user,
|
||||
) {
|
||||
return await this.claimRequestManagementService.uploadClaimFactor(
|
||||
claimId,
|
||||
partId,
|
||||
file,
|
||||
user,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiParam({ name: "id" })
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Patch(":id/visit")
|
||||
async inPersonVisit(
|
||||
@Param("id") requestId: string,
|
||||
@CurrentUser() actor,
|
||||
) {
|
||||
return await this.claimRequestManagementService.inPersonVisit(requestId, actor);
|
||||
}
|
||||
|
||||
// Legacy V1 owner branch picker — intentionally disabled.
|
||||
// A claim is handled by an expert assigned to the insurer branch, so the
|
||||
// owner must not choose an insurer branch while signing. This does not apply
|
||||
// to the separate expert-only `daghi.branchId` choice in pricing flows.
|
||||
//
|
||||
// @Get("branches/:insuranceId")
|
||||
// async insuranceBranches(@Param("insuranceId") insuranceId: string) {
|
||||
// return await this.claimRequestManagementService.retrieveInsuranceBranches(
|
||||
// insuranceId,
|
||||
// );
|
||||
// }
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("fanavaran-submit/:claimRequestId")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
async fanavaranSubmit(@Param("claimRequestId") claimRequestId: string) {
|
||||
return await this.claimRequestManagementService.fanavaranSubmit(
|
||||
claimRequestId,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("fanavaran-submit/:claimRequestId")
|
||||
// @ApiParam({ name: "claimRequestId" })
|
||||
async submitToFanavaran(@Param("claimRequestId") claimRequestId: string) {
|
||||
return await this.claimRequestManagementService.submitToFanavaran(
|
||||
claimRequestId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,9 @@ import { RequestManagementModule } from "src/request-management/request-manageme
|
||||
import { UsersModule } from "src/users/users.module";
|
||||
import { ClaimRequestManagementController } from "./claim-request-management.controller";
|
||||
import { ClaimRequestManagementV2Controller } from "./claim-request-management.v2.controller";
|
||||
import { RegistrarClaimV1Controller } from "./registrar-claim.v1.controller";
|
||||
import { ExpertInitiatedClaimMirrorController } from "./expert-initiated-claim.mirror.controller";
|
||||
import { RegistrarClaimMirrorController } from "./registrar-claim.mirror.controller";
|
||||
import { ClaimRequestManagementService } from "./claim-request-management.service";
|
||||
import { CarGreenCardDbService } from "./entites/db-service/car-green-card.db.service";
|
||||
import { ClaimRequestManagementDbService } from "./entites/db-service/claim-request-management.db.service";
|
||||
import { ClaimCaseDbService } from "./entites/db-service/claim-case.db.service";
|
||||
import {
|
||||
@@ -21,7 +19,6 @@ import {
|
||||
ClaimCaseSchema,
|
||||
} from "./entites/schema/claim-cases.schema";
|
||||
import { ClaimSignDbService } from "./entites/db-service/claim-sign.db.service";
|
||||
import { DamageImageDbService } from "./entites/db-service/damage-image.db.service";
|
||||
import { ClaimFactorsImageDbService } from "./entites/db-service/factor-image.db.service";
|
||||
import { VideoCaptureDbService } from "./entites/db-service/video-capture.db.service";
|
||||
import { ClaimRequiredDocumentDbService } from "./entites/db-service/claim-required-document.db.service";
|
||||
@@ -98,9 +95,9 @@ import { PlateNormalizerModule } from "src/utils/plate-normalizer/plate-normaliz
|
||||
ClaimRequestManagementService,
|
||||
ClaimRequestManagementDbService,
|
||||
ClaimCaseDbService,
|
||||
CarGreenCardDbService,
|
||||
|
||||
ClaimCaseDbService,
|
||||
DamageImageDbService,
|
||||
|
||||
ClaimSignDbService,
|
||||
ClaimFactorsImageDbService,
|
||||
VideoCaptureDbService,
|
||||
@@ -110,7 +107,6 @@ import { PlateNormalizerModule } from "src/utils/plate-normalizer/plate-normaliz
|
||||
controllers: [
|
||||
ClaimRequestManagementController,
|
||||
ClaimRequestManagementV2Controller,
|
||||
RegistrarClaimV1Controller,
|
||||
ExpertInitiatedClaimMirrorController,
|
||||
RegistrarClaimMirrorController,
|
||||
],
|
||||
@@ -118,7 +114,7 @@ import { PlateNormalizerModule } from "src/utils/plate-normalizer/plate-normaliz
|
||||
ClaimRequestManagementService,
|
||||
ClaimRequestManagementDbService,
|
||||
ClaimCaseDbService,
|
||||
DamageImageDbService,
|
||||
|
||||
VideoCaptureDbService,
|
||||
ClaimRequiredDocumentDbService,
|
||||
ClaimSignDbService,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +0,0 @@
|
||||
import { ClaimRequestManagementModel } from "src/claim-request-management/entites/schema/claim-request-management.schema";
|
||||
|
||||
export class ClaimPartUploadDetail {
|
||||
list: any;
|
||||
constructor(claimFile: ClaimRequestManagementModel[]) {
|
||||
this.list = claimFile
|
||||
.map((c) => {
|
||||
return {
|
||||
carPartDamage: c.carPartDamage,
|
||||
carOtherPartDamage: c.otherParts,
|
||||
greenCardUpload: !!c.carGreenCard.path,
|
||||
};
|
||||
})
|
||||
.flat(2);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,65 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { DamageSelectedPartV2BodyDto } from './damage-selected-part-v2.dto';
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { DamageSelectedPartV2BodyDto } from "./damage-selected-part-v2.dto";
|
||||
|
||||
/** Suggested HTTP call for the owner UI (`pathTemplate`: replace placeholders). */
|
||||
export class ClaimDetailsOwnerNextActionV2Dto {
|
||||
@ApiProperty({ description: 'Stable UI key', example: 'FINAL_SIGN' })
|
||||
@ApiProperty({ description: "Stable UI key", example: "FINAL_SIGN" })
|
||||
key: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'HTTP verb', example: 'PUT' })
|
||||
@ApiPropertyOptional({ description: "HTTP verb", example: "PUT" })
|
||||
method?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Path under API root',
|
||||
example: 'v2/claim-request-management/request/{claimRequestId}/owner-insurer-approval/sign',
|
||||
description: "Path under API root",
|
||||
example:
|
||||
"v2/claim-request-management/request/{claimRequestId}/owner-insurer-approval/sign",
|
||||
})
|
||||
pathTemplate?: string;
|
||||
|
||||
@ApiProperty({ description: 'What this endpoint does for the user' })
|
||||
@ApiProperty({ description: "What this endpoint does for the user" })
|
||||
description: string;
|
||||
}
|
||||
|
||||
/** Server-derived hints: which phase the claim is in and what to offer next (owners only). */
|
||||
export class ClaimDetailsOwnerGuidanceV2Dto {
|
||||
@ApiProperty({
|
||||
description: 'Machine-readable phase',
|
||||
description: "Machine-readable phase",
|
||||
enum: [
|
||||
'COMPLETED',
|
||||
'REJECTED',
|
||||
'CANCELLED',
|
||||
'EXPERT_RESEND',
|
||||
'WAITING_DAMAGE_EXPERT',
|
||||
'EXPERT_REVIEWING',
|
||||
'USER_FLOW',
|
||||
'UPLOAD_FACTORS',
|
||||
'EXPERT_VALIDATING_FACTORS',
|
||||
'SIGN_PRICED_LINES',
|
||||
'INSURER_REVIEW_NEEDS_REVISION',
|
||||
'FINAL_SIGN_OR_REJECT',
|
||||
'INSURER_APPROVAL_FALLBACK',
|
||||
"COMPLETED",
|
||||
"REJECTED",
|
||||
"CANCELLED",
|
||||
"EXPERT_RESEND",
|
||||
"WAITING_DAMAGE_EXPERT",
|
||||
"EXPERT_REVIEWING",
|
||||
"USER_FLOW",
|
||||
"UPLOAD_FACTORS",
|
||||
"EXPERT_VALIDATING_FACTORS",
|
||||
"SIGN_PRICED_LINES",
|
||||
"INSURER_REVIEW_NEEDS_REVISION",
|
||||
"FINAL_SIGN_OR_REJECT",
|
||||
"INSURER_APPROVAL_FALLBACK",
|
||||
],
|
||||
})
|
||||
phaseKey: string;
|
||||
|
||||
@ApiProperty({ description: 'Short headline for the current phase' })
|
||||
@ApiProperty({ description: "Short headline for the current phase" })
|
||||
headline: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Longer UX copy' })
|
||||
@ApiPropertyOptional({ description: "Longer UX copy" })
|
||||
detail?: string;
|
||||
|
||||
@ApiProperty({ type: [ClaimDetailsOwnerNextActionV2Dto] })
|
||||
nextActions: ClaimDetailsOwnerNextActionV2Dto[];
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Whether PUT objection is permitted (see server validation for exact rules)',
|
||||
description:
|
||||
"Whether PUT objection is permitted (see server validation for exact rules)",
|
||||
})
|
||||
objectionAllowed?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ description: 'How objection relates to priced vs factor-only lines' })
|
||||
@ApiPropertyOptional({
|
||||
description: "How objection relates to priced vs factor-only lines",
|
||||
})
|
||||
objectionHint?: string;
|
||||
}
|
||||
|
||||
@@ -86,18 +90,26 @@ export class ExpertResendDetailsV2Dto {
|
||||
fileName?: string;
|
||||
}>;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Set when the owner satisfied the resend request' })
|
||||
@ApiPropertyOptional({
|
||||
description: "Set when the owner satisfied the resend request",
|
||||
})
|
||||
fulfilledAt?: Date;
|
||||
}
|
||||
|
||||
export class ClaimDetailsV2ResponseDto {
|
||||
@ApiProperty({ description: 'Claim case ID' })
|
||||
@ApiProperty({
|
||||
description:
|
||||
"Whether this authorized viewer may act for the claim beneficiary. False means read-only access.",
|
||||
})
|
||||
canAct: boolean;
|
||||
|
||||
@ApiProperty({ description: "Claim case ID" })
|
||||
claimRequestId: string;
|
||||
|
||||
@ApiProperty({ description: 'Public ID' })
|
||||
@ApiProperty({ description: "Public ID" })
|
||||
publicId: string;
|
||||
|
||||
@ApiProperty({ description: 'Request number' })
|
||||
@ApiProperty({ description: "Request number" })
|
||||
requestNo: string;
|
||||
|
||||
@ApiProperty({
|
||||
@@ -107,35 +119,36 @@ export class ClaimDetailsV2ResponseDto {
|
||||
})
|
||||
status: string;
|
||||
|
||||
@ApiProperty({ description: 'Claim damage status' })
|
||||
@ApiProperty({ description: "Claim damage status" })
|
||||
claimStatus: string;
|
||||
|
||||
@ApiProperty({ description: 'Current workflow step' })
|
||||
@ApiProperty({ description: "Current workflow step" })
|
||||
currentStep: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Next workflow step' })
|
||||
@ApiPropertyOptional({ description: "Next workflow step" })
|
||||
nextStep?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Blame request ID' })
|
||||
@ApiPropertyOptional({ description: "Blame request ID" })
|
||||
blameRequestId?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Blame request number' })
|
||||
@ApiPropertyOptional({ description: "Blame request number" })
|
||||
blameRequestNo?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Blame file type: THIRD_PARTY or CAR_BODY',
|
||||
example: 'THIRD_PARTY',
|
||||
description: "Blame file type: THIRD_PARTY or CAR_BODY",
|
||||
example: "THIRD_PARTY",
|
||||
})
|
||||
blameType?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'How the blame file was initiated: IN_PERSON or LINK',
|
||||
example: 'IN_PERSON',
|
||||
description: "How the blame file was initiated: IN_PERSON or LINK",
|
||||
example: "IN_PERSON",
|
||||
})
|
||||
creationMethod?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Claim owner (damaged party): ids for the user and their insurer client scope',
|
||||
description:
|
||||
"Claim owner (damaged party): ids for the user and their insurer client scope",
|
||||
})
|
||||
owner?: {
|
||||
userId: string;
|
||||
@@ -144,7 +157,7 @@ export class ClaimDetailsV2ResponseDto {
|
||||
fullName?: string;
|
||||
};
|
||||
|
||||
@ApiPropertyOptional({ description: 'Vehicle snapshot' })
|
||||
@ApiPropertyOptional({ description: "Vehicle snapshot" })
|
||||
vehicle?: {
|
||||
carName?: string;
|
||||
carModel?: string;
|
||||
@@ -153,42 +166,45 @@ export class ClaimDetailsV2ResponseDto {
|
||||
};
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Selected outer damaged parts (ordered objects with id, name, side, label_fa)',
|
||||
description:
|
||||
"Selected outer damaged parts (ordered objects with id, name, side, label_fa)",
|
||||
type: [DamageSelectedPartV2BodyDto],
|
||||
})
|
||||
selectedParts?: DamageSelectedPartV2BodyDto[];
|
||||
|
||||
@ApiPropertyOptional({ description: 'Selected other damaged parts' })
|
||||
@ApiPropertyOptional({ description: "Selected other damaged parts" })
|
||||
otherParts?: string[];
|
||||
|
||||
@ApiPropertyOptional({ description: 'Bank info (masked)' })
|
||||
@ApiPropertyOptional({ description: "Bank info (masked)" })
|
||||
money?: {
|
||||
sheba?: string;
|
||||
nationalCodeOfOwner?: string;
|
||||
};
|
||||
|
||||
@ApiPropertyOptional({ description: 'Required documents status (link instead of id)' })
|
||||
@ApiPropertyOptional({
|
||||
description: "Required documents status (link instead of id)",
|
||||
})
|
||||
requiredDocuments?: Record<string, { uploaded: boolean; fileUrl?: string }>;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Car angles captured' })
|
||||
@ApiPropertyOptional({ description: "Car angles captured" })
|
||||
carAngles?: Record<string, { captured: boolean; url?: string }>;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'Per-part capture status and URLs (array index aligns with selectedParts; includes id, name, side, label_fa)',
|
||||
type: 'array',
|
||||
"Per-part capture status and URLs (array index aligns with selectedParts; includes id, name, side, label_fa)",
|
||||
type: "array",
|
||||
items: {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
properties: {
|
||||
index: { type: 'number' },
|
||||
id: { type: 'number', nullable: true },
|
||||
name: { type: 'string' },
|
||||
side: { type: 'string' },
|
||||
label_fa: { type: 'string' },
|
||||
captured: { type: 'boolean' },
|
||||
url: { type: 'string' },
|
||||
path: { type: 'string' },
|
||||
fileName: { type: 'string' },
|
||||
index: { type: "number" },
|
||||
id: { type: "number", nullable: true },
|
||||
name: { type: "string" },
|
||||
side: { type: "string" },
|
||||
label_fa: { type: "string" },
|
||||
captured: { type: "boolean" },
|
||||
url: { type: "string" },
|
||||
path: { type: "string" },
|
||||
fileName: { type: "string" },
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -206,16 +222,16 @@ export class ClaimDetailsV2ResponseDto {
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'Append-only expert damaged-part revisions. Removed rows retain their original capture URL.',
|
||||
type: 'array',
|
||||
"Append-only expert damaged-part revisions. Removed rows retain their original capture URL.",
|
||||
type: "array",
|
||||
items: {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
properties: {
|
||||
revisionId: { type: 'string' },
|
||||
changedAt: { type: 'string', format: 'date-time' },
|
||||
changedBy: { type: 'object' },
|
||||
removedParts: { type: 'array', items: { type: 'object' } },
|
||||
addedParts: { type: 'array', items: { type: 'object' } },
|
||||
revisionId: { type: "string" },
|
||||
changedAt: { type: "string", format: "date-time" },
|
||||
changedBy: { type: "object" },
|
||||
removedParts: { type: "array", items: { type: "object" } },
|
||||
addedParts: { type: "array", items: { type: "object" } },
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -233,7 +249,7 @@ export class ClaimDetailsV2ResponseDto {
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'Damage expert resend instructions and progress (when status is WAITING_FOR_USER_RESEND).',
|
||||
"Damage expert resend instructions and progress (when status is WAITING_FOR_USER_RESEND).",
|
||||
})
|
||||
expertResend?: ExpertResendDetailsV2Dto;
|
||||
|
||||
@@ -255,7 +271,8 @@ export class ClaimDetailsV2ResponseDto {
|
||||
};
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "Damage expert opinion(s): initial and final (after objection).",
|
||||
description:
|
||||
"Damage expert opinion(s): initial and final (after objection).",
|
||||
type: Object,
|
||||
})
|
||||
evaluation?: {
|
||||
@@ -266,11 +283,13 @@ export class ClaimDetailsV2ResponseDto {
|
||||
@ApiPropertyOptional({
|
||||
type: ClaimDetailsOwnerGuidanceV2Dto,
|
||||
description:
|
||||
'Owner-only: derived headline, suggested API routes, and whether objection is plausible. Omitted when the actor is FIELD_EXPERT.',
|
||||
"Owner-only: derived headline, suggested API routes, and whether objection is plausible. Omitted when the actor is FIELD_EXPERT.",
|
||||
})
|
||||
ownerGuidance?: ClaimDetailsOwnerGuidanceV2Dto;
|
||||
|
||||
@ApiPropertyOptional({ description: 'User satisfaction rating (if submitted)' })
|
||||
@ApiPropertyOptional({
|
||||
description: "User satisfaction rating (if submitted)",
|
||||
})
|
||||
userRating?: {
|
||||
progressSpeed: number;
|
||||
registrationEase: number;
|
||||
@@ -279,9 +298,9 @@ export class ClaimDetailsV2ResponseDto {
|
||||
createdAt?: Date;
|
||||
};
|
||||
|
||||
@ApiProperty({ description: 'Created at' })
|
||||
@ApiProperty({ description: "Created at" })
|
||||
createdAt: string;
|
||||
|
||||
@ApiProperty({ description: 'Updated at' })
|
||||
@ApiProperty({ description: "Updated at" })
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { ClaimRequestManagementModel } from "src/claim-request-management/entites/schema/claim-request-management.schema";
|
||||
import { ReqClaimStatus } from "src/Types&Enums/claim-request-management/status.enum";
|
||||
|
||||
export class ClaimRequestDtoRs {
|
||||
requestDetail: any;
|
||||
messsage: string;
|
||||
status: ReqClaimStatus;
|
||||
constructor(
|
||||
req: ClaimRequestManagementModel,
|
||||
message: string,
|
||||
status: ReqClaimStatus,
|
||||
) {
|
||||
this.requestDetail = req;
|
||||
this.messsage = message;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
export class CreateClaimRequestDtoRs {
|
||||
message: string;
|
||||
requestId: string;
|
||||
constructor(requestId: string, message: string) {
|
||||
this.requestId = requestId;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ClaimRequestManagementModel } from "src/claim-request-management/entites/schema/claim-request-management.schema";
|
||||
|
||||
export class ImageRequiredDto {
|
||||
public list: {} = {};
|
||||
constructor(imageModel: ClaimRequestManagementModel) {
|
||||
this.list = imageModel.imageRequired;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Types } from "mongoose";
|
||||
import { ClaimRequestManagementModel } from "src/claim-request-management/entites/schema/claim-request-management.schema";
|
||||
import { ReqClaimStatus } from "src/Types&Enums/claim-request-management/status.enum";
|
||||
|
||||
export class MyRequestsDtoList {
|
||||
status: ReqClaimStatus;
|
||||
submitDate: string;
|
||||
numberOfRequest: number;
|
||||
_id: Types.ObjectId;
|
||||
constructor(request: ClaimRequestManagementModel) {
|
||||
this._id = request["_id"];
|
||||
this.status = request.claimStatus;
|
||||
this.submitDate = new Date(request.createdAt).toLocaleString("fa-IR");
|
||||
this.numberOfRequest = request.requestNumber;
|
||||
}
|
||||
}
|
||||
|
||||
export class MyRequestsDto {
|
||||
public list = [];
|
||||
constructor(requests: ClaimRequestManagementModel[]) {
|
||||
this.list = requests.map((r) => new MyRequestsDtoList(r));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { ClaimRequestManagementModel } from "src/claim-request-management/entites/schema/claim-request-management.schema";
|
||||
import { UserCommentDto } from "src/claim-request-management/dto/user-comment.dto";
|
||||
|
||||
export class SubmitUserReplyDtoRs {
|
||||
requestId: string;
|
||||
partsNeedFactorDetail: object;
|
||||
partsNeedFactor: boolean;
|
||||
userComment: UserCommentDto;
|
||||
constructor(
|
||||
claim: ClaimRequestManagementModel,
|
||||
partsFactorDetail?,
|
||||
partsNeedFactor?,
|
||||
) {
|
||||
this.requestId = claim["_id"];
|
||||
this.partsNeedFactorDetail = partsFactorDetail;
|
||||
this.partsNeedFactor = partsNeedFactor;
|
||||
this.userComment = claim.damageExpertReply.userComment;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
|
||||
export class UserCommentDto {
|
||||
@ApiProperty({ type: Boolean })
|
||||
isAccept: boolean;
|
||||
|
||||
@ApiProperty({ type: "string", format: "binary", required: false })
|
||||
file?: Express.Multer.File;
|
||||
|
||||
@ApiProperty({ type: String })
|
||||
branch?: string;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export class UserReplyDtoRs {
|
||||
requestId: string;
|
||||
isAccept: string;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { InjectModel } from "@nestjs/mongoose";
|
||||
import { FilterQuery, Model } from "mongoose";
|
||||
import { CarGreenCardModel } from "src/claim-request-management/entites/schema/car-green-card.schema";
|
||||
|
||||
export class CarGreenCardDbService {
|
||||
constructor(
|
||||
@InjectModel(CarGreenCardModel.name)
|
||||
private readonly model: Model<CarGreenCardModel>,
|
||||
) {}
|
||||
async create(greenCard): Promise<CarGreenCardModel> {
|
||||
return await this.model.create(greenCard);
|
||||
}
|
||||
|
||||
async findOne(
|
||||
filter: FilterQuery<CarGreenCardModel>,
|
||||
): Promise<CarGreenCardModel> {
|
||||
return await this.model.findOne({ filter });
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,15 @@ export class ClaimCaseDbService {
|
||||
return this.claimCaseModel.create(payload);
|
||||
}
|
||||
|
||||
async findById(id: string | Types.ObjectId): Promise<ClaimCaseDocument | null> {
|
||||
async findById(
|
||||
id: string | Types.ObjectId,
|
||||
): Promise<ClaimCaseDocument | null> {
|
||||
return this.claimCaseModel.findById(id);
|
||||
}
|
||||
|
||||
async findOne(filter: FilterQuery<ClaimCase>): Promise<ClaimCaseDocument | null> {
|
||||
async findOne(
|
||||
filter: FilterQuery<ClaimCase>,
|
||||
): Promise<ClaimCaseDocument | null> {
|
||||
return this.claimCaseModel.findOne(filter);
|
||||
}
|
||||
|
||||
@@ -54,8 +58,4 @@ export class ClaimCaseDbService {
|
||||
: this.claimCaseModel.find(filter);
|
||||
return query.exec() as Promise<ClaimCaseDocument[]>;
|
||||
}
|
||||
|
||||
async countByFilter(filter: FilterQuery<ClaimCase>): Promise<number> {
|
||||
return this.claimCaseModel.countDocuments(filter);
|
||||
}
|
||||
}
|
||||
|
||||
-72
@@ -11,16 +11,6 @@ export class ClaimRequestManagementDbService {
|
||||
private readonly model: Model<ClaimRequestManagementModel>,
|
||||
) {}
|
||||
|
||||
async create(
|
||||
claimRequest: ClaimRequestManagementModel,
|
||||
): Promise<ClaimRequestManagementModel> {
|
||||
const uniqueRequestNumber = await this.generateUniqueNumbers();
|
||||
return this.model.create({
|
||||
...claimRequest,
|
||||
requestNumber: uniqueRequestNumber,
|
||||
});
|
||||
}
|
||||
|
||||
async findOne(
|
||||
id?: string,
|
||||
filter?: FilterQuery<ClaimRequestManagementModel>,
|
||||
@@ -45,31 +35,6 @@ export class ClaimRequestManagementDbService {
|
||||
return await this.model.findOneAndUpdate(filter, update, option);
|
||||
}
|
||||
|
||||
async findAllByStatus(filter: FilterQuery<ClaimRequestManagementModel>) {
|
||||
return await this.model.find(filter);
|
||||
}
|
||||
|
||||
async findAndDelete(
|
||||
filter: FilterQuery<ClaimRequestManagementModel>,
|
||||
option,
|
||||
) {
|
||||
return await this.model.deleteMany(filter, option);
|
||||
}
|
||||
|
||||
async findAllAndPagination(
|
||||
filter: FilterQuery<ClaimRequestManagementModel>,
|
||||
currentPage: number,
|
||||
countPerPage: number,
|
||||
) {
|
||||
const responsePerPage = countPerPage | 1;
|
||||
const skipPge = responsePerPage * (Number(currentPage) - 1);
|
||||
return await this.model.find(filter).limit(responsePerPage).skip(skipPge);
|
||||
}
|
||||
|
||||
async aggregate(filter?) {
|
||||
return await this.model.aggregate(filter);
|
||||
}
|
||||
|
||||
async findAndUpdate(
|
||||
id: string,
|
||||
update: UpdateQuery<ClaimRequestManagementModel>,
|
||||
@@ -81,41 +46,4 @@ export class ClaimRequestManagementDbService {
|
||||
option,
|
||||
);
|
||||
}
|
||||
|
||||
async findAllByAnyFilter(
|
||||
filter: FilterQuery<ClaimRequestManagementModel>,
|
||||
): Promise<ClaimRequestManagementModel[]> {
|
||||
return await this.model.find(filter);
|
||||
}
|
||||
|
||||
async countByFilter(
|
||||
filter: FilterQuery<ClaimRequestManagementModel>,
|
||||
): Promise<number> {
|
||||
return await this.model.countDocuments(filter);
|
||||
}
|
||||
async findAll(): Promise<ClaimRequestManagementModel[]> {
|
||||
return await this.model.find();
|
||||
}
|
||||
async generateUniqueNumbers(digits = 5) {
|
||||
try {
|
||||
const max = Math.pow(10, digits);
|
||||
const randomBytes = crypto.randomBytes(Math.ceil(digits / 2));
|
||||
const randomNumber = parseInt(randomBytes.toString("hex"), 16) % max;
|
||||
return randomNumber.toString().padStart(digits, "0");
|
||||
} catch (error) {
|
||||
console.error("Error generating unique numbers:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async findAllWithFilter(filter?: FilterQuery<ClaimRequestManagementModel>) {
|
||||
return await this.model.find(filter);
|
||||
}
|
||||
|
||||
async findByIdAndUpdate(
|
||||
id: string,
|
||||
updateDto: UpdateQuery<ClaimRequestManagementModel>,
|
||||
): Promise<ClaimRequestManagementModel | null> {
|
||||
return this.model.findByIdAndUpdate(id, updateDto, { new: true }).lean();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-23
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectModel } from "@nestjs/mongoose";
|
||||
import { FilterQuery, Model, Types } from "mongoose";
|
||||
import { Model, Types } from "mongoose";
|
||||
import { ClaimRequiredDocument } from "src/claim-request-management/entites/schema/claim-required-document.schema";
|
||||
|
||||
@Injectable()
|
||||
@@ -10,32 +10,13 @@ export class ClaimRequiredDocumentDbService {
|
||||
private readonly model: Model<ClaimRequiredDocument>,
|
||||
) {}
|
||||
|
||||
async create(document: Partial<ClaimRequiredDocument>): Promise<ClaimRequiredDocument> {
|
||||
async create(
|
||||
document: Partial<ClaimRequiredDocument>,
|
||||
): Promise<ClaimRequiredDocument> {
|
||||
return await this.model.create(document);
|
||||
}
|
||||
|
||||
async findOne(
|
||||
filter: FilterQuery<ClaimRequiredDocument>,
|
||||
): Promise<ClaimRequiredDocument | null> {
|
||||
return await this.model.findOne(filter);
|
||||
}
|
||||
|
||||
async findAll(
|
||||
filter: FilterQuery<ClaimRequiredDocument>,
|
||||
): Promise<ClaimRequiredDocument[]> {
|
||||
return await this.model.find(filter);
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<ClaimRequiredDocument | null> {
|
||||
return this.model.findById(id).lean();
|
||||
}
|
||||
|
||||
async findByClaimId(claimId: string): Promise<ClaimRequiredDocument[]> {
|
||||
return this.model.find({ claimId: new Types.ObjectId(claimId) });
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
await this.model.findByIdAndDelete(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { InjectModel } from "@nestjs/mongoose";
|
||||
import { Model, Types } from "mongoose";
|
||||
import { DamagePartImageModel } from "src/claim-request-management/entites/schema/damage-image-part.schema";
|
||||
|
||||
export class DamageImageDbService {
|
||||
constructor(
|
||||
@InjectModel(DamagePartImageModel.name)
|
||||
private readonly model: Model<DamagePartImageModel>,
|
||||
) {}
|
||||
|
||||
async create(image): Promise<DamagePartImageModel> {
|
||||
return await this.model.create(image);
|
||||
}
|
||||
|
||||
async findOne(id: string): Promise<DamagePartImageModel> {
|
||||
return await this.model.findById(new Types.ObjectId(id));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectModel } from "@nestjs/mongoose";
|
||||
import { FilterQuery, Model } from "mongoose";
|
||||
import { Model } from "mongoose";
|
||||
import { ClaimFactorsImage } from "src/claim-request-management/entites/schema/factor-image.schema";
|
||||
|
||||
@Injectable()
|
||||
@@ -13,12 +13,6 @@ export class ClaimFactorsImageDbService {
|
||||
return await this.model.create(image);
|
||||
}
|
||||
|
||||
async findOne(
|
||||
filter: FilterQuery<ClaimFactorsImage>,
|
||||
): Promise<ClaimFactorsImage> {
|
||||
return await this.model.findOne({ filter });
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<ClaimFactorsImage | null> {
|
||||
return this.model.findById(id).lean();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectModel } from "@nestjs/mongoose";
|
||||
import { FilterQuery, Model } from "mongoose";
|
||||
import { Model } from "mongoose";
|
||||
import { VideoCaptureModel } from "src/claim-request-management/entites/schema/video-capture.schema";
|
||||
|
||||
@Injectable()
|
||||
@@ -13,12 +13,6 @@ export class VideoCaptureDbService {
|
||||
return await this.videoCapture.create(video);
|
||||
}
|
||||
|
||||
async findOne(
|
||||
filter: FilterQuery<VideoCaptureModel>,
|
||||
): Promise<VideoCaptureModel> {
|
||||
return await this.videoCapture.findOne(filter);
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<VideoCaptureModel | null> {
|
||||
return this.videoCapture.findById(id);
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import mongoose, { Types } from "mongoose";
|
||||
|
||||
@Schema({ versionKey: false })
|
||||
export class ActionUserModel extends mongoose.Document {
|
||||
@Prop({ required: true, type: Types.ObjectId })
|
||||
userId: Types.ObjectId;
|
||||
|
||||
@Prop({ required: true, type: Date })
|
||||
date: Date;
|
||||
}
|
||||
|
||||
export const ActionActorSchema = SchemaFactory.createForClass(ActionUserModel);
|
||||
@@ -1,29 +0,0 @@
|
||||
import { Prop } from "@nestjs/mongoose";
|
||||
import mongoose, { Types } from "mongoose";
|
||||
import { ActionUserModel } from "./action-user.schema";
|
||||
|
||||
export class ClaimBaseModel extends mongoose.Document {
|
||||
@Prop()
|
||||
readonly _id: Types.ObjectId;
|
||||
|
||||
@Prop()
|
||||
readonly created: Date;
|
||||
|
||||
@Prop({
|
||||
required: false,
|
||||
type: ActionUserModel,
|
||||
})
|
||||
createdBy: ActionUserModel;
|
||||
|
||||
@Prop({ required: false })
|
||||
readonly updated: Date;
|
||||
|
||||
@Prop({
|
||||
required: false,
|
||||
type: [ActionUserModel],
|
||||
})
|
||||
updatedBy: ActionUserModel[];
|
||||
|
||||
@Prop()
|
||||
readonly deleted: boolean;
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post, UploadedFile, UseGuards, UseInterceptors } from "@nestjs/common";
|
||||
import { FileInterceptor } from "@nestjs/platform-express";
|
||||
import { diskStorage } from "multer";
|
||||
import { extname } from "path";
|
||||
import { ApiBearerAuth, ApiConsumes, ApiExcludeController } from "@nestjs/swagger";
|
||||
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
|
||||
import { RolesGuard } from "src/auth/guards/role.guard";
|
||||
import { Roles } from "src/decorators/roles.decorator";
|
||||
import { CurrentUser } from "src/decorators/user.decorator";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { DEFAULT_MEDIA_MAX_BYTES } from "src/client/client.service";
|
||||
import { SelectOuterPartsV2Dto } from "./dto/select-outer-parts-v2.dto";
|
||||
import { SelectOtherPartsV2Dto } from "./dto/select-other-parts-v2.dto";
|
||||
import { UploadRequiredDocumentV2Dto } from "./dto/upload-document-v2.dto";
|
||||
import { CapturePartV2Dto } from "./dto/capture-part-v2.dto";
|
||||
import { ClaimRequestManagementService } from "./claim-request-management.service";
|
||||
|
||||
@ApiExcludeController()
|
||||
// @ApiTags("registrar-claim (v1)")
|
||||
@Controller("registrar-claim")
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
||||
@Roles(RoleEnum.REGISTRAR)
|
||||
export class RegistrarClaimV1Controller {
|
||||
constructor(private readonly claimRequestManagementService: ClaimRequestManagementService) {}
|
||||
|
||||
@Post("create-from-blame/:blameRequestId")
|
||||
// @ApiParam({ name: "blameRequestId" })
|
||||
createFromBlame(@Param("blameRequestId") blameRequestId: string, @CurrentUser() registrar: any) {
|
||||
return this.claimRequestManagementService.createClaimFromBlameForRegistrarV1(
|
||||
blameRequestId,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
|
||||
@Get("request/:claimRequestId")
|
||||
getClaim(@Param("claimRequestId") claimRequestId: string, @CurrentUser() registrar: any) {
|
||||
return this.claimRequestManagementService.getClaimDetailsV2(
|
||||
claimRequestId,
|
||||
registrar.sub,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
|
||||
@Patch("select-outer-parts/:claimRequestId")
|
||||
// @ApiBody({ type: SelectOuterPartsV2Dto })
|
||||
selectOuter(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() body: SelectOuterPartsV2Dto,
|
||||
@CurrentUser() registrar: any,
|
||||
) {
|
||||
return this.claimRequestManagementService.selectOuterPartsV2(
|
||||
claimRequestId,
|
||||
body,
|
||||
registrar.sub,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
|
||||
@Patch("select-other-parts/:claimRequestId")
|
||||
// @ApiBody({ type: SelectOtherPartsV2Dto })
|
||||
selectOther(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() body: SelectOtherPartsV2Dto,
|
||||
@CurrentUser() registrar: any,
|
||||
) {
|
||||
return this.claimRequestManagementService.selectOtherPartsV2(
|
||||
claimRequestId,
|
||||
body,
|
||||
registrar.sub,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
|
||||
@Get("capture-requirements/:claimRequestId")
|
||||
getCapture(@Param("claimRequestId") claimRequestId: string, @CurrentUser() registrar: any) {
|
||||
return this.claimRequestManagementService.getCaptureRequirementsV2(
|
||||
claimRequestId,
|
||||
registrar.sub,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
|
||||
@Post("upload-document/:claimRequestId")
|
||||
@ApiConsumes("multipart/form-data")
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
storage: diskStorage({
|
||||
destination: "./files/claim-documents",
|
||||
filename: (req, file, cb) => cb(null, `${Date.now()}${extname(file.originalname)}`),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiOperation({ summary: "Registrar uploads required claim document" })
|
||||
uploadDoc(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() body: UploadRequiredDocumentV2Dto,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@CurrentUser() registrar: any,
|
||||
) {
|
||||
return this.claimRequestManagementService.uploadRequiredDocumentV2(
|
||||
claimRequestId,
|
||||
body,
|
||||
file,
|
||||
registrar.sub,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
|
||||
@Post("capture-part/:claimRequestId")
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: { fileSize: DEFAULT_MEDIA_MAX_BYTES },
|
||||
storage: diskStorage({
|
||||
destination: "./files/claim-captures",
|
||||
filename: (req, file, cb) => cb(null, `${Date.now()}${extname(file.originalname)}`),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
capturePart(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() body: CapturePartV2Dto,
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@CurrentUser() registrar: any,
|
||||
) {
|
||||
return this.claimRequestManagementService.capturePartV2(
|
||||
claimRequestId,
|
||||
body,
|
||||
file,
|
||||
registrar.sub,
|
||||
registrar,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user