Skip to main content

Standard Recipes

The Standard Recipes API allows you to manage product recipes that define which raw materials are needed to produce each product. Each standard recipe consists of a header (cabecera) and details (detalles) that specify the ingredients and quantities.

Endpoints

POST /api/pos/estandar

Create a new standard recipe with header and details.
prd_codigo
string
required
Product code this recipe is for
est_descripcion
string
required
Recipe description
detalles
array
required
Array of recipe detail objects containing raw materials
detalles[].mp_codigo
string
required
Raw material code
detalles[].cantidad
number
required
Quantity of raw material needed

Response

est_cod
string
Generated standard recipe code
message
string
Success message
cURL
curl -X POST "http://localhost:3000/api/pos/estandar" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prd_codigo": "PRD001",
    "est_descripcion": "Pizza Margherita Standard Recipe",
    "detalles": [
      {
        "mp_codigo": "MP001",
        "cantidad": 0.25
      },
      {
        "mp_codigo": "MP002",
        "cantidad": 0.15
      }
    ]
  }'
{
  "est_cod": "EST001",
  "message": "Estandar creado exitosamente"
}

GET /api/pos/estandar

Get all standard recipes with pagination.
page
number
Page number for pagination (default: 1)

Response

data
array
Array of standard recipe objects with headers and details
cURL
curl -X GET "http://localhost:3000/api/pos/estandar?page=1" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "data": [
    {
      "est_cod": "EST001",
      "prd_codigo": "PRD001",
      "prd_nombre": "Pizza Margherita",
      "est_descripcion": "Pizza Margherita Standard Recipe",
      "est_estado": "PEN",
      "detalles": [
        {
          "mp_codigo": "MP001",
          "mp_descripcion": "Mozzarella Cheese",
          "cantidad": 0.25,
          "unidad_medida": "KG"
        },
        {
          "mp_codigo": "MP002",
          "mp_descripcion": "Tomato Sauce",
          "cantidad": 0.15,
          "unidad_medida": "LT"
        }
      ]
    }
  ]
}

GET /api/pos/estandar/:est_cod

Get a specific standard recipe by code.
est_cod
string
required
Standard recipe code

Response

recipe
object
Standard recipe object with header and details
cURL
curl -X GET "http://localhost:3000/api/pos/estandar/EST001" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "est_cod": "EST001",
  "prd_codigo": "PRD001",
  "prd_nombre": "Pizza Margherita",
  "est_descripcion": "Pizza Margherita Standard Recipe",
  "est_estado": "APR",
  "detalles": [
    {
      "mp_codigo": "MP001",
      "mp_descripcion": "Mozzarella Cheese",
      "cantidad": 0.25,
      "unidad_medida": "KG",
      "costo_unitario": 8.50
    }
  ]
}

GET /api/pos/estandar/product/:prd_codigo

Get all standard recipes for a specific product.
prd_codigo
string
required
Product code

Response

data
array
Array of standard recipes for the product
cURL
curl -X GET "http://localhost:3000/api/pos/estandar/product/PRD001" \
  -H "Authorization: Bearer YOUR_TOKEN"
[
  {
    "est_cod": "EST001",
    "est_descripcion": "Pizza Margherita Standard Recipe",
    "est_estado": "APR",
    "prd_codigo": "PRD001"
  }
]

PUT /api/pos/estandar/:est_cod/detalle

Add or update recipe details for a standard recipe.
est_cod
string
required
Standard recipe code
detalles
array
required
Array of detail objects to upsert
detalles[].mp_codigo
string
required
Raw material code
detalles[].cantidad
number
required
Quantity of raw material needed

Response

message
string
Success message
cURL
curl -X PUT "http://localhost:3000/api/pos/estandar/EST001/detalle" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "detalles": [
      {
        "mp_codigo": "MP003",
        "cantidad": 0.05
      }
    ]
  }'
{
  "message": "Detalle agregado"
}

DELETE /api/pos/estandar/:est_cod/detalle

Delete specific recipe details from a standard recipe.
est_cod
string
required
Standard recipe code
materiasprimas
array
required
Array of raw material codes to delete

Response

message
string
Success message with count of deleted records
cURL
curl -X DELETE "http://localhost:3000/api/pos/estandar/EST001/detalle" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "materiasprimas": ["MP003", "MP004"]
  }'
{
  "message": "Detalle eliminado 2 registros"
}

PUT /api/pos/estandar/:est_cod/aprobar

Approve a standard recipe header.
est_cod
string
required
Standard recipe code to approve

Response

message
string
Success message
cURL
curl -X PUT "http://localhost:3000/api/pos/estandar/EST001/aprobar" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "Estandar aprobado exitosamente"
}

PUT /api/pos/estandar/:est_cod/anular

Cancel/annul a standard recipe header.
est_cod
string
required
Standard recipe code to cancel

Response

message
string
Success message
cURL
curl -X PUT "http://localhost:3000/api/pos/estandar/EST001/anular" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "message": "Estandar anulado exitosamente"
}

Build docs developers (and LLMs) love