forked from Yara724/api
Merge pull request 'fanavaran manuall test script + warn sms for fanavaran triggers at the last stage' (#273) from s.hajizadeh/yara724api:main into main
Reviewed-on: Yara724/api#273
This commit is contained in:
43
.gitignore
vendored
43
.gitignore
vendored
@@ -16,6 +16,7 @@ pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
files/fanavaran-auth/
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
@@ -80,6 +81,9 @@ web_modules/
|
||||
.env.production.local
|
||||
.env.local
|
||||
.env.development.env
|
||||
scripts/data/fanavaran-flow.*.env
|
||||
!scripts/data/fanavaran-flow.env.example
|
||||
files/fanavaran-flow/
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
@@ -143,4 +147,43 @@ dist
|
||||
/docker
|
||||
.development.env
|
||||
*.env
|
||||
!scripts/data/fanavaran-flow.env.example
|
||||
/files
|
||||
|
||||
*.jpg
|
||||
*.jpeg
|
||||
*.png
|
||||
*.gif
|
||||
*.bmp
|
||||
*.tiff
|
||||
*.ico
|
||||
*.webp
|
||||
*.svg
|
||||
*.heic
|
||||
*.heif
|
||||
*.heif-srgb
|
||||
*.heif-srgb-alpha
|
||||
*.heif-srgb-alpha-heic
|
||||
|
||||
*.mp3
|
||||
*.mp4
|
||||
*.wav
|
||||
*.ogg
|
||||
*.flac
|
||||
*.aac
|
||||
*.m4a
|
||||
*.m4v
|
||||
*.m4b
|
||||
*.m4p
|
||||
*.m4r
|
||||
*.m4w
|
||||
*.m4x
|
||||
*.txt
|
||||
*.md
|
||||
!README.md
|
||||
!docs/
|
||||
!docs/**/*.md
|
||||
*.sh
|
||||
!scripts/fanavaran-flow-test.sh
|
||||
!scripts/fanavaran-auth.sh
|
||||
*.json
|
||||
@@ -127,8 +127,7 @@ Full shape: see skill reference sample and `buildFanavaranSubmitPayload` / `appl
|
||||
| `Id` | `claimCases.claimId` |
|
||||
| `ClaimNo` | `claimCases.claimNo` |
|
||||
|
||||
History: `FANAVARAN_EARLY_AUTO_SUBMIT_SUCCEEDED`.
|
||||
SMS owner via `SmsOrchestrationService` (deduped `fanavaranSync.baseClaim.smsNotifiedAt`).
|
||||
History: `FANAVARAN_EARLY_AUTO_SUBMIT_SUCCEEDED`.
|
||||
|
||||
### Error handling
|
||||
|
||||
@@ -309,6 +308,7 @@ Requires `claimId` + `dmgCaseId` (soft-ensures earlier stages).
|
||||
| `Id` | `claimCases.expertiseId` |
|
||||
|
||||
History: `FANAVARAN_EXPERTISE_AUTO_SUBMIT_SUCCEEDED`.
|
||||
SMS owner via `SmsOrchestrationService` (deduped `fanavaranSync.expertise.smsNotifiedAt`).
|
||||
Proven Parsian: `expertiseId=403144`, `ClaimExpertId=29`.
|
||||
|
||||
Manual: `POST /v2/fanavaran/{client}/claim-cases/{id}/expertise/submit`.
|
||||
|
||||
@@ -31,7 +31,7 @@ source: fanavaran-module-docs
|
||||
| Validation: FileTypeId ∈ tenant lookup | logic ✅ | allowed ids ✅ |
|
||||
| Business: THIRD_PARTY only | ✅ | ❌ |
|
||||
| Provisional address / dummy licence | ✅ today | may customize later |
|
||||
| SMS template after base claim | shared orchestration | provider/templates may ✅ |
|
||||
| SMS template after expertise | shared orchestration | provider/templates may ✅ |
|
||||
| Mongo collections / audit schema | ✅ | ❌ |
|
||||
| Offline inquiry seeds | may exist per client | ✅ |
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ Start local claim
|
||||
→ Validate THIRD_PARTY + data readiness
|
||||
→ Auth (cached token)
|
||||
→ Policy inquiry (resolve-once PolicyId)
|
||||
→ GEN.03 base claim → store claimId / claimNo → SMS owner
|
||||
→ GEN.03 base claim → store claimId / claimNo
|
||||
→ SELECT_OUTER_PARTS
|
||||
→ GEN.12 damage case → store dmgCaseId
|
||||
→ Upload docs/images locally
|
||||
→ GEN.07 attachments (per file, best-effort)
|
||||
→ Expert pricing ready
|
||||
→ GEN.08 expertise → store expertiseId
|
||||
→ GEN.08 expertise → store expertiseId → SMS owner
|
||||
→ End (local completion independent of Fanavaran success)
|
||||
```
|
||||
|
||||
@@ -56,7 +56,6 @@ sequenceDiagram
|
||||
YARA->>FV: POST third-party-car-financial-claims (GEN.03)
|
||||
FV-->>YARA: Id, ClaimNo
|
||||
YARA->>DB: claimId, claimNo, history SUCCESS
|
||||
YARA->>YARA: SMS owner (deduped)
|
||||
|
||||
User->>YARA: SELECT_OUTER_PARTS
|
||||
YARA->>YARA: autoSubmitFanavaranDamageCase...
|
||||
@@ -77,6 +76,7 @@ sequenceDiagram
|
||||
YARA->>FV: POST .../expertise (GEN.08)
|
||||
FV-->>YARA: ExpertiseId
|
||||
YARA->>DB: expertiseId, history SUCCESS
|
||||
YARA->>YARA: SMS owner (deduped)
|
||||
```
|
||||
|
||||
## Flow diagram (stages + soft-ensure)
|
||||
|
||||
@@ -17,7 +17,7 @@ source: fanavaran-module-docs
|
||||
| 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 base | `SmsOrchestrationModule` | `sms-orchestration.service.ts` |
|
||||
| SMS after expertise | `SmsOrchestrationModule` | `sms-orchestration.service.ts` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ source: fanavaran-module-docs
|
||||
|
||||
| Dependency | Role |
|
||||
|------------|------|
|
||||
| **SMS provider** | Notify owner after successful GEN.03 (`SmsOrchestrationService`; same as login SMS stack) |
|
||||
| **SMS provider** | Notify owner after successful GEN.08 expertise (`SmsOrchestrationService`; same as login SMS stack) |
|
||||
| **Offline inquiry seeds** | Can supply driver/policy test data without live inquiry |
|
||||
| **Redis / Queue** | **Not** used for Fanavaran stage orchestration today — retries are in-process `setTimeout` + Mongo `nextRetryAt` |
|
||||
|
||||
|
||||
@@ -69,4 +69,4 @@ Per HTTP step:
|
||||
|
||||
## SMS
|
||||
|
||||
After successful base claim, owner SMS may be sent once (`smsNotifiedAt`). Failure to SMS should not roll back Fanavaran claim create; treat as separate notification concern.
|
||||
After successful expertise (last Fanavaran stage), owner SMS may be sent once (`fanavaranSync.expertise.smsNotifiedAt`). Failure to SMS should not roll back Fanavaran expertise submit; treat as separate notification concern. Claims already notified at base claim (`fanavaranSync.baseClaim.smsNotifiedAt`) are not re-notified.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
last_updated: 2026-08-08
|
||||
last_updated: 2026-08-17
|
||||
tags: [fanavaran, testing]
|
||||
source: fanavaran-module-docs
|
||||
---
|
||||
@@ -22,6 +22,96 @@ source files/fanavaran-auth/parsian/tokens.env
|
||||
# then curl a lookup — see docs/external-api-curls.md
|
||||
```
|
||||
|
||||
## Manual Fanavaran flow test (no YARA)
|
||||
|
||||
Use this when there is **no YARA claim** and you need to prove a tenant (Parsian / Tejaratno / Moallem) against Fanavaran with the **same stage order as the app**.
|
||||
|
||||
Files in git:
|
||||
|
||||
| Path | Role |
|
||||
|------|------|
|
||||
| `scripts/fanavaran-flow-test.sh` | Standalone tester |
|
||||
| `scripts/data/fanavaran-flow.env.example` | Template env (section A = you fill, section B = script fills) |
|
||||
|
||||
Do **not** commit a filled copy (`fanavaran-flow.moallem.env` and similar). It contains national codes, plate data, and secrets. Copy the example on the machine that runs the test.
|
||||
|
||||
### 1. Copy and fill the env
|
||||
|
||||
```bash
|
||||
cp scripts/data/fanavaran-flow.env.example scripts/data/fanavaran-flow.<client>.env
|
||||
```
|
||||
|
||||
Fill **section A** before the first run:
|
||||
|
||||
- Tenant: `FANAVARAN_CLIENT`, optional auth overrides (`APP_NAME`, `CORP_ID`, `LOCATION`, …)
|
||||
- Lookup ids **from that tenant** (`files/fanavaran-lookups/<client>/`): `CLAIM_EXPERT_ID`, `EXPERTISE_CLAIM_EXPERT_ID`, `CLAIM_FILE_TYPE_ID`, `VEHICLE_KIND_ID`, `DMG_SECTION_ID`
|
||||
- `INSURANCE_CORP_ID`: Persian caption **or** numeric Fanavaran Id
|
||||
- Case data: guilty national code, driver national code + Jalali birthday, plate/chassis/VIN if you have them
|
||||
- `ATTACHMENT_FILE`: absolute path(s) to image(s) **on the host that runs the script** (comma-separated for several files)
|
||||
- Leave **section B empty** (`POLICY_ID`, `CLAIM_ID`, …)
|
||||
|
||||
Lookup ids from Tejaratno/Parsian files are invalid for Moallem (Fanavaran returns `نوع خودرو یافت نشد` and similar). Fetch Moallem lookups first (`GET /lookups/vehicle-kinds` with `FANAVARAN_CLIENT=moallem`, or curl Fanavaran with that tenant’s token).
|
||||
|
||||
### 2. Network / IP whitelist
|
||||
|
||||
Fanavaran Login is IP-restricted. From a **whitelisted server**, run with no proxy. From **localhost**, Termius dynamic port forwarding does **not** apply automatically — set:
|
||||
|
||||
```env
|
||||
CURL_PROXY=socks5h://127.0.0.1:<termius-socks-port>
|
||||
```
|
||||
|
||||
Error `کاربر … مجاز به لاگین با آی پی … نمیباشد` means curl is still using your home IP.
|
||||
|
||||
### 3. Run (same sequence as the app)
|
||||
|
||||
```text
|
||||
auth (cached until Tehran midnight)
|
||||
→ policy inquiry → GEN.03 base
|
||||
→ driver inquiry + insurance-corp
|
||||
→ GEN.12 damage
|
||||
→ GEN.07 attachments (one request per file)
|
||||
→ GEN.08 expertise
|
||||
```
|
||||
|
||||
From repo root (`bash`, `curl`, `node`, `awk` required):
|
||||
|
||||
```bash
|
||||
chmod +x scripts/fanavaran-flow-test.sh
|
||||
|
||||
# Full flow (confirms before each POST)
|
||||
./scripts/fanavaran-flow-test.sh --env scripts/data/fanavaran-flow.moallem.env
|
||||
|
||||
# One or more stages
|
||||
./scripts/fanavaran-flow-test.sh --env scripts/data/fanavaran-flow.moallem.env --stages base,damage
|
||||
./scripts/fanavaran-flow-test.sh --env scripts/data/fanavaran-flow.moallem.env --stages attachments
|
||||
./scripts/fanavaran-flow-test.sh --env scripts/data/fanavaran-flow.moallem.env --stages expertise
|
||||
|
||||
# Build payloads / inquiries only
|
||||
./scripts/fanavaran-flow-test.sh --env scripts/data/fanavaran-flow.moallem.env --preview-only
|
||||
```
|
||||
|
||||
Missing section-A fields can be typed when prompted; they are written back into the env file.
|
||||
|
||||
### 4. Token cache (do not Login every run)
|
||||
|
||||
`authenticationToken` is stored in `files/fanavaran-auth/<client>/tokens.env` until **Asia/Tehran midnight** (same as Nest). Later runs print `Reusing cached authenticationToken`. Use `--force-login` only when you must mint a new token.
|
||||
|
||||
Repeated Login causes Fanavaran `لطفا پس از چند لحظه مجدد تلاش فرمایید`.
|
||||
|
||||
### 5. Resume after a stage succeeds
|
||||
|
||||
Section B is updated in the **same env file**. Re-run; stages with `CLAIM_ID` / `DMG_CASE_ID` already set are skipped (soft-skip). Payloads and HTTP bodies also land under `files/fanavaran-flow/<client>/<timestamp>/` (gitignored).
|
||||
|
||||
### 6. Typical failures
|
||||
|
||||
| Message | What to do |
|
||||
|---------|------------|
|
||||
| Login IP not allowed | Run on the tenant server, or set `CURL_PROXY` to Termius SOCKS |
|
||||
| Try again later | Wait; reuse cache; do not `--force-login` |
|
||||
| `نوع خودرو یافت نشد` | Set `VEHICLE_KIND_ID` from **this** tenant’s `vehicle-kinds` lookup |
|
||||
| File type lookup mismatch | Set `CLAIM_FILE_TYPE_ID` from this tenant’s `file-types` |
|
||||
| No `authenticationToken` | Read `login.body.json` in the run folder — Fanavaran `Message` is the real error |
|
||||
|
||||
## Unit / service specs
|
||||
|
||||
| Spec | Focus |
|
||||
@@ -31,7 +121,7 @@ source files/fanavaran-auth/parsian/tokens.env
|
||||
|
||||
Prefer mocks for Fanavaran HTTP in unit tests; use live calls only in controlled integration.
|
||||
|
||||
## Manual E2E (Parsian template)
|
||||
## Manual E2E (Parsian template — via YARA)
|
||||
|
||||
1. Create THIRD_PARTY claim with guilty party national code that has an **active** Fanavaran policy.
|
||||
2. Confirm history `FANAVARAN_EARLY_AUTO_SUBMIT_SUCCEEDED` and `claimId`/`claimNo`.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
last_updated: 2026-08-08
|
||||
last_updated: 2026-08-17
|
||||
tags: [fanavaran, documentation, parsian, third-party-claim]
|
||||
source: fanavaran-module-docs
|
||||
---
|
||||
@@ -32,7 +32,7 @@ source: fanavaran-module-docs
|
||||
| 7 | [07-data-mapping.md](./07-data-mapping.md) | YARA field → Fanavaran field |
|
||||
| 8 | [08-dependencies.md](./08-dependencies.md) | Mongo, files, env, SMS, audit |
|
||||
| 9 | [09-error-handling.md](./09-error-handling.md) | Errors, retry, backoff, logging |
|
||||
| 10 | [10-testing.md](./10-testing.md) | Test scenarios, scripts, proven case |
|
||||
| 10 | [10-testing.md](./10-testing.md) | Test scenarios, **manual flow-test script**, proven case |
|
||||
| 11 | [11-onboard-new-client.md](./11-onboard-new-client.md) | Checklist to add a new insurer |
|
||||
|
||||
## Related sources (code)
|
||||
@@ -47,6 +47,8 @@ source: fanavaran-module-docs
|
||||
| `.agents/skills/fanavaran-apis/references/third-party-cases.md` | Agent-oriented implementation rules |
|
||||
| `docs/external-api-curls.md` | Ready-to-run curl sequences |
|
||||
| `scripts/fanavaran-auth.sh` | Token helper |
|
||||
| `scripts/fanavaran-flow-test.sh` | Manual Fanavaran-only staged submit (see [10-testing.md](./10-testing.md)) |
|
||||
| `scripts/data/fanavaran-flow.env.example` | Env template for the flow-test script |
|
||||
|
||||
## Architecture (one glance)
|
||||
|
||||
|
||||
91
scripts/data/fanavaran-flow.env.example
Normal file
91
scripts/data/fanavaran-flow.env.example
Normal file
@@ -0,0 +1,91 @@
|
||||
# Fanavaran flow test — copy this file, fill section A, then run:
|
||||
#
|
||||
# cp scripts/data/fanavaran-flow.env.example scripts/data/fanavaran-flow.moallem.env
|
||||
# ./scripts/fanavaran-flow-test.sh --env scripts/data/fanavaran-flow.moallem.env
|
||||
#
|
||||
# Section A = you fill before (or when the script asks).
|
||||
# Section B = leave empty. The script writes Fanavaran ids here after each stage
|
||||
# so you can stop, re-run, or continue without copying ids by hand.
|
||||
#
|
||||
# Do not commit real secrets or national codes.
|
||||
|
||||
# =============================================================================
|
||||
# A) FILL BEFORE RUN
|
||||
# =============================================================================
|
||||
|
||||
# --- tenant ---
|
||||
FANAVARAN_CLIENT=moallem
|
||||
|
||||
# Localhost only: route curl through Termius SOCKS (Dynamic Port Forwarding).
|
||||
# Example: CURL_PROXY=socks5h://127.0.0.1:1080
|
||||
# Or run the script on the Moallem server (no proxy needed).
|
||||
# CURL_PROXY=
|
||||
|
||||
# Optional auth overrides (omit to use built-in seeds for this client)
|
||||
# APP_NAME=ItTalie
|
||||
# APP_SECRET=
|
||||
# FANAVARAN_USERNAME=
|
||||
# FANAVARAN_PASSWORD=
|
||||
# CORP_ID=
|
||||
# CONTRACT_ID=
|
||||
# LOCATION=
|
||||
|
||||
# --- tenant lookup ids (from this insurer's Fanavaran lookups) ---
|
||||
CLAIM_EXPERT_ID=
|
||||
EXPERTISE_CLAIM_EXPERT_ID=
|
||||
CLAIM_FILE_TYPE_ID=
|
||||
VEHICLE_KIND_ID=
|
||||
DMG_SECTION_ID=
|
||||
|
||||
# Persian caption OR numeric Fanavaran Id
|
||||
INSURANCE_CORP_ID=
|
||||
|
||||
# --- GEN.03 case ---
|
||||
GUILTY_NATIONAL_CODE=
|
||||
ACCIDENT_DATE=1404/05/20
|
||||
ACCIDENT_TIME=12:00
|
||||
|
||||
# --- GEN.12 case ---
|
||||
DRIVER_NATIONAL_CODE=
|
||||
DRIVER_BIRTH_YEAR=1370
|
||||
DRIVER_BIRTH_MONTH=1
|
||||
DRIVER_BIRTH_DAY=1
|
||||
DRIVER_IS_INSURER=0
|
||||
LICENCE_NO=
|
||||
DESC=سپر عقب
|
||||
|
||||
# Optional vehicle / plate / policy document (leave empty if unknown)
|
||||
# PLAQUE_LEFT_NO=
|
||||
# PLAQUE_RIGHT_NO=
|
||||
# PLAQUE_SERIAL=
|
||||
# PLAQUE_MIDDLE_CODE_ID=
|
||||
# PLAQUE_NO=
|
||||
# CHASSIS_NO=
|
||||
# MOTOR_NO=
|
||||
# VIN=
|
||||
# POLICY_NO=
|
||||
# POLICY_CI_NUMBER=
|
||||
# BEGIN_DATE=
|
||||
# END_DATE=
|
||||
# BUILT_YEAR=
|
||||
|
||||
# --- GEN.07 ---
|
||||
ATTACHMENT_FILE=
|
||||
|
||||
# --- GEN.08 ---
|
||||
DMG_ASSESSMENT_DATE=1404/05/20
|
||||
INSPECTION_TIME=12:00
|
||||
REPAIR_WAGE=0
|
||||
COMPONENT_REPLACEMENT_COST=0
|
||||
WASTE_VALUE=0
|
||||
|
||||
# =============================================================================
|
||||
# B) FILLED BY SCRIPT (do not set these before the first run)
|
||||
# =============================================================================
|
||||
POLICY_ID=
|
||||
CLAIM_ID=
|
||||
CLAIM_NO=
|
||||
DRIVER_ID=
|
||||
INSURANCE_CORP_ID_NUM=
|
||||
DMG_CASE_ID=
|
||||
EXPERTISE_ID=
|
||||
1111
scripts/fanavaran-flow-test.sh
Executable file
1111
scripts/fanavaran-flow-test.sh
Executable file
File diff suppressed because it is too large
Load Diff
@@ -5918,6 +5918,13 @@ export class ClaimRequestManagementService {
|
||||
this.logger.log(
|
||||
`[executeFanavaranExpertiseSubmit] Already have expertiseId=${claimCase.expertiseId}; skipping Fanavaran POST`,
|
||||
);
|
||||
// Catch-up / deduped: SMS may still be pending if expertise predated this notify.
|
||||
await this.notifyClaimOwnerFanavaranClaimRegistered({
|
||||
claimCaseId,
|
||||
claimId: claimCase.claimId,
|
||||
claimNo: claimCase.claimNo,
|
||||
logPrefix: `[Fanavaran ${clientKey} V2 Expertise]`,
|
||||
});
|
||||
return (
|
||||
(claimCase as any)?.fanavaranSync?.expertise?.response ?? {
|
||||
Id: claimCase.expertiseId,
|
||||
@@ -5982,6 +5989,14 @@ export class ClaimRequestManagementService {
|
||||
},
|
||||
});
|
||||
|
||||
// Best-effort: SMS after last Fanavaran stage (expertise) succeeds
|
||||
await this.notifyClaimOwnerFanavaranClaimRegistered({
|
||||
claimCaseId,
|
||||
claimId: claimCase.claimId,
|
||||
claimNo: claimCase.claimNo,
|
||||
logPrefix: `[Fanavaran ${clientKey} V2 Expertise]`,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
const exchange = this.fanavaranAuditService.captureAxiosExchange(error);
|
||||
@@ -6018,6 +6033,12 @@ export class ClaimRequestManagementService {
|
||||
};
|
||||
}
|
||||
if (claimCase.expertiseId != null) {
|
||||
await this.notifyClaimOwnerFanavaranClaimRegistered({
|
||||
claimCaseId,
|
||||
claimId: claimCase.claimId,
|
||||
claimNo: claimCase.claimNo,
|
||||
logPrefix,
|
||||
});
|
||||
return {
|
||||
attempted: false,
|
||||
submitted: false,
|
||||
@@ -7083,11 +7104,11 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* After Fanavaran base claim create succeeds, SMS the claim owner with
|
||||
* ClaimNo + claimId. Uses SmsOrchestrationService → same provider as login
|
||||
* for this deployment (`SMS` / `SMS_PROVIDER`). Never throws.
|
||||
* After Fanavaran expertise (last stage) succeeds, SMS the claim owner with
|
||||
* publicId + claimId + ClaimNo. Uses SmsOrchestrationService → same provider
|
||||
* as login for this deployment (`SMS` / `SMS_PROVIDER`). Never throws.
|
||||
*/
|
||||
private async notifyClaimOwnerFanavaranBaseClaimRegistered(input: {
|
||||
private async notifyClaimOwnerFanavaranClaimRegistered(input: {
|
||||
claimCaseId: string;
|
||||
claimId?: number | string | null;
|
||||
claimNo?: number | string | null;
|
||||
@@ -7106,7 +7127,9 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
if (!claimCase) return;
|
||||
|
||||
if ((claimCase as any)?.fanavaranSync?.baseClaim?.smsNotifiedAt) {
|
||||
const sync = (claimCase as any)?.fanavaranSync;
|
||||
// Dedup: expertise stage, or older base-claim notify from before the move.
|
||||
if (sync?.expertise?.smsNotifiedAt || sync?.baseClaim?.smsNotifiedAt) {
|
||||
this.logger.log(
|
||||
`${input.logPrefix} Fanavaran SMS already sent; skipping duplicate`,
|
||||
);
|
||||
@@ -7127,23 +7150,21 @@ export class ClaimRequestManagementService {
|
||||
: String(input.claimCaseId);
|
||||
|
||||
const sent =
|
||||
await this.smsOrchestrationService.sendFanavaranBaseClaimRegisteredNotice(
|
||||
{
|
||||
receptor: phone,
|
||||
publicId,
|
||||
claimNo: input.claimNo,
|
||||
claimId: input.claimId,
|
||||
},
|
||||
);
|
||||
await this.smsOrchestrationService.sendFanavaranClaimRegisteredNotice({
|
||||
receptor: phone,
|
||||
publicId,
|
||||
claimNo: input.claimNo ?? claimCase.claimNo,
|
||||
claimId: input.claimId ?? claimCase.claimId,
|
||||
});
|
||||
|
||||
if (sent) {
|
||||
await this.claimCaseDbService.findByIdAndUpdate(input.claimCaseId, {
|
||||
$set: {
|
||||
"fanavaranSync.baseClaim.smsNotifiedAt": new Date(),
|
||||
"fanavaranSync.expertise.smsNotifiedAt": new Date(),
|
||||
},
|
||||
});
|
||||
this.logger.log(
|
||||
`${input.logPrefix} Fanavaran claim SMS sent to claim owner phone=${phone} claimNo=${input.claimNo ?? "-"} claimId=${input.claimId ?? "-"}`,
|
||||
`${input.logPrefix} Fanavaran claim SMS sent to claim owner phone=${phone} publicId=${publicId} claimNo=${input.claimNo ?? claimCase.claimNo ?? "-"} claimId=${input.claimId ?? claimCase.claimId ?? "-"}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -7301,14 +7322,6 @@ export class ClaimRequestManagementService {
|
||||
claimCaseId,
|
||||
updateData,
|
||||
);
|
||||
|
||||
// Best-effort: same SMS provider as login for this deployment
|
||||
await this.notifyClaimOwnerFanavaranBaseClaimRegistered({
|
||||
claimCaseId,
|
||||
claimId,
|
||||
claimNo,
|
||||
logPrefix,
|
||||
});
|
||||
}
|
||||
|
||||
return response.data;
|
||||
|
||||
@@ -107,7 +107,7 @@ export class FanavaranSyncStage {
|
||||
@Prop({ type: Date })
|
||||
lastPayloadBuiltAt?: Date;
|
||||
|
||||
/** When we SMS'd the claim owner about Fanavaran claimId/ClaimNo (base claim). */
|
||||
/** When we SMS'd the claim owner about Fanavaran claimId/ClaimNo (after expertise). */
|
||||
@Prop({ type: Date })
|
||||
smsNotifiedAt?: Date;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ export const SEED_FANAVARAN_CLIENT_PROFILES: Record<
|
||||
defaults: {
|
||||
...SHARED_FANAVARAN_DEFAULTS,
|
||||
// GEN.03 — کارشناس مسئول پرونده مالی
|
||||
ClaimExpertId: 4543092,
|
||||
ClaimExpertId: 2721,
|
||||
// GEN.08 — ارزیاب (proven successful submit 2026-07-18 ClaimExpertId: 2709)
|
||||
ExpertiseClaimExpertId: 2709,
|
||||
ClaimFileTypeId: 23,
|
||||
@@ -152,7 +152,7 @@ export const SEED_FANAVARAN_CLIENT_PROFILES: Record<
|
||||
password: "itT@l!3@user",
|
||||
corpId: "5650",
|
||||
contractId: "304",
|
||||
location: "30900",
|
||||
location: "1",
|
||||
},
|
||||
// Expert role ids not confirmed for Moallem yet — start from shared shape.
|
||||
defaults: {
|
||||
|
||||
@@ -19,7 +19,7 @@ const PARSIAN_TEMPLATE_BODIES: Record<string, string> = {
|
||||
"yara-signature":
|
||||
"امضای پرونده {token} ({token2}) توسط کارشناس {token3} بررسی شد.\nلینک: {token10}",
|
||||
"yara-fanavaran-claim":
|
||||
"کاربر گرامی پرونده شما به شماره {token3} در فناوران با شناسه {token2} و شماره {token} ثبت شده است. جهت پیگیری های آتی پرونده خود باید از این اطلاعات استفاده کنید.",
|
||||
"کاربرگرامی پرونده شما به شماره {token} در سامانه فناوران با شناسه {token2} و شماره پرونده {token3} ثبت شده است. جهت پیگیری های آتی از این اطلاعات استفاده کنید.",
|
||||
};
|
||||
|
||||
function applyTokens(
|
||||
|
||||
@@ -194,17 +194,18 @@ export class SmsOrchestrationService implements OnModuleInit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the claim owner (damaged party) that the Fanavaran base claim was
|
||||
* created. Uses the same SMS gateway/provider as login for this deployment.
|
||||
* Notify the claim owner (damaged party) after Fanavaran expertise (last
|
||||
* stage) succeeds. Uses the same SMS gateway/provider as login.
|
||||
*
|
||||
* token = ClaimNo, token2 = claimId (Fanavaran Id), token3 = Yara publicId
|
||||
* token = Yara publicId (claim case number), token2 = Fanavaran claimId,
|
||||
* token3 = Fanavaran claimNo
|
||||
*
|
||||
* Parsian body:
|
||||
* کاربر گرامی پرونده شما به شماره {publicId} در فناوران با شناسه {claimId}
|
||||
* و شماره {claimNo} ثبت شده است. جهت پیگیری های آتی پرونده خود باید از این
|
||||
* اطلاعات استفاده کنید.
|
||||
* کاربرگرامی پرونده شما به شماره {publicId} در سامانه فناوران با شناسه
|
||||
* {claimId} و شماره پرونده {claimNo} ثبت شده است. جهت پیگیری های آتی از
|
||||
* این اطلاعات استفاده کنید.
|
||||
*/
|
||||
async sendFanavaranBaseClaimRegisteredNotice(params: {
|
||||
async sendFanavaranClaimRegisteredNotice(params: {
|
||||
receptor: string;
|
||||
publicId: string;
|
||||
claimNo?: string | number | null;
|
||||
@@ -221,12 +222,22 @@ export class SmsOrchestrationService implements OnModuleInit {
|
||||
return this.sendTemplate({
|
||||
template: "yara-fanavaran-claim",
|
||||
receptor: params.receptor,
|
||||
token: params.publicId || "-",
|
||||
token: params.publicId || "-",
|
||||
token2: claimId,
|
||||
token3: claimNo,
|
||||
});
|
||||
}
|
||||
|
||||
/** @deprecated Use sendFanavaranClaimRegisteredNotice */
|
||||
async sendFanavaranBaseClaimRegisteredNotice(params: {
|
||||
receptor: string;
|
||||
publicId: string;
|
||||
claimNo?: string | number | null;
|
||||
claimId?: string | number | null;
|
||||
}): Promise<boolean> {
|
||||
return this.sendFanavaranClaimRegisteredNotice(params);
|
||||
}
|
||||
|
||||
private async sendTemplate(args: TemplateArgs): Promise<boolean> {
|
||||
try {
|
||||
await this.smsGatewayService.verifyLookUp(args);
|
||||
|
||||
Reference in New Issue
Block a user