forked from Yara724/api
pppppp
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -8,7 +8,7 @@ export const MUTUAL_AGREEMENT_EXPERT_DECISION_FIELDS = {
|
||||
accidentWay: { id: 8, label: "جلو به عقب" },
|
||||
accidentReason: {
|
||||
id: 1,
|
||||
fanavaran: 1,
|
||||
fanavaran: 6,
|
||||
label:
|
||||
"عدم رعايت فاصله مناسب با وسيله نقليه و يا عدم توجه به جلو",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user