forked from Yara724/api
Submit Fanavaran base on claim create for all flows.
GEN.03 no longer waits on vehicle review; V3/file-maker create triggers early auto-submit, and expertise auto-path soft-ensures prior stages when each client's body is ready. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -113,7 +113,7 @@ flowchart TD
|
||||
|
||||
| Stage | Auto trigger | Function |
|
||||
|-------|--------------|----------|
|
||||
| Base | Claim create (early) | `autoSubmitToFanavaranV2OnClaimCreated` |
|
||||
| Base | Claim create (early; V1/V2/V3/file-maker creates; not deferred to expertise) | `autoSubmitToFanavaranV2OnClaimCreated` |
|
||||
| Base | Claim completed (legacy/fallback; skips if already submitted) | `autoSubmitToFanavaranV2OnClaimCompleted` |
|
||||
| Damage | After outer parts selection | `autoSubmitFanavaranDamageCaseOnOuterPartsSelected` |
|
||||
| Attachments | After successful local image/doc upload | `autoSubmitFanavaranAttachment` |
|
||||
|
||||
@@ -45,7 +45,7 @@ source: fanavaran-module-docs
|
||||
| Controller | `FanavaranController.preview` / `submit` |
|
||||
| Service | `ClaimRequestManagementService` |
|
||||
| Functions | `previewFanavaranSubmitV2`, `submitFanavaranV2`, `executeFanavaranV2Submit`, `buildFanavaranSubmitPayload`, `getPolicyIdFromNationalCode` |
|
||||
| When | Auto on claim create; manual preview/submit |
|
||||
| When | Auto on claim create (all create paths including V3); soft-ensure before later stages; manual preview/submit. Vehicle review is **not** required for GEN.03 — only for damage/attachments/expertise. |
|
||||
| Send | GEN.03 JSON + business headers |
|
||||
| Receive | `Id`, `ClaimNo` |
|
||||
| Store | `claimId`, `claimNo`, `fanavaranSync.baseClaim.*`, history |
|
||||
|
||||
@@ -6423,18 +6423,14 @@ export class ClaimRequestManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
if (!claimCase.claimId) {
|
||||
await this.autoSubmitToFanavaranV2OnClaimCreated(claimCaseId);
|
||||
claimCase = await this.claimCaseDbService.findById(claimCaseId);
|
||||
}
|
||||
// Same ordered soft-ensure as manual expertise submit: base → damage → files.
|
||||
await this.completeFanavaranExpertisePrerequisites(
|
||||
claimCaseId,
|
||||
clientKey,
|
||||
FanavaranAuditSource.AUTO_SUBMIT,
|
||||
);
|
||||
claimCase = await this.claimCaseDbService.findById(claimCaseId);
|
||||
const product = await this.resolveFanavaranClaimProduct(claimCaseId);
|
||||
if (fanavaranHasDamageCaseStage(product) && !claimCase?.dmgCaseId) {
|
||||
await this.autoSubmitFanavaranDamageCaseOnOuterPartsSelected(
|
||||
claimCaseId,
|
||||
claimCase?.damage?.selectedParts ?? [],
|
||||
);
|
||||
claimCase = await this.claimCaseDbService.findById(claimCaseId);
|
||||
}
|
||||
|
||||
const { payload, warnings } = await this.buildFanavaranExpertisePayload({
|
||||
claimCase,
|
||||
@@ -6559,9 +6555,8 @@ export class ClaimRequestManagementService {
|
||||
return 'Already submitted to Fanavaran';
|
||||
}
|
||||
|
||||
if (!claimCase.fanavaranVehicleReview?.approved) {
|
||||
return 'Expert vehicle review is required before Fanavaran submission';
|
||||
}
|
||||
// GEN.03 base claim is sent as soon as the local claim exists.
|
||||
// Vehicle review remains required for damage / attachments / expertise only.
|
||||
|
||||
const clientKey = resolveFanavaranClientKey();
|
||||
const notifierAllowed =
|
||||
@@ -7643,7 +7638,7 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
}
|
||||
if (!existing) throw new NotFoundException('Claim case not found');
|
||||
this.assertFanavaranVehicleReviewApproved(existing);
|
||||
// Vehicle review is not required for GEN.03 base — only for later stages.
|
||||
const notifierAllowed =
|
||||
clientKey === 'tejaratno'
|
||||
? await this.tejaratNotifierAllowedIds(clientKey)
|
||||
|
||||
@@ -2,8 +2,10 @@ import {
|
||||
BadRequestException,
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
forwardRef,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Inject,
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
@@ -30,6 +32,7 @@ import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { UserAuthService } from "src/auth/auth-services/user.auth.service";
|
||||
import { ClaimCaseDbService } from "src/claim-request-management/entites/db-service/claim-case.db.service";
|
||||
import { ClaimRequestManagementDbService } from "src/claim-request-management/entites/db-service/claim-request-management.db.service";
|
||||
import { ClaimRequestManagementService } from "src/claim-request-management/claim-request-management.service";
|
||||
import { fanavaranClaimReferences } from "src/claim-request-management/fanavaran-claim-references";
|
||||
import { ClientService } from "src/client/client.service";
|
||||
import { VehicleRegistrationState } from "src/common/dto/inquiry-participants.dto";
|
||||
@@ -1131,6 +1134,8 @@ export class RequestManagementService {
|
||||
|
||||
private readonly claimRequestManagementDbService: ClaimRequestManagementDbService,
|
||||
private readonly claimCaseDbService: ClaimCaseDbService,
|
||||
@Inject(forwardRef(() => ClaimRequestManagementService))
|
||||
private readonly claimRequestManagementService: ClaimRequestManagementService,
|
||||
private readonly publicIdService: PublicIdService,
|
||||
private readonly workflowStepDbService: WorkflowStepDbService,
|
||||
private readonly hashService: HashService,
|
||||
@@ -7165,7 +7170,20 @@ export class RequestManagementService {
|
||||
],
|
||||
};
|
||||
|
||||
return this.claimCaseDbService.create(newClaimData);
|
||||
const created = await this.claimCaseDbService.create(newClaimData);
|
||||
// Same early GEN.03 path as V1/V2 createClaimFromBlame* — do not wait for expertise.
|
||||
try {
|
||||
await this.claimRequestManagementService.autoSubmitToFanavaranV2OnClaimCreated(
|
||||
String((created as any)._id),
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.warn(
|
||||
`Fanavaran early base submit after V3 claim create failed claimCaseId=${String(
|
||||
(created as any)._id,
|
||||
)}: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
private ensureV3GuiltyPartyDecision(req: any): void {
|
||||
|
||||
Reference in New Issue
Block a user