Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/YonAnn99/Acrylitec/llms.txt

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

The Materiales model is Acrylitec’s source of truth for your physical acrylic sheet inventory. Each record describes a specific sheet by its dimensions and tracks how many units are currently in stock alongside the minimum level below which the business needs to reorder. Because every POS sale references a material and decrements its stock automatically, the inventory stays in sync with the shop floor without requiring manual counts after every order.

Material Fields

The following fields are defined on the Materiales model:
FieldTypeDescription
descripcionCharField (max 100)Material name or description, e.g. Acrílico 3mm transparente
largoDecimalFieldSheet length in centimetres
anchoDecimalFieldSheet width in centimetres
stock_actualIntegerFieldCurrent number of units available in the warehouse
stock_minimoIntegerFieldMinimum acceptable stock level; alerts fire when stock_actual <= stock_minimo

Searching Materials

The material list at GET /materiales/ accepts an optional q query parameter. When provided, the view filters the queryset by the descripcion field using a case-insensitive icontains lookup:
materiales = Materiales.objects.all()
if query:
    materiales = materiales.filter(descripcion__icontains=query)
Example: GET /materiales/?q=3mm returns every material whose description contains “3mm” (case-insensitive), such as Acrílico 3mm transparente or 3mm negro. To clear the filter and see all materials, navigate to /materiales/ without the q parameter.

Low-Stock Alerts

The lista_materiales view calculates materiales_bajos — a count of all materials whose stock_actual is at or below their stock_minimo:
materiales_bajos = sum(1 for m in materiales if m.stock_actual <= m.stock_minimo)
This count is passed to the template and displayed as a banner alert at the top of /materiales/. Individual rows in the table are highlighted in amber and marked with a ⚠️ Stock bajo badge, or in red with a Sin stock badge if stock_actual is zero.

Creating a Material

1

Open the creation form

Navigate to /materiales/nuevo/. The form is rendered by the crear_material view.
2

Fill in the sheet details

The form requires the following fields, which map directly to model fields:
Form fieldModel fieldNotes
descripciondescripcionText description of the sheet
largolargoLength in cm (decimal accepted)
anchoanchoWidth in cm (decimal accepted)
stockstock_actualStarting stock count
stock_minimostock_minimoAlert threshold
Note that the HTML input for current stock uses the name stock (not stock_actual). The view maps it correctly: stock_actual=request.POST.get('stock').
3

Submit

Click Guardar en Base de Datos. The view calls Materiales.objects.create(...) with the submitted values and redirects to /materiales/.

Deleting a Material

Deletion follows a two-step confirmation flow handled by the eliminar_material view at /materiales/eliminar/<id>/:
1

Visit the confirmation page (GET)

Navigate to GET /materiales/eliminar/<id>/. The view counts how many Cotizaciones and DetalleVenta rows reference this material and renders a confirmation page showing those counts.
2

Confirm deletion (POST)

Submitting the confirmation form sends POST /materiales/eliminar/<id>/. If any linked records exist, deletion is blocked and an error message is shown:
No se puede eliminar "Acrílico 3mm transparente":
tiene 3 cotización(es) y 2 venta(s) asociadas.
If no references exist, material.delete() is called and a success message is displayed.
Deleting a material that is referenced by existing quotes (Cotizaciones) or sale line items (DetalleVenta) is blocked. You must delete or reassign those records first before the material can be removed.

Automatic Stock Deduction

When a new POS order is confirmed at POST /pedidos/nuevo/, the nuevo_pedido view iterates over every item in the cart. For each DetalleVenta item it creates, it decrements the corresponding material’s stock_actual by the ordered cantidad, flooring at zero to prevent negative stock:
material.stock_actual = max(0, material.stock_actual - cantidad)
material.save(update_fields=['stock_actual'])
Using update_fields=['stock_actual'] ensures only the stock column is written, avoiding accidental overwrites of other fields.

Low-Stock Alerts on Sale

After all cart items are processed, the POS endpoint collects any material that has fallen to or below its minimum threshold and returns them in the alertas_stock array of the JSON response:
{
  "ok": true,
  "venta_id": 15,
  "alertas_stock": [
    { "nombre": "Acrílico 3mm transparente", "actual": 2, "minimo": 5 }
  ]
}
The POS front end reads this array and can surface a warning to the operator immediately after the sale is recorded — without requiring a separate trip to the materials list. An empty alertas_stock array means all materials remain above their minimum thresholds.

Build docs developers (and LLMs) love