Overweight Refund API
API used by the Overweights screen to accept or reject overweight refund tickets. Only the payload addition for this change is described; the rest of the endpoint behavior remains as before.
PUT /overweights/ticket/
Updates the ticket status (accept or reject) for an overweight record. On accept, it applies the refund (balance, surcharge, compensation) and sends the client notification.
Authentication
- Strategy:
token_admin
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | number | Yes | Overweight record id (surcharge id for the overweight charge). |
Payload
| Field | Type | Required | Description |
|---|---|---|---|
| ticket_id | number | Yes | Company ticket id. |
| status_id | number | Yes | 2 = Accepted, 3 = Rejected. |
| comments | string | Yes | Comment for the ticket (e.g. review comment). |
| approved_amount | number | No | Refund amount to apply when accepting. When present: must be > 0 and <= the original overweight surcharge amount. If omitted on accept, the surcharge amount is used. Ignored when status_id is Rejected. |
Request example (accept with optional amount)
json
{
"ticket_id": 12345,
"status_id": 2,
"comments": "Refund approved.",
"approved_amount": 150.50
}Omit approved_amount to use the full surcharge amount.
Validation (backend)
ticket_id: required, number.status_id: required, number.comments: required, string.approved_amount: optional, number. If sent:- Must be greater than 0.
- Must not exceed the original overweight surcharge amount (surcharge loaded by path param
id).
- When ticket is already closed (status 2 or 3): 400 "Ticket already close."
- When ticket not found: 400 "Ticket not found."
Success response
- Status: 200
- Body:
{ "data": true }
Error responses
| Status | Condition |
|---|---|
| 400 | Ticket not found, ticket already closed, or invalid/forbidden approved_amount. |
| 401 | Missing or invalid auth. |
| 404 | Surcharge not found (from path id) when processing accept. |
Behavior summary
- Reject (
status_id === 3): Ticket and comment/history updated; no balance change, no compensation, no notification. - Accept (
status_id === 2) and ticket type overweight:- Refund amount =
approved_amountif provided and valid, else surcharge amount. - Balance updated (credit), new surcharge row (type 2 refund), compensation row created, ticket/comment/history updated, WhatsApp notification sent.
- Refund amount =
