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.Unique identifier for the return
ID of the original sale transaction
ID of the client making the return
Timestamp when the return was created (auto-generated)
Reason for the return
ID of the user who processed the return
Total amount refunded (sum of all line items)
DetalleDevolucion (Customer Return Line Item)
Individual items returned in a customer return.Unique identifier for the line item
ID of the parent return transaction
ID of the product being returned
Quantity of items being returned
Price per unit at the time of original sale
Calculated as
cantidad * precio_unitario (read-only property)DevolucionCompra (Supplier Return)
Return of items to a supplier (e.g., defective products).Unique identifier for the supplier return
ID of the original purchase transaction
ID of the supplier receiving the return
ID of the user who processed the return
Reason for returning items to supplier
Timestamp when the return was created (defaults to current time)
Total value of items returned to supplier
DetalleDevolucionCompra (Supplier Return Line Item)
Individual items returned to a supplier.Unique identifier for the line item
ID of the parent supplier return transaction
ID of the product being returned to supplier
Quantity of items being returned
Price per unit at the time of original purchase
Customer Return Endpoints
Create Customer Return
Process a customer return and refund.ID of the original sale transaction
ID of the client making the return
Reason for the return
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.Filter returns from this date (YYYY-MM-DD)
Filter returns until this date (YYYY-MM-DD)
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.ID of the original purchase transaction
ID of the supplier
Reason for returning items (e.g., “Productos defectuosos”, “Error en pedido”)
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