Require the damaged party in user flows to select an active insurer branch and preserve branch access rules. Accept older licence issue dates, correct anniversary boundaries, and update Fanavaran audit documentation and regression coverage.
**IsLicenseReplaced:**`1` when`CulpritLicenceIssuDate`is more than 10 years before `AccidentDate`; otherwise `null` (never send `0`). Dummy issue date when missing: `1404/08/20`.
**IsLicenseReplaced:**derived on the server from`CulpritLicenceIssuDate`and
`AccidentDate`: `0` through the third anniversary, `null` after three years
through the tenth anniversary, and `1` after ten years. Intake accepts valid past
issue dates older than ten years; no expiry-date or replacement-checkbox input
is required. The existing missing-date fallback is `1400/01/01`.
| Field | Persian | Type | Null? | Current value / source |
# Fanavaran hardcoded outbound values — current audit
Date: **2026-11-11**. Remote baseline: API `90bdc51` on `origin/main`, with the
existing local branch-routing work restored. This is a source audit of possible
outbound values, not a capture of production requests. Mongo configuration can
override seed defaults, so the numbers below are code defaults, not a claim about
what is configured on a particular production server.
**The requirement “never send guessed/default business codes” is not satisfied.**
The staff-location fix is present, and recent hull changes removed several
numeric fallbacks, but other defaults can still reach Fanavaran. Merely checking
that a default ID exists in a lookup does not establish that it describes this
accident, driver, vehicle, or assessment.
This document updates the outbound-default findings in
[lookup-coding-audit.md](./lookup-coding-audit.md), which predates the latest hull
and location changes. This audit changes documentation only.
## Audited paths
| Area | Sources and responsibility |
|---|---|
| Application write entry points | `src/fanavaran/fanavaran.controller.ts`: base claim, damage case, attachments, expertise preview/submit; automatic and soft-ensure stage calls in `ClaimRequestManagementService` use the same builders |
| Payloads and HTTP writes | `src/claim-request-management/claim-request-management.service.ts`: GEN.03, GEN.12, GEN.44, GEN.07, third-party GEN.08, hull base PUT and GEN.06 |
| Configuration and headers | `src/core/config/fanavaran-client.config.ts`, `src/fanavaran/fanavaran-{client-config,auth,location}.service.ts`, config schema, system settings |
| Lookup/inquiry and local catalogues | `src/fanavaran/fanavaran-lookup.service.ts`, `fanavaran-lookup.config.ts`, `src/lookups/`, `src/static/outer-car-parts-catalog.ts`, part helpers, vehicle/stage review code |
| Expert and user UI | Expert Fanavaran API route, vehicle review, stage-field defaults, damage reply fields; user inquiry/part-selection consumers. No matching numeric payload defaults were found in the current UI source search; the expert UI does accept backend-prefilled defaults. |
| Standalone tools | `scripts/fanavaran-flow-ui-server.js`, `scripts/data/fanavaran-flow-ui.html`, `scripts/fanavaran-flow-test.sh`, `scripts/fanavaran-auth.sh`, `scripts/get-fanavaran-car-parts.sh`; report-seeding fixtures were distinguished from application writes |
The runtime tenant type supports `parsian`, `tejaratno`, and `moallem`.
`esg/src` had no direct Fanavaran references in the search. `rewrite` was excluded.
## 1. Business IDs that can still be sent from defaults
Line references are against the restored worktree at audit time. `service` means
| Field / stage | Hardcoded or seeded value | When it reaches the payload | Evidence / required source |
|---|---|---|---|
| `AccidentCauseId` — base, both products | **6** | Always initialized to 6. `accidentReason` is passed into the builder but its selected ID / `fanavaran` code is not applied. Hull checks membership, which can accept the wrong but active cause. | `service:405`, `1894`; use the actual selected cause mapped to this tenant. |
| `AccidentCityId` — base, both products | **701** | Profile default unless an expert stage review changes it. The shared builder does not resolve the supplied coordinates into a city. | Config `:100`; `service:1893`, `5691`; use accident-city selection/inquiry. |
| `CompensationReferenceId` — third-party base | **167** | Included from the profile; not among the current editable stage fields or manual-ID overrides. Hull's key whitelist removes it. | Config `:106`; `service:1893`; confirm the required contract/codebook and source. |
| `CulpritLicenceTypeId` — base, both products | **2** | Included from the profile. The resolved driver identity includes `licenseType`, but the payload does not use it. Hull checks whether 2 is active, not whether it is the driver's licence category. | Config `:107`; `service:4679` vicinity; map the actual stored driver's selection. |
| `CulpritTypeId` — third-party base | **337 / 338** | Final value comes from a static map: policyholder/driver same national code → 337, different → 338. Missing role information can default to 337. It is no longer simply the profile's 337. | `fanavaran-party-roles.ts:205–226`; `service:4687`; resolve current tenant IDs by confirmed role meaning and reject unknown roles. |
| `AccidentVehicleUsedId` — third-party base and damage | **1** | Fallback when inquiry/group resolution is unresolved; an expert's approved use type can override it. Hull base has removed this numeric fallback. | `service:4771`, `3208`; preserve the actual vehicle use or require a selection. |
| `DmgCaseTypeId` — third-party damage | **175** | Unconditionally taken from the profile. No current expert stage field for it. | `service:3235`; determine the actual damage-case classification. |
| `PlaqueKindId` / `PlaqueSampleId` — third-party damage | **8 / 10** | National-plate fallback when matched Fanavaran vehicle has no kind. Even with a real kind, a missing sample still falls back to 10 and is labelled `vehicle-inquiry`. | `src/lookups/fanavaran-last-car-policy.ts:391–392`, `450–470`; require sourced plate IDs with compatible kind/sample. |
| `PlaqueMiddleCodeId` — third-party damage | Static **1–24** letter map | Used when the matched vehicle does not provide a middle code. These are explicit fixed mappings rather than a default letter, but are still tenant-unverified numeric codes. | `service:424–449`, `3266`; map through the tenant's plate-letter catalogue. |
| `PoliceOfficerId` — third-party base | **1** | Assigned directly; hull explicitly replaces it with null. | `service:1857`; `fanavaran-hull-base-claim.ts:164`; real officer selection or null if permitted. |
| `InspectionPlaceId` — third-party expertise | **282** | Default unless reviewed. Fetching the inspection-place list does not select or validate this fallback at the write boundary. | `service:6014–6020`; explicit inspection place. |
| `DropAmountStatus` — third-party expertise | **5458** | Always assigned directly, even though `drop-amount-status` is fetched. Not a current editable stage field. | `service:6015–6020`; derive from confirmed depreciation outcome or require selection. |
| `DmgSections[].AccidentLevel` — third-party expertise | **5456** | Any nonnumeric `typeOfDamage` falls back to 5456. **The ordinary expert UI sends `تعمیر` / `تعویض`, so normal UI replies take this fallback.** Those values express repair/replacement, not damage severity. | `service:5888–5899`; expert `damagePartTable.tsx:2292–2305`, `claimReplySubmit.tsx:183–192`; add a separate severity field rather than treating repair method as severity. |
| `FileTypeId`, including `Files[].FileTypeId` — attachments | **Parsian 63 / Tejaratno 23 / Moallem 17** | One configured type is assigned across collected document/photo categories. Hull checks that the ID is active, not that its meaning matches each document. | Config `:155`, `181`, `201` vicinity; `service:5126`, `5329`, `5495–5497`; per-document semantic mapping to current tenant catalogue. |
| `CityId` — GEN.44 person creation | **9131** | Fallback if a person's explicit city and caption lookup cannot resolve it; shared helper has no tenant argument. This remains despite the **HTTP Location** fix. | `fanavaran-other-people.ts:95`, `251–254`; actual person city, never a Parsian city ID for another tenant. |
| `PersonKindId` — GEN.44 | **46** | Natural-person caption lookup fallback; shared across all clients. | `fanavaran-other-people.ts:96`, `265–268`; resolve correct person kind for the tenant/person. |
| `IsIranian` — GEN.44 | **1 / 0** | Fallback when `ans` lookup is unavailable. The helper assumes Iranian unless explicitly false or a naturalized code is present. | `fanavaran-other-people.ts:214–215`, `259–261`; encode confirmed nationality using the proper contract. |
`ClaimFileTypeId` also has a startup migration: Moallem's stored **23 → 17**
(`fanavaran-client-config.service.ts:40–45`). Editing a stored value back to 23
## 2. Default values that are not lookup IDs but still assert case facts
| Field | Current assumption | Source / consequence |
|---|---|---|
| `AccidentLocationAddress` | **`استان تهران شهر تهران`** | `service:404`, `1910`, `5690`. Location coordinates are accepted by the builder but not used here. Expert review/manual text can replace it. **This address default is separate from the fixed HTTP `Location` header.** |
| `CulpritLicenceNo`, damage `LicenceNo` | Environment dummy, else **`9705463515`** | `service:412–413`, `1812`, `1818`, `3250`, `7570`. Real licence preferred, but missing/empty values and even empty manual overrides are replaced by a fabricated number. |
| `CulpritLicenceIssuDate`, damage `LicenceIssuDate` | **`1394/10/13`** | `fanavaran-party-roles.ts:11`, `237–242`; shared builder also initializes it at `service:1835`. Real stored date wins if available. |
| `EstimateAmount` | **1000 rials** | `service:407`, `1770`, `3238`. Base uses it when no positive calculated estimate exists; damage builder always initializes to it, with manual amount override available. |
| `FaultPercent` — damage | **100** | Profile default, `service:3239`; does not derive an actual percentage. |
| `CustomerFaultPercent` — hull | **100** | `service:2642`, `fanavaran-hull-base-claim.ts:59`, `154–157`; expert stage review can replace it. |
| `RepairDuration` — hull expertise | **3 days** | `service:2844–2846`, `fanavaran-hull-expertise.ts:80`, `121–122`; review can replace it. Optional `HullExpertiseRepairDuration` exists in the profile interface but this builder does not use it. |
| `DamagedCount` — third-party base | **1** | `service:1838`. Current two-party flow has one beneficiary, but this is a fixed scenario assumption. |
| `IsLicenseMatchWithVehicleKind` | **1** | `service:1842`; no actual licence/category compatibility calculation here. |
| `HasOtherCulprit`, `IsAccidentOutOfBorder`, `IsFatalAccident`, `IsPlaqueChanged`, `IsLicenseReplacement` — third-party base | **0** | `service:1843–1848`, `1865`; assertions of “no”, not inferred accident facts. |
| `IsLicenseReplaced` — hull | **Always 0** | `fanavaran-hull-base-claim.ts:126–129`; forced even if the incoming builder value differs. Current code intentionally implements the previous contract decision. |
| `IsOwnerChanged`, `CostSeparationToDmgSections` — hull | **0 when absent** | `fanavaran-hull-base-claim.ts:135–142`. Encoded through `ans`, validated for membership on hull writes. |
| `Count` — hull damage section | **1** | `fanavaran-hull-expertise.ts:156`; one item per selected part row. Must be explicit if quantities can differ. |
| `ComponentReplacementTaxAndToll` — third-party expertise | **0** | `service:6051`; not computed from an expert-entered tax value. |
| Flow shell `:352–380` | Fixed tenant CorpId/ContractId and Location: Tejaratno **3539/263/100**, Parsian **543/28/210050**, Moallem **5650/304/30900**. Shell hull contract falls back to the configured third-party contract if a hull contract is not supplied. |
| Flow HTML `:1052–1092`, `:1316–1399` | Static expert/branch lists. Tejaratno auto-selects case-owner2721 and assessor2709 at location100; Moallem defaults to first case-owner5347 and assessor5350 at location30900; Parsian chooses branch210110 and the first listed maker32/reviewer3989 when no preference exists. Other static choices remain in these tables. |
| Flow HTML `:789–790`, `:1611–1619` | Static culprit337/338 mapping by role scenario. |
| Flow HTML `:851–853`, `:879–900` | Prefilled GEN.44 city9131/person-kind46/Iranian1, example amounts, repair3, fault100, example vehicle current value0. Also contains sample identity/plate/licence values; do not treat these as real inquiry evidence. |
| Flow server `:1168` | Party inquiry falls back to Location **100** if neither environment nor query supplies it. |
Before accepting the blame report/signature, the damaged party selects a city and an active branch of the insurer **paying** the claim. In third-party cases the payer is the guilty party's insurer, even if the damaged vehicle has another insurer. In car-body cases it is the first/only party's insurer. Both guilty-party positions and call-center cases are supported.
Expert/registrar/FileMaker-created flows retain their existing branch/ownership rules. The server determines applicability from the stored case flags, not a browser version parameter. Administrative insurer/super-admin oversight is unchanged.
## API
All routes below use existing user authentication and the user-role guard:
-`GET /v2/blame-request-management/:requestId/claim-branches`: authorize case access, resolve the beneficiary/payer, and return `{required, branchId, locked, branches}`. Only the beneficiary receives branch options. Each option contains `id`, `name`, `code`, `city`, `state`, `address`, and optional `phoneNumber`. Options are active branches from the payer only; the client cannot supply an insurer ID.
-`PUT /v2/blame-request-management/:requestId/claim-branch`: `{branchId}` saves a validated branch while waiting for signatures or after signing, before any claim exists. This supports historical cases that were already signed when the feature deployed. Other parties cannot select a branch. Existing claims freeze routing; this endpoint cannot move them to another branch.
- Existing `PUT /v2/blame-request-management/sign/:requestId` accepts an additional multipart `branchId`. When the damaged user accepts in a user-led flow, a valid branch is mandatory (either supplied now or previously saved). Branch validation occurs before creating the signature record. Confirmation and branch ID are saved in the same blame update. The guilty party signs normally without choosing a branch. Rejection does not require a branch.
Invalid IDs, inactive branches and branches from another insurer are rejected with Persian errors. The API checks the insurer relationship; UI filtering alone is insufficient. If there are no active branches, the user sees a support message and cannot confirm acceptance/create a new claim until the insurer provisions its branches.
`GET /v2/blame-request-management/:requestId` includes `claimBranch: {required, branchId}` for the current viewer.
## Claim creation and expert access
`createClaimFromBlameV2` revalidates the active branch and copies `blame.branchId` to `claim.branchId`. Missing/invalid selection prevents creation and automatic Fanavaran submission. Changing browser state or calling the creation endpoint directly cannot omit branch validation. This adds no Fanavaran lookup ID or payload field.
The existing expert claim list filter and detail/assignment/action authorization compare the claim branch with the expert's stored branch, in addition to insurer/tenant isolation. Thus a new routed claim appears in that branch's queue and is rejected for damage experts from another branch, including direct access by case ID. Missing expert branch assignments are already denied. Insurer administrators should assign claim experts to the appropriate branches before rollout.
Existing claims are not migrated or reassigned. Their current access/ownership rules remain in effect. Already-signed blame cases without a claim select their branch on the final screen before entering claim creation. Direct entry into `/claim` also checks selection and returns to that screen if necessary. Deactivation between signing and creation requires choosing another active branch.
## User interface
The city and branch selectors appear above the signature canvas, only for the damaged user. A city change clears the branch selection. Same-named cities in different provinces have separate choices. The selected branch's address and phone are displayed. Loading, fetch failure/retry, empty lists and locked routing have explicit Persian states. Confirmation is disabled until the selection is valid. The signature dialog scrolls vertically on small screens.
The final screen reuses the selector for cases already signed before rollout; the backend selection rule also protects direct claim entry. Later v6 claim-result signing no longer asks for another branch, avoiding a competing choice. Existing expert-created flows retain their existing result-signing UI.
## Deployment and verification
Deploy API and `ui-user` together. No environment variables or database migration are required: the existing `branchId` fields and branch indexes are reused. Configure active branches, city/state/address and expert branch membership in the management panels. `ui-expert` already implements the required branch checks; no UI change there is needed.
Backend tests cover beneficiary/payer resolution, car-body and both third-party guilty positions, active insurer-scoped options, rejected foreign/inactive IDs, signature enforcement/persistence, culprit restrictions, legacy pre-claim selection, immutable existing claims, claim inheritance and branch access. Existing v6 workflow and authorization tests remain in place. Frontend tests cover city grouping, actor/case partitioning, loading/error/empty states, signature navigation and claim-entry compatibility.
Production QA should exercise each product in v1 and v6, both signature orders, a signed historical case, no active branches, deactivation before creation, and experts from two branches in the same insurer. Verify the selected branch sees the submitted claim and the other branch cannot list/open/assign it. Repeat expert-created flows 2–5 to confirm their creator ownership is preserved.
## Combined verification — 2026-11-11
| Check | Result |
| --- | --- |
| Complete API unit/regression suite | 90 suites, 774 tests passed |
| User and expert frontend regression suites | Both passed |
| Browser scenarios | 14 passed on real v1/v6 pages: desktop/mobile positive paths, legacy entry and guilty-party signing |
| TypeScript | API, user UI and expert UI checked |
The integration test is `test/claim-branch-flows.e2e-spec.ts`. It uses the production controllers, JWT verification, role guards, Persian error filter, branch service, signature service and claim creation method. Repository operations are isolated in-memory implementations that return fresh documents and apply persisted updates; media policy and external SMS/Fanavaran delivery are mocked. Generated test signature files are removed afterward. The resulting claim is passed through the actual expert tenant/branch authorization and queue-filter methods.
The matrix covers v1 car-body, v6 car-body, both possible v1 third-party damaged parties, v6's second/damaged party, and both valid third-party signature orders. It asserts the insurer comes from the paying party, validates branch inheritance, prevents guilty-party claim creation, rejects foreign/inactive branches, requires both signatures, preserves existing expert-created LINK branches, handles signed legacy cases, rechecks deactivation, blocks missing authentication/wrong roles/non-participants, freezes existing claim routing, and prevents duplicate sequential creation.
Browser tests draw a signature, verify its multipart request includes the selected branch, continue to claim creation once, and verify the claim can proceed. Changing city clears the previous branch. Existing signed cases entering `/claim` without a branch return to the branch picker. Separate v1/v6 guilty-party checks confirm no branch selection is requested and no claim-creation button appears. Existing suites cover the flow 2–5 ownership and file-maker/reviewer handoff rules.
No new application defect was found in this verification pass; the additional HTTP integration tests/configuration were retained as regression coverage. External-provider availability, production branch/staff configuration, real database connectivity/indexes and live SMS delivery were not exercised. Those still require deployment QA; these results do not claim an exhaustive proof of every possible application state.
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.