Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/MultiSas/llms.txt

Use this file to discover all available pages before exploring further.

A pharmacy sale records a product purchase transaction. When a sale is created, the API looks up the company and product, optionally links a registered client, calculates sub_total and total from the product price multiplied by the requested quantity, auto-generates a bill_counter, and snapshots the product’s batch data at the time of purchase. Two endpoints are available: create a sale and list all sales for a company with pagination.
All sale endpoints require two authentication middlewares. TokenAny validates the bearer token and attaches the user to the request. TokenAuthorize('Admin', 'Super Admin') restricts access to users whose role is either Admin or Super Admin. Include the token in every request as token-access: Bearer $TOKEN.

Create a Sale


POST /api/sale-pharmacy/:company_id/sale/:product_id Records a new pharmacy sale. quantity must be greater than zero. A client_id is optional — if provided, the client document is looked up and a snapshot is embedded in the sale record.

Path Parameters

company_id
string
required
The MongoDB ObjectId of the owning company.
product_id
string
required
The MongoDB ObjectId of the product being sold.

Body Parameters

quantity
number
required
Number of units being purchased. Must be greater than 0.
type_payment
string
required
Payment method for the sale. Must be one of: "Efectivo", "Tarjeta", "Transferencia". Defaults to "Efectivo".
client_id
string
Optional MongoDB ObjectId of a registered pharmacy client to associate with this sale.

Response Fields

msj
string
Human-readable result message.
status
boolean
true on success, false on failure.
save_sale
object
The newly created sale document.

Example

curl -X POST https://api.example.com/api/sale-pharmacy/64a1f2c3e4b0a1b2c3d4e5f6/sale/64h8i9j0k1l2m3n4o5p6q7r8 \
  -H "Content-Type: application/json" \
  -H "token-access: Bearer $TOKEN" \
  -d '{
    "quantity": 2,
    "type_payment": "Efectivo",
    "client_id": "64i9j0k1l2m3n4o5p6q7r8s9"
  }'
{
  "msj": "Venta realizada exitosamente",
  "status": true,
  "save_sale": {
    "_id": "64j0k1l2m3n4o5p6q7r8s9t0",
    "bill_counter": "SALE-0001",
    "company": "64a1f2c3e4b0a1b2c3d4e5f6",
    "type_payment": "Efectivo",
    "quantity": 2,
    "price": "5000",
    "sub_total": "10000",
    "total": "10000",
    "product": {
      "_id": "64h8i9j0k1l2m3n4o5p6q7r8",
      "bill_counter": "FAR-0001",
      "name_product": "Ibuprofeno 400mg",
      "category_product": "analgesicos",
      "unit_product": "caja",
      "price_product": "5000",
      "batch_product": [
        {
          "_id": "64h8i9j0k1l2m3n4o5p6q7r9",
          "lote": "LOT-2024-001",
          "expiration_date": "2026-06-30T00:00:00.000Z",
          "quantity": 100
        }
      ]
    },
    "client": {
      "_id": "64i9j0k1l2m3n4o5p6q7r8s9",
      "name_client": "Carlos Ramírez"
    },
    "createdAt": "2024-01-15T11:30:00.000Z",
    "updatedAt": "2024-01-15T11:30:00.000Z"
  }
}

List Sales


GET /api/sale-pharmacy/:company_id Returns a paginated list of all pharmacy sales for the specified company, sorted by most recently created.

Path Parameters

company_id
string
required
The MongoDB ObjectId of the company whose sales to retrieve.

Response Fields

msj
string
Human-readable result message.
status
boolean
true on success.
data
array
Array of sale documents for the company.
pagination
object
Pagination metadata.

Example

curl -X GET https://api.example.com/api/sale-pharmacy/64a1f2c3e4b0a1b2c3d4e5f6 \
  -H "Content-Type: application/json" \
  -H "token-access: Bearer $TOKEN"
{
  "msj": "Cargando ventas",
  "status": true,
  "data": [
    {
      "_id": "64j0k1l2m3n4o5p6q7r8s9t0",
      "bill_counter": "SALE-0001",
      "company": "64a1f2c3e4b0a1b2c3d4e5f6",
      "type_payment": "Efectivo",
      "quantity": 2,
      "price": "5000",
      "sub_total": "10000",
      "total": "10000",
      "product": {
        "_id": "64h8i9j0k1l2m3n4o5p6q7r8",
        "bill_counter": "FAR-0001",
        "name_product": "Ibuprofeno 400mg",
        "category_product": "analgesicos",
        "unit_product": "caja",
        "price_product": "5000",
        "batch_product": [
          {
            "_id": "64h8i9j0k1l2m3n4o5p6q7r9",
            "lote": "LOT-2024-001",
            "expiration_date": "2026-06-30T00:00:00.000Z",
            "quantity": 100
          }
        ]
      },
      "client": {
        "_id": "64i9j0k1l2m3n4o5p6q7r8s9",
        "name_client": "Carlos Ramírez"
      },
      "createdAt": "2024-01-15T11:30:00.000Z",
      "updatedAt": "2024-01-15T11:30:00.000Z"
    }
  ],
  "pagination": {
    "pag": "1",
    "perpage": 10,
    "pags": 1
  }
}

Build docs developers (and LLMs) love