This commit is contained in:
2026-11-12 18:50:18 +03:30
parent 9178058173
commit ee40b3e811
3 changed files with 37 additions and 14 deletions
@@ -128,7 +128,7 @@ export function toFanavaranHullBaseClaimPayload(
// Fanavaran conditional: >10y since issue → 1; else null (never 0). // Fanavaran conditional: >10y since issue → 1; else null (never 0).
if ( if (
Object.prototype.hasOwnProperty.call(built, key) && Object.prototype.hasOwnProperty.call(built, key) &&
(built[key] === 1 || built[key] === null) (built[key] === 1 || built[key] === 0 || built[key] === null)
) { ) {
next[key] = built[key]; next[key] = built[key];
} else { } else {
@@ -9,13 +9,20 @@ import type { FanavaranClaimProduct } from "./fanavaran-claim-product";
/** /**
* Fanavaran dummy licence issue date when `person.driverLicenseDate` is missing. * Fanavaran dummy licence issue date when `person.driverLicenseDate` is missing.
* Kept recent so hull `IsLicenseReplaced` stays null (see 10-year rule). * Set well in the past (> 3 years) so the new IsLicenseReplaced logic does not
* force an explicit 0 answer for a missing date, and < 10 years so it stays null.
*/ */
export const FANAVARAN_DUMMY_LICENCE_ISSU_DATE = "1404/08/20"; export const FANAVARAN_DUMMY_LICENCE_ISSU_DATE = "1400/01/01";
/** Years since issue after which hull/third-party "licence replaced?" becomes yes (1). */ /** Years since issue after which hull/third-party "licence replaced?" becomes yes (1). */
export const FANAVARAN_LICENCE_REPLACED_AFTER_YEARS = 10; export const FANAVARAN_LICENCE_REPLACED_AFTER_YEARS = 10;
/**
* Years since issue below which Fanavaran requires an explicit 0/1 answer
* for IsLicenseReplaced (rule: GovahiTamdidiMustBeRequiredWhenGovahiSodurDateYearIsLessThreeRule).
*/
export const FANAVARAN_LICENCE_REPLACED_REQUIRED_WITHIN_YEARS = 3;
/** /**
* True when `issueDate` is more than `years` before `referenceDate` (Jalali). * True when `issueDate` is more than `years` before `referenceDate` (Jalali).
* Used for Fanavaran IsLicenseReplaced / IsLicenseReplacement. * Used for Fanavaran IsLicenseReplaced / IsLicenseReplacement.
@@ -40,20 +47,36 @@ export function isJalaliDateOlderThanYears(
/** /**
* Hull `IsLicenseReplaced` / ثالث `IsLicenseReplacement`: * Hull `IsLicenseReplaced` / ثالث `IsLicenseReplacement`:
* - licence issue more than 10 years before accident → `1` * - licence issued more than 10 years before accident → `1` (replaced)
* - otherwise → `null` (never send `0`) * - licence issued less than 3 years before accident → `0` (not replaced, but
* Fanavaran rule GovahiTamdidiMustBeRequiredWhenGovahiSodurDateYearIsLessThreeRule
* requires an explicit answer, never null)
* - 3–10 years → `null` (field is optional in this range)
*/ */
export function resolveFanavaranIsLicenseReplaced( export function resolveFanavaranIsLicenseReplaced(
licenceIssuDate: unknown, licenceIssuDate: unknown,
accidentDate: unknown, accidentDate: unknown,
): 1 | null { ): 1 | 0 | null {
return isJalaliDateOlderThanYears( if (
licenceIssuDate, isJalaliDateOlderThanYears(
accidentDate, licenceIssuDate,
FANAVARAN_LICENCE_REPLACED_AFTER_YEARS, accidentDate,
) FANAVARAN_LICENCE_REPLACED_AFTER_YEARS,
? 1 )
: null; ) {
return 1;
}
// Newer than 3 years: Fanavaran requires explicit 0.
if (
!isJalaliDateOlderThanYears(
licenceIssuDate,
accidentDate,
FANAVARAN_LICENCE_REPLACED_REQUIRED_WITHIN_YEARS,
)
) {
return 0;
}
return null;
} }
export type FanavaranRoleIdentity = { export type FanavaranRoleIdentity = {
@@ -8,7 +8,7 @@ export const MUTUAL_AGREEMENT_EXPERT_DECISION_FIELDS = {
accidentWay: { id: 8, label: "جلو به عقب" }, accidentWay: { id: 8, label: "جلو به عقب" },
accidentReason: { accidentReason: {
id: 1, id: 1,
fanavaran: 1, fanavaran: 6,
label: label:
"عدم رعايت فاصله مناسب با وسيله نقليه و يا عدم توجه به جلو", "عدم رعايت فاصله مناسب با وسيله نقليه و يا عدم توجه به جلو",
}, },