fanavaran duplication request problems fixed.

This commit is contained in:
2026-08-02 17:00:19 +03:30
parent c2f5c576fa
commit b345818d43
9 changed files with 884 additions and 123 deletions

View File

@@ -18,6 +18,8 @@ import {
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
import { ClaimRequestManagementService } from "src/claim-request-management/claim-request-management.service";
import {
FANAVARAN_CLIENT_KEYS,
FANAVARAN_CLIENT_SWAGGER_ENUM,
isFanavaranClientKey,
listFanavaranClientProfiles,
normalizeFanavaranClientKey,
@@ -37,7 +39,7 @@ export class FanavaranController {
@ApiOperation({
summary: "List supported Fanavaran insurance clients",
description:
"Returns configured Fanavaran tenants (parsian, tejaratno) and which client is active for this deployment.",
"Returns configured Fanavaran tenants (parsian, tejaratno, moallem) and which client is active for this deployment.",
})
listClients() {
const activeClient = resolveFanavaranClientKey();
@@ -60,7 +62,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -75,26 +77,33 @@ export class FanavaranController {
name: "forceRefreshPolicy",
required: false,
description:
"When true, ignores cached PolicyId and performs a live Fanavaran policy inquiry again",
"When true, ignores cached PolicyId and performs a live Fanavaran policy inquiry again. Do not pass this from normal UI loads.",
})
@ApiQuery({
name: "resolvePolicy",
required: false,
deprecated: true,
description:
"Deprecated. Ignored for cache-busting. PolicyId is resolve-once from fanavaranSync.baseClaim.policyId; use forceRefreshPolicy=true only to re-inquire.",
})
async preview(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
@Query("debug") debug?: string,
@Query("forceRefreshPolicy") forceRefreshPolicy?: string,
@Query("resolvePolicy") resolvePolicy?: string,
@Query("resolvePolicy") _resolvePolicy?: string,
) {
const clientKey = this.parseClientParam(client);
// IMPORTANT: resolvePolicy must NOT force a live inquiry. Older UI clients
// send resolvePolicy=true on every preview load; that used to defeat the
// PolicyId cache and re-Login Fanavaran on every click.
return await this.claimRequestManagementService.previewFanavaranSubmitV2(
claimCaseId,
clientKey,
{
debug: debug === "1" || debug === "true",
forceRefreshPolicy:
forceRefreshPolicy === "1" ||
forceRefreshPolicy === "true" ||
resolvePolicy === "1" ||
resolvePolicy === "true",
forceRefreshPolicy === "1" || forceRefreshPolicy === "true",
requirePolicyId: false,
},
);
@@ -109,7 +118,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -137,7 +146,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -158,12 +167,12 @@ export class FanavaranController {
@ApiOperation({
summary: "Submit Fanavaran damage-case request",
description:
"Submits the GEN.12 dmg-cases request for the already-created Fanavaran claim and stores returned Id as local dmgCaseId.",
"Submits the GEN.12 dmg-cases request. If base claim (claimId) is missing, soft-ensures GEN.03 base claim first, then submits damage. Skips when dmgCaseId already exists.",
})
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -191,7 +200,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -217,7 +226,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -243,7 +252,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -269,7 +278,7 @@ export class FanavaranController {
@ApiParam({
name: "client",
description: "Fanavaran tenant key",
enum: ["parsian", "tejaratno"],
enum: FANAVARAN_CLIENT_SWAGGER_ENUM,
})
@ApiParam({
name: "claimCaseId",
@@ -291,7 +300,7 @@ export class FanavaranController {
private parseClientParam(client: string) {
if (!isFanavaranClientKey(client)) {
throw new BadRequestException(
`Invalid Fanavaran client "${client}". Expected one of: parsian, tejaratno`,
`Invalid Fanavaran client "${client}". Expected one of: ${FANAVARAN_CLIENT_KEYS.join(", ")}`,
);
}
return normalizeFanavaranClientKey(client);