Skip to main content

Update Lab Visit Invoice (v1)

Method & Path

PUT /api/v1/{workspaceId}/labs/visits/{labVisitId}/invoice

Description

Update the invoice items, discount, and notes for a lab visit. Updates remain editable even after transfer.

note

Backend route: /:workspaceId/labs/visits/:labVisitId/invoice

Authentication

Required: Workspace Owner or Staff with labs.run.

Headers

  • Authorization: Bearer <token>
  • Content-Type: application/json

Path Parameters

NameTypeRequiredDescription
workspaceIdstringنعمWorkspace ID
labVisitIdstringنعمLab visit ID

Request Body

{
"items": [
{
"id": "item-1",
"description": "CBC",
"quantity": 1,
"unitPrice": 20
},
{
"description": "Manual item",
"quantity": 2,
"unitPrice": 15
}
],
"discount": 5,
"discountType": "fixed",
"notes": "خصم خاص للعميل"
}

Response 200 OK

{
"labVisit": {
"id": "64f1a0a6a2d4f3c8b6f9a123",
"labVisitStatus": "pending",
"labVisitInvoice": {
"items": [
{
"id": "item-1",
"description": "CBC",
"quantity": 1,
"unitPrice": 20,
"total": 20
}
],
"subtotal": 20,
"discount": 5,
"discountType": "fixed",
"total": 15,
"currency": "USD",
"notes": "خصم خاص للعميل",
"createdAt": "2024-01-01T10:00:00.000Z",
"updatedAt": "2024-01-01T11:00:00.000Z"
},
"linkedClientInvoiceId": "64f1a0a6a2d4f3c8b6f9a777"
},
"invoice": {
"items": [
{
"id": "item-1",
"description": "CBC",
"quantity": 1,
"unitPrice": 20,
"total": 20
}
],
"subtotal": 20,
"discount": 5,
"discountType": "fixed",
"total": 15,
"currency": "USD",
"notes": "خصم خاص للعميل",
"createdAt": "2024-01-01T10:00:00.000Z",
"updatedAt": "2024-01-01T11:00:00.000Z"
}
}

Common Errors

  • 400 Bad Request: Invalid identifiers or parameters.
  • 401 Unauthorized: Missing/invalid auth token.
  • 403 Forbidden: Staff lacks labs.run.
  • 404 Not Found: Visit not found.
  • 422 Unprocessable Entity: Validation failed (items empty, invalid amounts, etc).
  • 500 Internal Server Error: Unexpected error.