forked from Yara724/api
Add TejaratNo notifier review and submission validation
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
hasReviewedTejaratNotifier,
|
||||
tejaratNotifierLookup,
|
||||
} from "src/fanavaran/tejarat-notifier";
|
||||
import {
|
||||
BadGatewayException,
|
||||
BadRequestException,
|
||||
@@ -4287,9 +4291,10 @@ export class ClaimRequestManagementService {
|
||||
claimCase,
|
||||
"car-body",
|
||||
"baseClaim",
|
||||
clientKey,
|
||||
);
|
||||
delete payload.IsLicenseReplacement;
|
||||
const hull = toFanavaranHullBaseClaimPayload(payload);
|
||||
const hull = toFanavaranHullBaseClaimPayload(payload, clientKey);
|
||||
for (const key of Object.keys(payload)) delete payload[key];
|
||||
Object.assign(payload, hull);
|
||||
}
|
||||
@@ -4302,6 +4307,7 @@ export class ClaimRequestManagementService {
|
||||
claimCase,
|
||||
"third-party",
|
||||
"baseClaim",
|
||||
clientKey,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5092,7 +5098,7 @@ export class ClaimRequestManagementService {
|
||||
const product = fanavaranClaimProductFromBlameType(blame.type);
|
||||
const clientKey = resolveFanavaranClientKey();
|
||||
const defaults = getFanavaranClientProfile(clientKey).defaults;
|
||||
const definitions = fanavaranStageFields(product);
|
||||
const definitions = fanavaranStageFields(product, clientKey);
|
||||
const options = new Map<string, ReturnType<typeof activeStageLookupRows>>();
|
||||
await Promise.all(
|
||||
definitions
|
||||
@@ -5130,6 +5136,7 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
return {
|
||||
product,
|
||||
clientKey,
|
||||
version: claim.fanavaranFieldReview?.version ?? 0,
|
||||
reviewedAt: claim.fanavaranFieldReview?.reviewedAt,
|
||||
reviewedByActorName: claim.fanavaranFieldReview?.reviewedByActorName,
|
||||
@@ -5173,6 +5180,10 @@ export class ClaimRequestManagementService {
|
||||
clientKey: FanavaranClientKey,
|
||||
name: string,
|
||||
): Promise<unknown[]> {
|
||||
if (clientKey === "tejaratno") {
|
||||
const supplied = tejaratNotifierLookup(name);
|
||||
if (supplied) return supplied;
|
||||
}
|
||||
const definition = this.fanavaranLookupDefinition(name);
|
||||
try {
|
||||
const data = await this.fanavaranLookupService.getRemoteLookup(
|
||||
@@ -5781,6 +5792,15 @@ export class ClaimRequestManagementService {
|
||||
return "Expert vehicle review is required before Fanavaran submission";
|
||||
}
|
||||
|
||||
if (
|
||||
!hasReviewedTejaratNotifier(
|
||||
claimCase.fanavaranFieldReview?.values,
|
||||
resolveFanavaranClientKey(),
|
||||
)
|
||||
) {
|
||||
return "نوع و نسبت اعلامکننده باید پیش از ارسال اولیه پرونده به فناوران انتخاب شوند.";
|
||||
}
|
||||
|
||||
if (!claimCase.blameRequestId) {
|
||||
return "Blame case not linked to claim case";
|
||||
}
|
||||
@@ -5994,6 +6014,7 @@ export class ClaimRequestManagementService {
|
||||
built && typeof built === "object" && "payload" in built
|
||||
? (built as { payload: Record<string, unknown> }).payload
|
||||
: built,
|
||||
clientKey,
|
||||
);
|
||||
const url = `${fanavaranClaimsBaseUrl("car-body")}/${nestedId}`;
|
||||
this.logger.log(
|
||||
@@ -6861,6 +6882,15 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
if (!existing) throw new NotFoundException("Claim case not found");
|
||||
this.assertFanavaranVehicleReviewApproved(existing);
|
||||
if (
|
||||
!hasReviewedTejaratNotifier(existing.fanavaranFieldReview?.values, clientKey)
|
||||
) {
|
||||
throw new ConflictException({
|
||||
code: "FANAVARAN_NOTIFIER_REVIEW_REQUIRED",
|
||||
message:
|
||||
"نوع و نسبت اعلامکننده باید پیش از ارسال اولیه پرونده به فناوران بررسی و انتخاب شوند.",
|
||||
});
|
||||
}
|
||||
|
||||
const auditSession: FanavaranAuditSession = {
|
||||
trackingCode: this.fanavaranAuditService.generateTrackingCode(),
|
||||
|
||||
Reference in New Issue
Block a user