fix(car-body): validate policy coverage on accident date

Validate hull coverage against the accident date, select the covering renewal, and defer validation until that date is collected.
This commit is contained in:
2026-11-21 12:04:09 +03:30
parent 8f15040080
commit 5c6e21dd14
13 changed files with 499 additions and 56 deletions
@@ -312,7 +312,10 @@ import {
resolvePolicyholderFromParty,
resolveThirdPartyCulpritTypeId,
} from './fanavaran-party-roles';
import { selectLatestActiveFanavaranPolicy } from './fanavaran-policy-selection';
import {
selectLatestActiveFanavaranPolicy,
selectFanavaranPolicyForAccident,
} from './fanavaran-policy-selection';
export interface FanavaranAutoSubmitResult {
attempted: boolean;
@@ -3959,6 +3962,7 @@ export class ClaimRequestManagementService {
claimCaseId?: string;
product?: FanavaranClaimProduct;
insuranceLineId?: number;
accidentDate?: Date | string;
},
): Promise<number | null> {
const clientKey =
@@ -4024,7 +4028,10 @@ export class ClaimRequestManagementService {
this.logger.log(
`${logPrefix} Policy inquiry response status=${response.status} count=${policyCount}`,
);
const selectedPolicy = selectLatestActiveFanavaranPolicy(response.data);
const selectedPolicy =
product === 'car-body'
? selectFanavaranPolicyForAccident(response.data, options?.accidentDate)
: selectLatestActiveFanavaranPolicy(response.data);
this.logger.log(
`${logPrefix} Selected latest active policy PolicyId=${selectedPolicy.policyId} EndDate=${selectedPolicy.endDate}`,
);
@@ -4719,7 +4726,12 @@ export class ClaimRequestManagementService {
profile.auth,
logPrefix,
auditSession,
{ clientKey, claimCaseId, product: 'car-body' },
{
clientKey,
claimCaseId,
product: 'car-body',
accidentDate: firstParty?.statement?.accidentDate,
},
);
debug.values.policyId = policyId;
debug.steps.policyInquirySucceeded = policyId !== null;