forked from Yara724/api
YARA-1110
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Param,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from "@nestjs/common";
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiBody,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiTags,
|
||||
} from "@nestjs/swagger";
|
||||
import { IsOptional, IsString } from "class-validator";
|
||||
import { ApiPropertyOptional } 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 { RequestManagementService } from "./request-management.service";
|
||||
import { ClaimRequestManagementService } from "src/claim-request-management/claim-request-management.service";
|
||||
|
||||
class FileMakerRejectDto {
|
||||
@ApiPropertyOptional({
|
||||
description: "Reason for rejection (visible to FileReviewer)",
|
||||
example: "Damage assessment is incorrect — please re-evaluate parts X and Y",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* V5 FileMaker approval panel.
|
||||
*
|
||||
* After the full claim flow completes (FileReviewer does damage assessment via
|
||||
* expert-claim APIs, user signs), the claim lands in WAITING_FOR_FILE_MAKER_APPROVAL.
|
||||
* The FileMaker who created the blame file can then:
|
||||
*
|
||||
* approve → triggers fanavaran submission (claim → COMPLETED)
|
||||
* reject → sends claim back to WAITING_FOR_DAMAGE_EXPERT so the FileReviewer
|
||||
* can re-lock, adjust pricing, and redo the user interaction
|
||||
*
|
||||
* All endpoints operate on `claimRequestId` (the claim case ID, not the blame ID).
|
||||
* Use `GET v5/file-maker/blame-request-management/claim-id/:requestId` to obtain
|
||||
* the claimRequestId from the original blame request ID.
|
||||
*/
|
||||
@ApiTags("v5 FileMaker — claim approval before fanavaran")
|
||||
@Controller("v5/file-maker/claim-approval")
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
||||
@Roles(RoleEnum.FILE_MAKER)
|
||||
export class FileMakerClaimApprovalV5Controller {
|
||||
constructor(
|
||||
private readonly requestManagementService: RequestManagementService,
|
||||
private readonly claimRequestManagementService: ClaimRequestManagementService,
|
||||
) {}
|
||||
|
||||
@Post("approve/:claimRequestId")
|
||||
@ApiParam({ name: "claimRequestId" })
|
||||
@ApiOperation({
|
||||
summary: "Approve the completed claim (FileMaker V5)",
|
||||
description:
|
||||
"Approves a claim that is in WAITING_FOR_FILE_MAKER_APPROVAL status. " +
|
||||
"Marks the claim COMPLETED and triggers fanavaran submission.",
|
||||
})
|
||||
async approve(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@CurrentUser() fileMaker: any,
|
||||
) {
|
||||
const result = await this.requestManagementService.fileMakerApproveV5(
|
||||
fileMaker,
|
||||
claimRequestId,
|
||||
);
|
||||
|
||||
// Trigger fanavaran auto-submit now that the claim is COMPLETED and the gate
|
||||
// (requiresFileMakerApproval) has been cleared.
|
||||
const fanavaran =
|
||||
await this.claimRequestManagementService.autoSubmitToFanavaranV2OnClaimCompleted(
|
||||
claimRequestId,
|
||||
);
|
||||
|
||||
return { ...result, fanavaran };
|
||||
}
|
||||
|
||||
@Post("reject/:claimRequestId")
|
||||
@ApiParam({ name: "claimRequestId" })
|
||||
@ApiBody({ type: FileMakerRejectDto })
|
||||
@ApiOperation({
|
||||
summary: "Reject the completed claim back to FileReviewer (FileMaker V5)",
|
||||
description:
|
||||
"Rejects a claim that is in WAITING_FOR_FILE_MAKER_APPROVAL status. " +
|
||||
"Moves claim to FILE_MAKER_REJECTED so the FileReviewer can re-lock, " +
|
||||
"adjust the damage assessment, and restart user interaction as needed.",
|
||||
})
|
||||
async reject(
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() body: FileMakerRejectDto,
|
||||
@CurrentUser() fileMaker: any,
|
||||
) {
|
||||
return this.requestManagementService.fileMakerRejectV5(
|
||||
fileMaker,
|
||||
claimRequestId,
|
||||
body?.reason,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user