culprit licence bug fixed , and handled some default values

This commit is contained in:
2026-11-12 11:23:40 +03:30
parent 8b9dabc9f2
commit e215dbdc03
12 changed files with 353 additions and 21 deletions
@@ -1,5 +1,6 @@
import type { FanavaranClientKey } from "src/core/config/fanavaran-client.config";
import { TEJARAT_NOTIFIER_FIELDS } from "src/fanavaran/tejarat-notifier";
import { resolveFanavaranIsLicenseReplaced } from "./fanavaran-party-roles";
/** GEN.03 VHUD input fields. Do not send ثالث-only keys (DamagedCount, HasOtherCulprit, plaques, …). */
export const FANAVARAN_HULL_BASE_CLAIM_KEYS = [
@@ -50,7 +51,7 @@ export const FANAVARAN_HULL_BASE_CLAIM_KEYS = [
/** Select the current API row for the default collision scenario. */
export const FANAVARAN_HULL_ACCIDENT_TYPE_CAPTION = "تصادف(حادثه)";
/** GEN.03 ans (0=خیر). Used for CostSeparationToDmgSections, IsOwnerChanged, IsLicenseReplaced. */
/** GEN.03 ans (0=خیر). Used for CostSeparationToDmgSections, IsOwnerChanged. */
export const FANAVARAN_HULL_ANS_NO = 0;
export const FANAVARAN_HULL_CULPRIT_TYPE_CAPTION = "بيمه گذار";
@@ -124,8 +125,18 @@ export function toFanavaranHullBaseClaimPayload(
const next: Record<string, unknown> = {};
for (const key of FANAVARAN_HULL_BASE_CLAIM_KEYS) {
if (key === "IsLicenseReplaced") {
// Hull GEN.03: explicitly send خیر. Keep the hull field name.
next[key] = FANAVARAN_HULL_ANS_NO;
// Fanavaran conditional: >10y since issue → 1; else null (never 0).
if (
Object.prototype.hasOwnProperty.call(built, key) &&
(built[key] === 1 || built[key] === null)
) {
next[key] = built[key];
} else {
next[key] = resolveFanavaranIsLicenseReplaced(
built.CulpritLicenceIssuDate,
built.AccidentDate,
);
}
continue;
}
if (key === "AccidentTypeId") {