A dispatch converts reserved stock into an actual outbound movement. It takes one or more items from a requirement that has reserved stock, decrements bothDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElthonJohan/Sistema-MRP/llms.txt
Use this file to discover all available pages before exploring further.
stock and reserved in the principal warehouse, records an OUT movement, and generates a numbered Guía de Remisión document.
Creating a dispatch from a requirement
Only requirements with statuspending or partial that have at least one item with reserved stock appear in the dispatch selector. To generate a dispatch:
Select the requirement
Choose a requirement from the Selecciona requerimiento dropdown. The list shows requirement ID, creation date (Lima time), and current status.
Review the items
Each item with pending quantity is shown with its available-to-dispatch amount. Adjust quantities if you want a partial dispatch (minimum 1, maximum remaining pending quantity per item).
Dispatch validation
create_dispatch() runs a two-phase approach: it validates everything before touching the database.
For each item in the dispatch request it checks:
- Quantity does not exceed pending amount —
qty <= (requested_qty - fulfilled_qty). - Item has reserved stock —
req_item.status != "pending". Items still inpendingcannot be dispatched. - Principal warehouse has enough physical stock —
sum(inv.stock) >= qtyacross all inventory records for that material.
What happens on dispatch
Once validation passes,create_dispatch() applies all changes atomically in a single db.commit():
- Stock decremented —
Inventory.stock -= qtydistributed FIFO across budget records. - Reserved decremented —
Inventory.reserved -= qtydistributed FIFO across budget records. - OUT movement logged —
Movement(movement_type="OUT", reference_type="dispatch", reference_id=dispatch.id). - RequirementItem updated —
fulfilled_qty += qty; status becomesfulfilledif fully dispatched,partialotherwise. - Requirement status updated —
fulfilledif all items are now fully dispatched,partialif any remain.
Guía de Remisión
Each dispatch receives a unique Guía de Remisión number assigned at creation time:The guia number format is
GR-YYYYMMDD-{dispatch_id:05d}, for example GR-20260518-00042. The date component is derived from datetime.utcnow() at the time of dispatch creation. The PDF is generated by utils/pdf_generator.py (using fpdf2) and saved to storage/guides/<guia_number>.pdf.Cancelling a dispatch
Click the 🗑 button in the dispatch history and confirm the deletion prompt.delete_dispatch() reverses all inventory changes:
- Returns
qtytoInventory.stockandInventory.reservedin the principal warehouse. - Resets
RequirementItem.fulfilled_qtyand status accordingly. - Deletes any associated receipt if one had been created.
- Removes the
OUTmovement records for the dispatch.