forked from Yara724/api
Merge pull request 'main' (#155) from s.hajizadeh/yara724api:main into main
Reviewed-on: Yara724/api#155
This commit is contained in:
@@ -189,6 +189,7 @@ export interface FanavaranAutoSubmitResult {
|
||||
}
|
||||
|
||||
const FANAVARAN_ACCIDENT_LOCATION_ADDRESS = "استان تهران شهر تهران";
|
||||
const FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID = 6;
|
||||
|
||||
@Injectable()
|
||||
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 {
|
||||
result.ActualPremium = null;
|
||||
result.ArchiveNo = null;
|
||||
@@ -3431,14 +3415,10 @@ export class ClaimRequestManagementService {
|
||||
input.defaults ?? this.TEJARATNO_FANAVARAN_DEFAULTS;
|
||||
const result: Record<string, unknown> = {
|
||||
...lookupDefaults,
|
||||
AccidentCauseId: this.resolveAccidentCauseId(input.accidentReason),
|
||||
AccidentCauseId: FANAVARAN_DEFAULT_ACCIDENT_CAUSE_ID,
|
||||
};
|
||||
|
||||
if (input.accidentReason && result.AccidentCauseId === null) {
|
||||
this.logger.warn(
|
||||
`${input.logPrefix} accidentReason exists but fanavaran is null or undefined`,
|
||||
);
|
||||
} else if (!input.accidentReason) {
|
||||
if (!input.accidentReason) {
|
||||
this.logger.error(
|
||||
`${input.logPrefix} expert decision / accidentReason is missing`,
|
||||
);
|
||||
@@ -3544,58 +3524,16 @@ export class ClaimRequestManagementService {
|
||||
CompensationReferenceId: 167,
|
||||
CulpritLicenceTypeId: 2,
|
||||
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 fanavaran is 0, use id instead. First check if expertSubmitReplyFinal exists, if not check expertSubmitReply
|
||||
if (blameRequest.expertSubmitReplyFinal) {
|
||||
// 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 {
|
||||
if (
|
||||
!blameRequest.expertSubmitReplyFinal &&
|
||||
!blameRequest.expertSubmitReply
|
||||
) {
|
||||
this.logger.error(
|
||||
`[Fanavaran Submit] Both expertSubmitReplyFinal and expertSubmitReply are null/undefined`,
|
||||
);
|
||||
result.AccidentCauseId = null;
|
||||
}
|
||||
|
||||
// AccidentDate: Convert createdAt to Persian date
|
||||
|
||||
Reference in New Issue
Block a user