Overview
The Returns API allows you to process customer returns (refunds) and supplier returns (returning defective items to suppliers). Returns automatically adjust inventory levels and maintain detailed transaction history.Models
Devolucion (Customer Return)
Customer return from a sale transaction.integer
Unique identifier for the return
integer
ID of the original sale transaction
integer
ID of the client making the return
datetime
Timestamp when the return was created (auto-generated)
string
Reason for the return
integer
ID of the user who processed the return
decimal
Total amount refunded (sum of all line items)
DetalleDevolucion (Customer Return Line Item)
Individual items returned in a customer return.integer
Unique identifier for the line item
integer
ID of the parent return transaction
integer
ID of the product being returned
integer
Quantity of items being returned
decimal
Price per unit at the time of original sale
decimal
Calculated as
cantidad * precio_unitario (read-only property)DevolucionCompra (Supplier Return)
Return of items to a supplier (e.g., defective products).integer
Unique identifier for the supplier return
integer
ID of the original purchase transaction
integer
ID of the supplier receiving the return
integer
ID of the user who processed the return
string
Reason for returning items to supplier
datetime
Timestamp when the return was created (defaults to current time)
decimal
Total value of items returned to supplier
DetalleDevolucionCompra (Supplier Return Line Item)
Individual items returned to a supplier.integer
Unique identifier for the line item
integer
ID of the parent supplier return transaction
integer
ID of the product being returned to supplier
integer
Quantity of items being returned
decimal
Price per unit at the time of original purchase
Customer Return Endpoints
Create Customer Return
Process a customer return and refund.integer
required
ID of the original sale transaction
integer
required
ID of the client making the return
string
Reason for the return
array
required
Array of products being returned, each containing:
producto_id(integer): Product IDcantidad(integer): Quantity to returnprecio_unitario(decimal): Original unit price
List Customer Returns
Retrieve all customer returns for the current user.date
Filter returns from this date (YYYY-MM-DD)
date
Filter returns until this date (YYYY-MM-DD)
integer
Filter by client ID
Get Customer Return Details
Retrieve details of a specific customer return.Supplier Return Endpoints
Create Supplier Return
Return defective or incorrect items to a supplier.integer
required
ID of the original purchase transaction
integer
ID of the supplier
string
Reason for returning items (e.g., “Productos defectuosos”, “Error en pedido”)
array
required
Array of products being returned to supplier
List Supplier Returns
Retrieve all supplier returns for the current user.Stock Impact
Returns automatically adjust product inventory: Customer Returns (Devoluciones):- When a customer return is created, stock is increased by the returned quantity
- Products are available for resale
- When items are returned to a supplier, stock is decreased by the returned quantity
- Products are removed from available inventory
Permissions
Admin
- Create customer returns
- Create supplier returns
- View all returns
- Delete returns
Vendedor
- Create customer returns
- View returns they created
- Cannot create supplier returns
- Cannot delete returns
Business Rules
-
Customer Returns:
- Must reference a valid sale transaction
- Cannot return more items than were originally sold
- Stock is automatically restored upon return
- Total refund amount is calculated from line items
-
Supplier Returns:
- Must reference a valid purchase transaction
- Reduces available inventory
- Typically used for defective items or shipping errors
-
Deletion Protection:
- Returns use
SET_NULLfor sale references (allows sale deletion) - Returns use
PROTECTfor client and product references (prevents deletion) - Supplier returns use
CASCADEfor purchase (deleted if purchase is deleted)
- Returns use
Related Endpoints
- Sales API - Original sale transactions for customer returns
- Purchases API - Original purchase transactions for supplier returns
- Products API - Product inventory affected by returns
Example: Complete Return Workflow
1
Customer Contacts You
Customer reports a defective product from sale #123
2
Verify Original Sale
3
Process Return
4
Verify Stock Update
5
Issue Refund
Process the financial refund to the customer based on
total_devuelto