The requirement service sits at the top of the MRP demand chain. When a work-site warehouse needs materials, a requirement is created here. The service immediately attempts to reserve matching stock in the principal warehouse, marking each line itemDocumentation 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.
reserved if stock is available or pending if not. Pending items are retried automatically whenever add_stock is called through reprocess_requirements. A requirement only advances to fulfilled or partial once a dispatch is created against it.
create_requirement
budget_id is provided, then attempts to reserve stock for each line item in a single transaction. Each RequirementItem receives status reserved or pending depending on whether stock was available.
budget_id is mandatory. Omitting it or passing None returns (False, "Debes seleccionar un proyecto. El proyecto es obligatorio.") without creating any record.Active SQLAlchemy session. The caller opens and closes the session.
ID of the work-site (
obra) warehouse making the request.List of material–quantity pairs to request.
ID of the project this requirement belongs to. The project must exist. Passing
None causes an early return with an error message.True when the requirement was created successfully.Human-readable message. On success:
"Requerimiento creado exitosamente". On failure: a descriptive error string (e.g. missing warehouse, missing project).get_requirements
created_at descending. All filter parameters are optional; omitting them returns all requirements.
Active SQLAlchemy session.
Number of records to skip. Use
0 for the first page.Maximum number of records to return per page.
Filter to a single requirement by ID.
Filter by status. Accepted values:
"pending", "partial", "fulfilled", "cancelled".Return only requirements created on or after this date.
Return only requirements created on or before this date.
List of obra warehouse IDs to filter by. When
None, requirements from all warehouses are returned.List of
Requirement ORM objects for the requested page.Total count of matching requirements before pagination, useful for building page controls.
cancel_requirement
reserved stock back to available inventory. For each line item with status reserved, release_reservation is called against the principal warehouse. The requirement status is set to cancelled. Returns False when the requirement does not exist.
Active SQLAlchemy session. Commits internally via
release_reservation.ID of the requirement to cancel.
Optional free-text reason stored in
Requirement.notes.True when the requirement was found and cancelled; False otherwise.reprocess_requirements
pending or partial and attempts to reserve stock for any line items still in pending state. This function is called automatically by add_stock after new stock is committed; it should rarely need to be called directly.
For each requirement, if all items transition to reserved or fulfilled during this pass, the requirement is added to the returned list so the caller can notify interested parties. The parent requirement status (pending/partial) does not change here—only a successful dispatch changes it to fulfilled.
Active SQLAlchemy session. Commits at the end of processing.
List of
Requirement ORM objects that had at least one pending item and are now fully reserved (all items reserved or fulfilled). Empty when no requirements reached that state.