Sales
1. Get Sales
Request
- Method:
GET
- Endpoint:
/api/sales
- Parameters:
filter
(optional): Filter sales by client name, last name, or DNI.skip
(optional): Number of records to skip.limit
(optional): Maximum number of records to retrieve.orderBy
(optional): Property by which to order the results (e.g., “date”, “total”).desc
(optional): Set to true for descending order, false or omit for ascending order.
Example
Response
2. Get Sale by ID
Request
- Method:
GET
- Endpoint:
/api/sales/{Id}
Example
Response
3. Add Sale
Request
- Method:
POST
- Endpoint:
/api/sales
- Body:
idClient
(required): ID of the client for the sale.concepts
(required): List of concepts for the sale, includingquantity
,unitaryPrice
,import
,idProduct
.
Example
Response
5. Update Sale
Request
- Method:
PATCH
- Endpoint:
/api/sales
- Body:
id
(required): ID of the sale to update.- Additional fields (optional): Updated values for
idClient
,concepts
.
Example
Response
6. Delete Sale (Logic)
Request
- Method:
DELETE
- Endpoint:
/api/sales/{Id}
- Parameters:
Id
(required): ID of the sale to delete.
Example
Response
7. Full Delete Sale
Request
- Method:
DELETE
- Endpoint:
/api/sales/fulldelete/{Id}
- Parameters:
Id
(required): ID of the sale to fully delete.
Example
Response
Pagination and Filtering in Get Sales
When using the Get Sales
endpoint, you can apply
pagination and filtering to retrieve specific sets of data.
Pagination
- Use the
skip
parameter to skip a certain number of records. - Use the
limit
parameter to set the maximum number of records to retrieve.
Example:
This will skip the first 10 records and retrieve the next 5 records.
Filtering
- Use the
filter
parameter to filter users by client name, client last name, date, or product name. - Use the
orderBy
parameter to specify the property by which to order the results (date, client name or last name and total price). - Use the
desc
parameter to set the order as descending (1) for descending order.
Example:
This will filter sales with the client last name “Doe” and order the results by the date in descending order.
Data Model
Sale
Attribute | Type | Description |
---|---|---|
id | Long | ID of the sale |
idClient | Long | ID of the client for the sale. |
concepts | List | List of concepts for the sale. |
date | DateTime | Date of the sale. |
total | Decimal | Total amount of the sale. |
state | Byte | State of the sale. |
Concept
Attribute | Type | Description |
---|---|---|
id | Long | ID |
quantity | Int | Quantity of the product in the concept. |
unitaryPrice | Decimal | Unitary price of the product in the concept. |
import | Decimal | Total import of the concept. |
idProduct | Long | ID of the product in the concept. |
state | Byte | State of the concept. |
Validations
- idClient: Must be a positive integer and exist in the database.
- concepts: Must have at least one concept with valid data.
- quantity: Must be a positive integer.
- unitaryPrice: Must be a positive decimal.
- import: Must be a positive decimal.
- idProduct: Must be a positive integer, exist in the database and have the requested stock.
- state: Must be a byte value.