forked from Yara724/api
badane bugs continues
This commit is contained in:
@@ -50,6 +50,7 @@ import {
|
|||||||
type FanavaranClaimProduct,
|
type FanavaranClaimProduct,
|
||||||
} from "./fanavaran-claim-product";
|
} from "./fanavaran-claim-product";
|
||||||
import {
|
import {
|
||||||
|
collectFanavaranExpertiseReadinessWarnings,
|
||||||
hullExpertiseAssertFields,
|
hullExpertiseAssertFields,
|
||||||
pickHullVehicleIdentity,
|
pickHullVehicleIdentity,
|
||||||
toFanavaranHullExpertiseDmgSection,
|
toFanavaranHullExpertiseDmgSection,
|
||||||
@@ -6154,6 +6155,7 @@ export class ClaimRequestManagementService {
|
|||||||
|
|
||||||
const url = `${await this.fanavaranClaimsUrlForClaim(claimCaseId)}/${claimCase.claimId}/files`;
|
const url = `${await this.fanavaranClaimsUrlForClaim(claimCaseId)}/${claimCase.claimId}/files`;
|
||||||
const fileTypeId = profile.defaults.ClaimFileTypeId;
|
const fileTypeId = profile.defaults.ClaimFileTypeId;
|
||||||
|
const product = await this.resolveFanavaranClaimProduct(claimCaseId);
|
||||||
|
|
||||||
const logPrefix = `[Fanavaran ${clientKey} V2 Attachment Batch] claimCaseId=${claimCaseId}`;
|
const logPrefix = `[Fanavaran ${clientKey} V2 Attachment Batch] claimCaseId=${claimCaseId}`;
|
||||||
|
|
||||||
@@ -6164,6 +6166,7 @@ export class ClaimRequestManagementService {
|
|||||||
const content = {
|
const content = {
|
||||||
FileName: candidate.fileName,
|
FileName: candidate.fileName,
|
||||||
FileTypeId: fileTypeId,
|
FileTypeId: fileTypeId,
|
||||||
|
...(product === "car-body" ? { ClaimId: claimCase.claimId } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
@@ -6187,6 +6190,7 @@ export class ClaimRequestManagementService {
|
|||||||
submitted: true,
|
submitted: true,
|
||||||
claimId: claimCase.claimId,
|
claimId: claimCase.claimId,
|
||||||
fileName: candidate.fileName,
|
fileName: candidate.fileName,
|
||||||
|
submitUrl: url,
|
||||||
fanavaranResponse: response.data,
|
fanavaranResponse: response.data,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -6199,6 +6203,8 @@ export class ClaimRequestManagementService {
|
|||||||
submitted: false,
|
submitted: false,
|
||||||
warning,
|
warning,
|
||||||
fileName: candidate.fileName,
|
fileName: candidate.fileName,
|
||||||
|
claimId: claimCase.claimId,
|
||||||
|
submitUrl: url,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Schedule a retry for this individual file via autoSubmitFanavaranAttachment,
|
// Schedule a retry for this individual file via autoSubmitFanavaranAttachment,
|
||||||
@@ -6318,6 +6324,10 @@ export class ClaimRequestManagementService {
|
|||||||
Files: [
|
Files: [
|
||||||
{ FileName: fileName, FileTypeId: profile.defaults.ClaimFileTypeId },
|
{ FileName: fileName, FileTypeId: profile.defaults.ClaimFileTypeId },
|
||||||
],
|
],
|
||||||
|
...((await this.resolveFanavaranClaimProduct(claimCaseId)) ===
|
||||||
|
"car-body"
|
||||||
|
? { ClaimId: claimCase.claimId }
|
||||||
|
: {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const auditSession: FanavaranAuditSession = {
|
const auditSession: FanavaranAuditSession = {
|
||||||
@@ -6793,36 +6803,15 @@ export class ClaimRequestManagementService {
|
|||||||
warnings: string[],
|
warnings: string[],
|
||||||
options?: { requireDmgCaseId?: boolean; requireThirdPartyLookups?: boolean },
|
options?: { requireDmgCaseId?: boolean; requireThirdPartyLookups?: boolean },
|
||||||
): void {
|
): void {
|
||||||
const sections = Array.isArray(payload.DmgSections)
|
const readyWarnings = collectFanavaranExpertiseReadinessWarnings(
|
||||||
? payload.DmgSections
|
payload,
|
||||||
: [];
|
options,
|
||||||
if (options?.requireDmgCaseId !== false && !payload.DmgCaseId)
|
);
|
||||||
warnings.push("DmgCaseId is required.");
|
const allWarnings = Array.from(new Set([...warnings, ...readyWarnings]));
|
||||||
if (options?.requireThirdPartyLookups !== false) {
|
if (allWarnings.length) {
|
||||||
if (!payload.InspectionPlaceId)
|
|
||||||
warnings.push("InspectionPlaceId is required.");
|
|
||||||
if (!payload.DropAmountStatus)
|
|
||||||
warnings.push("DropAmountStatus is required.");
|
|
||||||
}
|
|
||||||
if (!payload.InspectionPlaceId)
|
|
||||||
warnings.push("InspectionPlaceId is required.");
|
|
||||||
if (!payload.DropAmountStatus)
|
|
||||||
warnings.push("DropAmountStatus is required.");
|
|
||||||
if (!sections.length)
|
|
||||||
warnings.push("At least one DmgSections row is required.");
|
|
||||||
for (const [index, section] of sections.entries()) {
|
|
||||||
const row = section as Record<string, unknown>;
|
|
||||||
if (!row.DmgSectionId) {
|
|
||||||
warnings.push(`DmgSections[${index}].DmgSectionId is required.`);
|
|
||||||
}
|
|
||||||
if (!row.AccidentLevel) {
|
|
||||||
warnings.push(`DmgSections[${index}].AccidentLevel is required.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (warnings.length) {
|
|
||||||
throw new BadRequestException({
|
throw new BadRequestException({
|
||||||
message: "Fanavaran expertise payload is not ready.",
|
message: "Fanavaran expertise payload is not ready.",
|
||||||
warnings: Array.from(new Set(warnings)),
|
warnings: allWarnings,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { PartyRole } from "src/request-management/entities/schema/partyRole.enum";
|
import { PartyRole } from "src/request-management/entities/schema/partyRole.enum";
|
||||||
import {
|
import {
|
||||||
|
hullExpertiseAssertFields,
|
||||||
|
collectFanavaranExpertiseReadinessWarnings,
|
||||||
pickHullVehicleIdentity,
|
pickHullVehicleIdentity,
|
||||||
toFanavaranHullExpertiseDmgSection,
|
toFanavaranHullExpertiseDmgSection,
|
||||||
toFanavaranHullExpertisePayload,
|
toFanavaranHullExpertisePayload,
|
||||||
@@ -95,4 +97,60 @@ describe("fanavaran hull expertise", () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not require ثالث expertise fields on a GEN.06 hull payload", () => {
|
||||||
|
const payload = toFanavaranHullExpertisePayload({
|
||||||
|
claimExpertId: 29,
|
||||||
|
dmgAssessmentDate: "1405/06/24",
|
||||||
|
inspectionTime: "10:41",
|
||||||
|
wage: 6000000,
|
||||||
|
componentReplacementCost: 10000000,
|
||||||
|
wasteValue: 0,
|
||||||
|
dropAmount: 10000,
|
||||||
|
vehicleCurrentValue: null,
|
||||||
|
vehicle: {
|
||||||
|
motorNo: "13389030167",
|
||||||
|
chassisNo: "NAAP41FD5BJ301065",
|
||||||
|
vin: "IRFC891V7D2301065",
|
||||||
|
plaqueNo: "56د394",
|
||||||
|
plaqueSerial: "66",
|
||||||
|
builtYear: 1389,
|
||||||
|
},
|
||||||
|
dmgSections: [
|
||||||
|
toFanavaranHullExpertiseDmgSection({
|
||||||
|
partId: 9,
|
||||||
|
desc: "سپر جلو",
|
||||||
|
wasteValue: 0,
|
||||||
|
amount: 11000000,
|
||||||
|
}),
|
||||||
|
toFanavaranHullExpertiseDmgSection({
|
||||||
|
partId: 11,
|
||||||
|
desc: "آينه سمت راننده",
|
||||||
|
wasteValue: 0,
|
||||||
|
amount: 5000000,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
collectFanavaranExpertiseReadinessWarnings(
|
||||||
|
payload,
|
||||||
|
hullExpertiseAssertFields("car-body"),
|
||||||
|
),
|
||||||
|
).toEqual([]);
|
||||||
|
expect(
|
||||||
|
collectFanavaranExpertiseReadinessWarnings(
|
||||||
|
payload,
|
||||||
|
hullExpertiseAssertFields("third-party"),
|
||||||
|
),
|
||||||
|
).toEqual([
|
||||||
|
"DmgCaseId is required.",
|
||||||
|
"InspectionPlaceId is required.",
|
||||||
|
"DropAmountStatus is required.",
|
||||||
|
"DmgSections[0].DmgSectionId is required.",
|
||||||
|
"DmgSections[0].AccidentLevel is required.",
|
||||||
|
"DmgSections[1].DmgSectionId is required.",
|
||||||
|
"DmgSections[1].AccidentLevel is required.",
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -122,3 +122,39 @@ export function hullExpertiseAssertFields(
|
|||||||
}
|
}
|
||||||
return { requireDmgCaseId: true, requireThirdPartyLookups: true };
|
return { requireDmgCaseId: true, requireThirdPartyLookups: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function collectFanavaranExpertiseReadinessWarnings(
|
||||||
|
payload: Record<string, unknown>,
|
||||||
|
options?: { requireDmgCaseId?: boolean; requireThirdPartyLookups?: boolean },
|
||||||
|
): string[] {
|
||||||
|
const warnings: string[] = [];
|
||||||
|
const sections = Array.isArray(payload.DmgSections)
|
||||||
|
? payload.DmgSections
|
||||||
|
: [];
|
||||||
|
const thirdPartyLookups = options?.requireThirdPartyLookups !== false;
|
||||||
|
if (options?.requireDmgCaseId !== false && !payload.DmgCaseId) {
|
||||||
|
warnings.push("DmgCaseId is required.");
|
||||||
|
}
|
||||||
|
if (thirdPartyLookups) {
|
||||||
|
if (!payload.InspectionPlaceId) {
|
||||||
|
warnings.push("InspectionPlaceId is required.");
|
||||||
|
}
|
||||||
|
if (!payload.DropAmountStatus) {
|
||||||
|
warnings.push("DropAmountStatus is required.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!sections.length) {
|
||||||
|
warnings.push("At least one DmgSections row is required.");
|
||||||
|
}
|
||||||
|
for (const [index, section] of sections.entries()) {
|
||||||
|
const row = section as Record<string, unknown>;
|
||||||
|
if (!thirdPartyLookups) continue;
|
||||||
|
if (!row.DmgSectionId) {
|
||||||
|
warnings.push(`DmgSections[${index}].DmgSectionId is required.`);
|
||||||
|
}
|
||||||
|
if (!row.AccidentLevel) {
|
||||||
|
warnings.push(`DmgSections[${index}].AccidentLevel is required.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Array.from(new Set(warnings));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user