forked from Yara724/api
updated the accident cause id to default value 6
This commit is contained in:
@@ -189,6 +189,7 @@ export interface FanavaranAutoSubmitResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FANAVARAN_ACCIDENT_LOCATION_ADDRESS = "استان تهران شهر تهران";
|
const FANAVARAN_ACCIDENT_LOCATION_ADDRESS = "استان تهران شهر تهران";
|
||||||
|
const FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID = 6;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ClaimRequestManagementService {
|
export class ClaimRequestManagementService {
|
||||||
@@ -3347,23 +3348,6 @@ export class ClaimRequestManagementService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveAccidentCauseId(accidentReason?: {
|
|
||||||
id?: string | number | null;
|
|
||||||
fanavaran?: number | null;
|
|
||||||
}): number | null {
|
|
||||||
const fanavaranValue = accidentReason?.fanavaran;
|
|
||||||
const idValue = accidentReason?.id;
|
|
||||||
|
|
||||||
if (fanavaranValue !== undefined && fanavaranValue !== null) {
|
|
||||||
if (fanavaranValue === 0) {
|
|
||||||
return idValue !== undefined && idValue !== null ? Number(idValue) : null;
|
|
||||||
}
|
|
||||||
return fanavaranValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private applyFanavaranDefaultFields(result: Record<string, unknown>): void {
|
private applyFanavaranDefaultFields(result: Record<string, unknown>): void {
|
||||||
result.ActualPremium = null;
|
result.ActualPremium = null;
|
||||||
result.ArchiveNo = null;
|
result.ArchiveNo = null;
|
||||||
@@ -3431,14 +3415,10 @@ export class ClaimRequestManagementService {
|
|||||||
input.defaults ?? this.TEJARATNO_FANAVARAN_DEFAULTS;
|
input.defaults ?? this.TEJARATNO_FANAVARAN_DEFAULTS;
|
||||||
const result: Record<string, unknown> = {
|
const result: Record<string, unknown> = {
|
||||||
...lookupDefaults,
|
...lookupDefaults,
|
||||||
AccidentCauseId: this.resolveAccidentCauseId(input.accidentReason),
|
AccidentCauseId: FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (input.accidentReason && result.AccidentCauseId === null) {
|
if (!input.accidentReason) {
|
||||||
this.logger.warn(
|
|
||||||
`${input.logPrefix} accidentReason exists but fanavaran is null or undefined`,
|
|
||||||
);
|
|
||||||
} else if (!input.accidentReason) {
|
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
`${input.logPrefix} expert decision / accidentReason is missing`,
|
`${input.logPrefix} expert decision / accidentReason is missing`,
|
||||||
);
|
);
|
||||||
@@ -3544,58 +3524,16 @@ export class ClaimRequestManagementService {
|
|||||||
CompensationReferenceId: 167,
|
CompensationReferenceId: 167,
|
||||||
CulpritLicenceTypeId: 2,
|
CulpritLicenceTypeId: 2,
|
||||||
CulpritTypeId: 337,
|
CulpritTypeId: 337,
|
||||||
AccidentCauseId: 6, // Initialize to null, will be set if found
|
AccidentCauseId: FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
// AccidentCauseId: from expertSubmitReplyFinal.fields.accidentReason.fanavaran
|
if (
|
||||||
// If fanavaran is 0, use id instead. First check if expertSubmitReplyFinal exists, if not check expertSubmitReply
|
!blameRequest.expertSubmitReplyFinal &&
|
||||||
if (blameRequest.expertSubmitReplyFinal) {
|
!blameRequest.expertSubmitReply
|
||||||
// expertSubmitReplyFinal exists, use it for AccidentCauseId
|
) {
|
||||||
const accidentReason =
|
|
||||||
blameRequest.expertSubmitReplyFinal?.fields?.accidentReason;
|
|
||||||
const fanavaranValue = accidentReason?.fanavaran;
|
|
||||||
const idValue = accidentReason?.id;
|
|
||||||
|
|
||||||
if (fanavaranValue !== undefined && fanavaranValue !== null) {
|
|
||||||
// If fanavaran is 0, use id instead
|
|
||||||
if (fanavaranValue === 0) {
|
|
||||||
result.AccidentCauseId =
|
|
||||||
idValue !== undefined && idValue !== null ? idValue : null;
|
|
||||||
} else {
|
|
||||||
result.AccidentCauseId = fanavaranValue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.warn(
|
|
||||||
`[Fanavaran Submit] expertSubmitReplyFinal exists but fanavaran is null or undefined`,
|
|
||||||
);
|
|
||||||
result.AccidentCauseId = null;
|
|
||||||
}
|
|
||||||
} else if (blameRequest.expertSubmitReply) {
|
|
||||||
// expertSubmitReplyFinal is null, use expertSubmitReply
|
|
||||||
const accidentReason =
|
|
||||||
blameRequest.expertSubmitReply?.fields?.accidentReason;
|
|
||||||
const fanavaranValue = accidentReason?.fanavaran;
|
|
||||||
const idValue = accidentReason?.id;
|
|
||||||
|
|
||||||
if (fanavaranValue !== undefined && fanavaranValue !== null) {
|
|
||||||
// If fanavaran is 0, use id instead
|
|
||||||
if (fanavaranValue === 0) {
|
|
||||||
result.AccidentCauseId =
|
|
||||||
idValue !== undefined && idValue !== null ? idValue : null;
|
|
||||||
} else {
|
|
||||||
result.AccidentCauseId = fanavaranValue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.warn(
|
|
||||||
`[Fanavaran Submit] expertSubmitReply exists but fanavaran is null or undefined`,
|
|
||||||
);
|
|
||||||
result.AccidentCauseId = null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
`[Fanavaran Submit] Both expertSubmitReplyFinal and expertSubmitReply are null/undefined`,
|
`[Fanavaran Submit] Both expertSubmitReplyFinal and expertSubmitReply are null/undefined`,
|
||||||
);
|
);
|
||||||
result.AccidentCauseId = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccidentDate: Convert createdAt to Persian date
|
// AccidentDate: Convert createdAt to Persian date
|
||||||
|
|||||||
Reference in New Issue
Block a user