Skip to content

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

NameTypeRequiredDescription
idnumberYesOverweight record id (surcharge id for the overweight charge).

Payload

FieldTypeRequiredDescription
ticket_idnumberYesCompany ticket id.
status_idnumberYes2 = Accepted, 3 = Rejected.
commentsstringYesComment for the ticket (e.g. review comment).
approved_amountnumberNoRefund 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

StatusCondition
400Ticket not found, ticket already closed, or invalid/forbidden approved_amount.
401Missing or invalid auth.
404Surcharge 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:
    1. Refund amount = approved_amount if provided and valid, else surcharge amount.
    2. Balance updated (credit), new surcharge row (type 2 refund), compensation row created, ticket/comment/history updated, WhatsApp notification sent.

Envia Admin