forked from Yara724/api
Fix v5 + Fix ToDate field for damaged parts
This commit is contained in:
@@ -18,6 +18,7 @@ import { basename, resolve } from "node:path";
|
||||
import FormData = require("form-data");
|
||||
import { AiService } from "src/ai/ai.service";
|
||||
import { buildFileLink, resolveStoredFileUrl } from "src/helpers/urlCreator";
|
||||
import { jalaliToGregorianDate } from "src/helpers/date-jalali";
|
||||
import { RequestManagementDbService } from "src/request-management/entities/db-service/request-management.db.service";
|
||||
import { ReqBlameStatus } from "src/Types&Enums/blame-request-management/status.enum";
|
||||
import { ReqClaimStatus } from "src/Types&Enums/claim-request-management/status.enum";
|
||||
@@ -577,6 +578,8 @@ export class ClaimRequestManagementService {
|
||||
async getOuterPartsCatalogV2(): Promise<OuterPartCatalogItemDto[]> {
|
||||
const clientKey = resolveFanavaranClientKey();
|
||||
const rows = await this.getFanavaranLookupRows(clientKey, "car-components");
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
return rows
|
||||
.filter(
|
||||
(r): r is { Id: number; Caption: string } =>
|
||||
@@ -585,6 +588,13 @@ export class ClaimRequestManagementService {
|
||||
typeof (r as any).Id === "number" &&
|
||||
typeof (r as any).Caption === "string",
|
||||
)
|
||||
.filter((r) => {
|
||||
const toDate = (r as any).ToDate;
|
||||
if (!toDate) return true;
|
||||
const gregorian = jalaliToGregorianDate(String(toDate));
|
||||
if (!gregorian) return true;
|
||||
return new Date(gregorian) >= today;
|
||||
})
|
||||
.map((r) => ({ id: r.Id, label_fa: r.Caption }));
|
||||
}
|
||||
|
||||
|
||||
@@ -11081,6 +11081,9 @@ export class RequestManagementService {
|
||||
: { ...(req as any) };
|
||||
// Attach linked claim ID if present
|
||||
const claim = await this.claimCaseDbService.findOne({ blameRequestId: (req as any)._id });
|
||||
const claimPlain = claim && typeof (claim as any).toObject === "function"
|
||||
? (claim as any).toObject({ versionKey: false })
|
||||
: claim ? { ...(claim as any) } : null;
|
||||
return {
|
||||
_id: plain._id,
|
||||
publicId: plain.publicId,
|
||||
@@ -11115,7 +11118,19 @@ export class RequestManagementService {
|
||||
inquiryComplete: !!(p.person?.inquiriesCompleted),
|
||||
hasSigned: p.confirmation != null,
|
||||
})),
|
||||
linkedClaimId: claim ? String((claim as any)._id) : null,
|
||||
linkedClaimId: claimPlain ? String(claimPlain._id) : null,
|
||||
...(claimPlain ? {
|
||||
claimStatus: claimPlain.status,
|
||||
claimWorkflow: claimPlain.workflow,
|
||||
fileMakerRejectionCount: claimPlain.fileMakerRejectionCount ?? 0,
|
||||
fileMakerRejectionReason: claimPlain.fileMakerRejectionReason ?? null,
|
||||
evaluation: claimPlain.evaluation
|
||||
? {
|
||||
damageExpertReply: claimPlain.evaluation.damageExpertReply ?? null,
|
||||
damageExpertReplyFinal: claimPlain.evaluation.damageExpertReplyFinal ?? null,
|
||||
}
|
||||
: null,
|
||||
} : {}),
|
||||
createdAt: plain.createdAt,
|
||||
updatedAt: plain.updatedAt,
|
||||
};
|
||||
@@ -11169,6 +11184,9 @@ export class RequestManagementService {
|
||||
? (req as any).toObject({ versionKey: false })
|
||||
: { ...(req as any) };
|
||||
const claim = await this.claimCaseDbService.findOne({ blameRequestId: (req as any)._id });
|
||||
const claimPlain = claim && typeof (claim as any).toObject === "function"
|
||||
? (claim as any).toObject({ versionKey: false })
|
||||
: claim ? { ...(claim as any) } : null;
|
||||
return {
|
||||
_id: plain._id,
|
||||
publicId: plain.publicId,
|
||||
@@ -11216,7 +11234,19 @@ export class RequestManagementService {
|
||||
} : undefined,
|
||||
accidentFields: plain.expert.accidentFields,
|
||||
} : undefined,
|
||||
linkedClaimId: claim ? String((claim as any)._id) : null,
|
||||
linkedClaimId: claimPlain ? String(claimPlain._id) : null,
|
||||
...(claimPlain ? {
|
||||
claimStatus: claimPlain.status,
|
||||
claimWorkflow: claimPlain.workflow,
|
||||
fileMakerRejectionCount: claimPlain.fileMakerRejectionCount ?? 0,
|
||||
fileMakerRejectionReason: claimPlain.fileMakerRejectionReason ?? null,
|
||||
evaluation: claimPlain.evaluation
|
||||
? {
|
||||
damageExpertReply: claimPlain.evaluation.damageExpertReply ?? null,
|
||||
damageExpertReplyFinal: claimPlain.evaluation.damageExpertReplyFinal ?? null,
|
||||
}
|
||||
: null,
|
||||
} : {}),
|
||||
createdAt: plain.createdAt,
|
||||
updatedAt: plain.updatedAt,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user