forked from Yara724/api
GEN.03 no longer waits on vehicle review; V3/file-maker create triggers early auto-submit, and expertise auto-path soft-ensures prior stages when each client's body is ready. Co-authored-by: Cursor <cursoragent@cursor.com>
174 lines
7.4 KiB
Markdown
174 lines
7.4 KiB
Markdown
---
|
|
last_updated: 2026-11-09
|
|
tags: [fanavaran, yara, integration]
|
|
source: fanavaran-module-docs
|
|
---
|
|
|
|
# 06 — YARA ↔ Fanavaran integration points
|
|
|
|
## Module map
|
|
|
|
| Concern | Module | Primary files |
|
|
|---------|--------|---------------|
|
|
| HTTP surface | `FanavaranModule` | `fanavaran.controller.ts` |
|
|
| Auth | `FanavaranModule` | `fanavaran-auth.service.ts` |
|
|
| Lookups | `FanavaranLookupModule` / `LookupsModule` | `fanavaran-lookup.service.ts`, `lookups.*` |
|
|
| Audit | `FanavaranAuditModule` | `fanavaran-audit.service.ts` |
|
|
| Tenant config | boot + System Settings | `fanavaran-client-config.service.ts`, `system-settings.*` |
|
|
| Orchestration | `ClaimRequestManagementModule` | `claim-request-management.service.ts` |
|
|
| Policy select | same | `fanavaran-policy-selection.ts` |
|
|
| SMS after expertise | Disabled by product decision | No message is dispatched |
|
|
|
|
---
|
|
|
|
## Interaction catalogue
|
|
|
|
### A. Authentication
|
|
|
|
| | |
|
|
|--|--|
|
|
| Module | `src/fanavaran` |
|
|
| Service | `FanavaranAuthService` |
|
|
| Controller | *(none external — used by claim/lookup)* |
|
|
| Functions | `getAuthenticationToken`, GetAppToken + Login internals |
|
|
| When | Before any Fanavaran business/lookup HTTP |
|
|
| Send | appname/secret → appToken → username/password |
|
|
| Receive | `authenticationToken` |
|
|
| Store | Memory cache + `fanavaranAuthTokens` |
|
|
| Consumers | Claim submit, lookups, policy inquiry |
|
|
|
|
### B. Base claim preview/submit
|
|
|
|
| | |
|
|
|--|--|
|
|
| Module | Fanavaran + ClaimRequestManagement |
|
|
| Controller | `FanavaranController.preview` / `submit` |
|
|
| Service | `ClaimRequestManagementService` |
|
|
| Functions | `previewFanavaranSubmitV2`, `submitFanavaranV2`, `executeFanavaranV2Submit`, `buildFanavaranSubmitPayload`, `getPolicyIdFromNationalCode` |
|
|
| When | Auto on claim create (all create paths including V3); soft-ensure before later stages; manual preview/submit. Vehicle review is **not** required for GEN.03 — only for damage/attachments/expertise. |
|
|
| Send | GEN.03 JSON + business headers |
|
|
| Receive | `Id`, `ClaimNo` |
|
|
| Store | `claimId`, `claimNo`, `fanavaranSync.baseClaim.*`, history |
|
|
| Consumers | Damage/expertise soft-ensure; UI claim detail |
|
|
|
|
Hull base claims always GET the selected hull policy, then GET its `VehicleId`
|
|
at `VehicleVersionNo`. `AccidentVehicleUsedId` is that vehicle response's
|
|
`UsedId`. This path does not substitute a guilty-party VIN, cached use id,
|
|
expert override, tenant default, or a generic lookup row. Missing `UsedId`
|
|
produces `FANAVARAN_HULL_VEHICLE_USE_UNRESOLVED` in preview and blocks submit.
|
|
Debug preview exposes `accidentVehicleUsedId` and `accidentVehicleUsedSource`.
|
|
|
|
#### Staff source for ClaimExpertId across request flows
|
|
|
|
The flows in `docs/Yara724 flows.pdf` share the same base-claim resolver.
|
|
Base claims use `ThirdPartyClaimExpertId` / `CarBodyClaimExpertId`; expertise
|
|
uses `ThirdPartyExpertiseClaim` / `CarBodyExpertiseClaim` from staff profiles.
|
|
|
|
| Local flow | Base-claim staff source | Expertise staff source |
|
|
|------------|------------------------|------------------------|
|
|
| V1/V2 user, including expert-panel review | Blame expert when present; otherwise claim damage-review actor or persistent reviewer assignment | Claim damage-review actor |
|
|
| V2 expert-initiated / V3 | Initiating field expert, then blame expert; claim damage reviewer is a fallback | Claim damage-review actor |
|
|
| V4 / V5 | Initiating FileMaker | Assigned FileReviewer |
|
|
|
|
Outside V4/V5, base resolution checks blame initiator, blame assigned expert,
|
|
blame deciding expert, claim initiator, claim reply actor, then
|
|
`workflow.assignedForReviewBy.actorId`, in that order. Reply actor selection
|
|
matches expertise: the active submitted reply, then final/initial reply actor.
|
|
Temporary workflow locks are not reviewer assignments.
|
|
|
|
An unassigned user-created claim can still have no expert early in its lifecycle:
|
|
preview returns a missing-expert warning, and submit requires a resolvable code.
|
|
Tenant defaults and unrelated staff profiles do not supply expert ids.
|
|
For example, a claim review actor with `ThirdPartyClaimExpertId="5507"` and
|
|
`ThirdPartyExpertiseClaim="5510"` supplies base `ClaimExpertId=5507` and
|
|
expertise `ClaimExpertId=5510`.
|
|
|
|
### C. Damage case
|
|
|
|
| | |
|
|
|--|--|
|
|
| Controller | `previewDamageCase` / `submitDamageCase` |
|
|
| Functions | `previewFanavaranDamageCaseV2`, `submitFanavaranDamageCaseV2`, `buildFanavaranDamageCasePayload`, `autoSubmitFanavaranDamageCaseOnOuterPartsSelected`, `ensureFanavaranBaseClaim` |
|
|
| When | After outer parts selected; soft-ensure from later stages |
|
|
| Send | GEN.12 JSON |
|
|
| Receive | `Id` → `dmgCaseId` |
|
|
| Store | `dmgCaseId`, `fanavaranSync.damageCase.{driverId,vehicleKindId,insuranceCorpId,lastPayload}` |
|
|
| Consumers | Expertise payload (`DmgCaseId`) |
|
|
|
|
### D. Attachments
|
|
|
|
| | |
|
|
|--|--|
|
|
| Controller | `previewAttachments` / `submitAttachments` |
|
|
| Functions | `previewFanavaranAttachmentsV2`, `submitFanavaranAttachmentsV2`, `autoSubmitFanavaranAttachment` |
|
|
| When | After local required-doc / capture upload |
|
|
| Send | multipart GEN.07 |
|
|
| Receive | file metadata / ids |
|
|
| Store | `fanavaranSync.attachments.files[]` |
|
|
| Consumers | Manual retry of missing uploads |
|
|
|
|
### E. Expertise
|
|
|
|
| | |
|
|
|--|--|
|
|
| Controller | `previewExpertise` / `submitExpertise` |
|
|
| Functions | `previewFanavaranExpertiseV2`, `submitFanavaranExpertiseV2`, `buildFanavaranExpertisePayload`, `autoSubmitFanavaranExpertiseOnExpertReply`, `ensureFanavaranDamageCase` |
|
|
| When | Expert reply priced / factor validated |
|
|
| Send | GEN.08 JSON |
|
|
| Receive | `Id` → `expertiseId` |
|
|
| Store | `expertiseId`, `fanavaranSync.expertise.*` |
|
|
| Consumers | Claim completion reporting / history |
|
|
|
|
### F. Lookups (read)
|
|
|
|
| | |
|
|
|--|--|
|
|
| Controller | `LookupsController` |
|
|
| Service | `LookupsService` → `FanavaranLookupService` |
|
|
| When | UI dropdowns; cold cache; payload id resolution |
|
|
| Store | `files/fanavaran-lookups/{client}/*.json` |
|
|
|
|
### G. Tenant config admin
|
|
|
|
| | |
|
|
|--|--|
|
|
| Module | System Settings |
|
|
| Service | `SystemSettingsService` / `FanavaranClientConfigService` |
|
|
| When | Boot seed missing keys; admin update |
|
|
| Store | `fanavaranClientConfigs` → in-memory cache via `setFanavaranClientProfilesCache` |
|
|
|
|
### H. Claim create call sites (auto base)
|
|
|
|
`autoSubmitToFanavaranV2OnClaimCreated` is invoked from claim creation paths inside `ClaimRequestManagementService` (registrar / expert-initiated / v2 create flows — search call sites ~7717, 7839, 8141, 8243).
|
|
|
|
Outer parts selection invokes damage auto-submit (~8422).
|
|
Document/capture upload hooks call attachment auto-submit (~9496+).
|
|
Expert reply path calls expertise auto-submit (~10576).
|
|
|
|
---
|
|
|
|
## Controllers summary
|
|
|
|
| Controller | Fanavaran-related routes |
|
|
|------------|--------------------------|
|
|
| `FanavaranController` | All `/v2/fanavaran/*` preview/submit |
|
|
| `LookupsController` | `/lookups/*` Fanavaran-backed reads |
|
|
| Claim V2 / registrar / expert mirrors | Create/select/upload that **trigger** auto-submit (no direct Fanavaran URL) |
|
|
|
|
---
|
|
|
|
## Data written by Fanavaran stages
|
|
|
|
| Field path | Stage |
|
|
|------------|-------|
|
|
| `claimCases.claimId` / `claimNo` | GEN.03 |
|
|
| `claimCases.dmgCaseId` | GEN.12 |
|
|
| `claimCases.expertiseId` | GEN.08 |
|
|
| `claimCases.fanavaranSync.*` | All |
|
|
| `claimCases.fanavaranSync.damageCase.otherPersonId` | GEN.44 |
|
|
| `claimCases.history[]` | Success/fail events |
|
|
| `blameCases.parties[].person.fanavaranDriverId` | GEN.12 driver resolve / GEN.44 |
|
|
| `fanavaranAuditLogs` | Every real HTTP step |
|
|
| `fanavaranAuthTokens` | Auth cache |
|
|
| `fanavaranClientConfigs` | Tenant profiles |
|