forked from Yara724/api
fix: harden claim review and inquiry workflows
Preserve damage history and current vehicle price, restore depreciation mapping, normalize inquiry/report output, and support resumable expert review with paginated case retrieval.
This commit is contained in:
@@ -101,7 +101,12 @@ import {
|
||||
ClaimListItemV2Dto,
|
||||
} from "./dto/my-claims-v2.dto";
|
||||
import { ListQueryV2Dto } from "src/common/dto/list-query-v2.dto";
|
||||
import { applyListQueryV2 } from "src/helpers/list-query-v2";
|
||||
import {
|
||||
applyListQueryV2,
|
||||
isInListDateRange,
|
||||
parseListDateRange,
|
||||
} from "src/helpers/list-query-v2";
|
||||
import { resolveUnifiedFileStatus } from "src/helpers/unified-file-status";
|
||||
import { partyPersonMatchesUser } from "src/helpers/iran-mobile";
|
||||
import {
|
||||
buildBlamePartyAccessOrConditions,
|
||||
@@ -206,6 +211,7 @@ import {
|
||||
partLookupKey,
|
||||
resolvePartCaptureIndex,
|
||||
} from "src/helpers/outer-damage-parts";
|
||||
import { serializeDamagedPartSelectionHistory } from "src/helpers/claim-damaged-part-audit";
|
||||
import { normalizeMoneyAmountString } from "src/utils/unicode-digits";
|
||||
import { PlateNormalizerService } from "src/utils/plate-normalizer/plate-normalizer.service";
|
||||
|
||||
@@ -12421,7 +12427,7 @@ export class ClaimRequestManagementService {
|
||||
blameIdsForList.length > 0
|
||||
? ((await this.blameRequestDbService.find(
|
||||
{ _id: { $in: blameIdsForList.map((id) => new Types.ObjectId(id)) } },
|
||||
{ lean: true, select: "type creationMethod" },
|
||||
{ lean: true, select: "type creationMethod status" },
|
||||
)) as any[])
|
||||
: [];
|
||||
const blameByIdForList = new Map<string, any>(
|
||||
@@ -12443,16 +12449,37 @@ export class ClaimRequestManagementService {
|
||||
blameRequestId: c.blameRequestId?.toString(),
|
||||
blameType: blameForItem?.type ?? undefined,
|
||||
creationMethod: blameForItem?.creationMethod ?? undefined,
|
||||
unifiedFileStatus: resolveUnifiedFileStatus({
|
||||
blameStatus: blameForItem?.status,
|
||||
claimStatus: c.status,
|
||||
}),
|
||||
};
|
||||
}) as ClaimListItemV2Dto[];
|
||||
|
||||
let filtered = list;
|
||||
if (query.unifiedStatus) {
|
||||
filtered = filtered.filter(
|
||||
(row) => row.unifiedFileStatus === query.unifiedStatus,
|
||||
);
|
||||
}
|
||||
const { fromDate, toDate } = parseListDateRange(
|
||||
query.startDate,
|
||||
query.endDate,
|
||||
);
|
||||
if (fromDate || toDate) {
|
||||
filtered = filtered.filter((row) =>
|
||||
isInListDateRange(row.createdAt, fromDate, toDate),
|
||||
);
|
||||
}
|
||||
|
||||
const paged = applyListQueryV2(
|
||||
list,
|
||||
filtered,
|
||||
{
|
||||
publicId: (r) => r.publicId,
|
||||
createdAt: (r) => r.createdAt,
|
||||
requestNo: (r) => r.requestNo,
|
||||
status: (r) => r.status,
|
||||
status: (r) => r.unifiedFileStatus ?? r.status,
|
||||
fileType: (r) => r.blameType,
|
||||
searchExtras: (r) =>
|
||||
[
|
||||
r.claimRequestId,
|
||||
@@ -12588,6 +12615,10 @@ export class ClaimRequestManagementService {
|
||||
catalogLikeKeyFromPart,
|
||||
buildFileLink,
|
||||
});
|
||||
const damagedPartsHistory = serializeDamagedPartSelectionHistory({
|
||||
history: (claim.damage as any)?.partSelectionHistory,
|
||||
currentSelectedParts: selectedNormDetails,
|
||||
});
|
||||
|
||||
const er = claim.evaluation?.damageExpertResend;
|
||||
const expertResend =
|
||||
@@ -12671,6 +12702,7 @@ export class ClaimRequestManagementService {
|
||||
: undefined,
|
||||
carAngles,
|
||||
damagedParts,
|
||||
damagedPartsHistory,
|
||||
expertResend,
|
||||
fanavaran: fanavaranClaimReferences(claim),
|
||||
evaluation: mappedEvaluation
|
||||
|
||||
Reference in New Issue
Block a user