From ee40b3e811eb90440c2efdd7340d900f0b1871f6 Mon Sep 17 00:00:00 2001 From: "s.hajizadeh" Date: Thu, 12 Nov 2026 18:50:18 +0330 Subject: [PATCH] pppppp --- .../fanavaran-hull-base-claim.ts | 2 +- .../fanavaran-party-roles.ts | 47 ++++++++++++++----- src/helpers/blame-party-agreement-decision.ts | 2 +- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/claim-request-management/fanavaran-hull-base-claim.ts b/src/claim-request-management/fanavaran-hull-base-claim.ts index a75f2c9..1e7db69 100644 --- a/src/claim-request-management/fanavaran-hull-base-claim.ts +++ b/src/claim-request-management/fanavaran-hull-base-claim.ts @@ -128,7 +128,7 @@ export function toFanavaranHullBaseClaimPayload( // Fanavaran conditional: >10y since issue → 1; else null (never 0). if ( 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]; } else { diff --git a/src/claim-request-management/fanavaran-party-roles.ts b/src/claim-request-management/fanavaran-party-roles.ts index c7682cd..0c001d2 100644 --- a/src/claim-request-management/fanavaran-party-roles.ts +++ b/src/claim-request-management/fanavaran-party-roles.ts @@ -9,13 +9,20 @@ import type { FanavaranClaimProduct } from "./fanavaran-claim-product"; /** * 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). */ 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). * Used for Fanavaran IsLicenseReplaced / IsLicenseReplacement. @@ -40,20 +47,36 @@ export function isJalaliDateOlderThanYears( /** * Hull `IsLicenseReplaced` / ثالث `IsLicenseReplacement`: - * - licence issue more than 10 years before accident → `1` - * - otherwise → `null` (never send `0`) + * - licence issued more than 10 years before accident → `1` (replaced) + * - 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( licenceIssuDate: unknown, accidentDate: unknown, -): 1 | null { - return isJalaliDateOlderThanYears( - licenceIssuDate, - accidentDate, - FANAVARAN_LICENCE_REPLACED_AFTER_YEARS, - ) - ? 1 - : null; +): 1 | 0 | null { + if ( + isJalaliDateOlderThanYears( + licenceIssuDate, + accidentDate, + FANAVARAN_LICENCE_REPLACED_AFTER_YEARS, + ) + ) { + 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 = { diff --git a/src/helpers/blame-party-agreement-decision.ts b/src/helpers/blame-party-agreement-decision.ts index daaa007..7844852 100644 --- a/src/helpers/blame-party-agreement-decision.ts +++ b/src/helpers/blame-party-agreement-decision.ts @@ -8,7 +8,7 @@ export const MUTUAL_AGREEMENT_EXPERT_DECISION_FIELDS = { accidentWay: { id: 8, label: "جلو به عقب" }, accidentReason: { id: 1, - fanavaran: 1, + fanavaran: 6, label: "عدم رعايت فاصله مناسب با وسيله نقليه و يا عدم توجه به جلو", },