automatiacally previous stages submitted

This commit is contained in:
2026-11-11 18:36:10 +03:30
parent 84b92eb55a
commit 8b9dabc9f2
8 changed files with 437 additions and 23 deletions
@@ -68,3 +68,37 @@ To verify remote receipts directly, use
`GET /v2/fanavaran/parsian/claim-cases/{claimCaseId}/hull/files`.
Retrieve one image and its Base64 content using `/hull/files/{fileId}`.
See [hull retrieval](hull-retrieval.md) for all supported read routes.
## Expertise submit completes missing prerequisites
The frontend can call
`POST /v2/fanavaran/{client}/claim-cases/{claimCaseId}/expertise/submit`
without separately retrying earlier stages. The backend completes them in order:
- Third-party: base claim → damage case → pending attachments → expertise.
- Hull: base claim → pending attachments → expertise. Hull has no damage-case stage.
Existing claim/damage IDs and successful image receipts are reused. A previously
skipped attachment stage is retried. Completion is checked against a fresh read
of the saved receipts for all current local image candidates, not just the
attachment stage's status or an upload response saying success. Missing local
files, rejected uploads, and unconfirmed receipts stop expertise submission.
If there are no local attachment candidates, there is nothing to upload.
Errors identify `stage` (`baseClaim`, `damageCase`, or `attachments`) and preserve
vendor details. An attachment failure includes:
```json
{
"statusCode": 400,
"code": "FANAVARAN_ATTACHMENTS_INCOMPLETE",
"stage": "attachments",
"pendingFiles": [
{ "fileName": "image.jpg", "error": "Upload failure reason", "skipped": false }
]
}
```
Retrying resumes pending work. Even when expertise already exists, this API first
repairs missing prerequisites, then returns the existing expertise response/Id
without posting another expertise. Automatic final writes also check attachments.
+16
View File
@@ -25,6 +25,22 @@ expertise on this same claim, supply `?expertiseId=44237`. A missing saved
expertise ID without an explicit override returns 400. File and expertise IDs
must be positive safe integers.
Local validation errors return a stable `code`, a specific Persian message, and
the relevant field/product metadata. They do not collapse to the generic form
validation message:
| Code | Meaning |
|---|---|
| `FANAVARAN_LOCAL_CLAIM_ID_INVALID` | `claimCaseId` must be a local MongoDB ObjectId, not the numeric external claim ID |
| `FANAVARAN_HULL_CLAIM_REQUIRED` | The linked claim resolves to third-party; `actualProduct` and `expectedProduct` identify the mismatch |
| `FANAVARAN_HULL_CLAIM_NOT_SUBMITTED` | No external `claimId` is saved for the local claim |
| `FANAVARAN_HULL_EXPERTISE_ID_MISSING` | No expertise ID is saved and no override was supplied |
| `FANAVARAN_HULL_FILE_ID_INVALID` / `FANAVARAN_HULL_EXPERTISE_ID_INVALID` | The selected external ID is not a positive safe integer |
| `FANAVARAN_CLIENT_INVALID` | The requested tenant is unsupported |
Selecting `parsian` chooses the insurer; it does not change a third-party claim
into a hull claim. These VHUD routes intentionally reject third-party claims.
Every response wraps the unmodified vendor body in `data`, with `clientKey`,
`claimCaseId`, `claimId`, and the selected `fileId` or `expertiseId` when relevant: