Skip to main content

Documentation 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.

Budgets (presupuestos) represent construction projects in Sistema MRP. Each budget defines the financial envelope for a project and acts as the reference point for linking inventory records and requirements, calculating dispatched material costs, and tracking expenditure against plan.

What is a project?

A project is a Budget record in the database (models/budget.py). Its fields are:
FieldTypeDescription
namestringHuman-readable project name.
budget_solesfloatAllocated budget in Peruvian soles (S/.).
budget_dolaresfloatAllocated budget in US dollars ($).
notesstringOptional free-text description or scope notes.
is_activebooleanWhether the project is currently active.
is_finishedbooleanTrue after finish_budget() is called.
finished_atdatetimeTimestamp set when the project is finished; None otherwise.
created_atdatetimeWhen the project was created.
Both budget_soles and budget_dolares can be set independently. Projects can carry a soles-only budget, a dollars-only budget, or both simultaneously.

Creating a project

1

Open the registration form

On the Presupuestos page, expand the Registrar nuevo presupuesto section.
2

Enter the project name

Type a descriptive name in the Nombre del proyecto field (required). Example: Obra Residencial Norte 2025.
3

Set the budget amounts

Enter the allocated amount in Presupuesto (S/.) and/or Presupuesto ($). Both default to 0. At least one should be set to a positive value to enable budget-utilization tracking.
4

Add notes (optional)

Use the Notas field to record the project description, scope, or any relevant details.
5

Submit

Click Crear Presupuesto. The project is created immediately via create_budget() and appears in the project list.

Linking inventory and requirements to a project

Both the Inventory and Requirement models have a budget_id foreign key. When a client creates an inventory record in their principal warehouse or raises a requirement, they can associate it with a specific project by setting this field. This linkage is what determines which inventory records are frozen when a project is deleted, and which requirements are cancelled automatically. It also controls how dispatched materials are attributed to a project for cost tracking.

Tracking costs

get_dispatch_costs(db, since, until) in services/budget_service.py calculates material expenditure for a given time range. For each material that appears in any dispatch within the range, it computes:
total_cost_soles   = total_dispatched_qty × material.unit_price
total_cost_dolares = total_dispatched_qty × material.unit_price_dolares
The function returns a list of per-material cost records and two grand totals — one in soles and one in dollars. The Presupuestos page calls this function with since=bud.created_at to scope costs to each project’s lifetime. A progress bar on each project card shows how much of the soles and dollar budgets have been consumed. The bar turns amber above 70% utilization and red above 90%.
Material unit prices are configured on the Materiales page, not on the budget itself. If a material has no unit price set, its cost contribution shows as S/ 0.00. Make sure all materials used on a project have their unit_price and/or unit_price_dolares fields filled in.

Finishing a project

Clicking Finalizar obra on a project card calls finish_budget(db, budget_id), which:
b.is_finished = True
b.is_active   = False
b.finished_at = datetime.utcnow()
Before confirming, the UI compares the actual dispatch cost against the budget and shows whether the project ran over budget, under budget, or on target (separately for soles and dollars). A finished project remains visible in the list with a “Finalizado” badge and its completion date. A finished project can be reopened using the Reactivar button (see Reactivating a finished project).

Deleting a project

Clicking Eliminar on a project card triggers a confirmation prompt that also shows how many active inventory records are linked to the project. Confirming calls delete_budget(db, budget_id), which:
  1. Cancels all pending and partial requirements linked to the project (Requirement.budget_id == budget_id).
  2. Sets is_active = False on all linked Inventory records (freezing them).
  3. Deletes the Budget record.
Deleting a project freezes all inventory records linked to it (is_active = False). Frozen inventory can no longer be used for new requirements or dispatches until it is redirected to another project. Deletion is permanent and cannot be undone.
Frozen inventory records are not lost. The client can redirect them to a different active project from their Inventario Principal page, which restores the records to active status under the new project.

Reactivating a finished project

reactivate_budget(db, budget_id) reverses finish_budget:
b.is_finished = False
b.is_active   = True
b.finished_at = None
The Reactivar button appears only on projects where is_finished == True. After reactivation, the project returns to active status and can receive new requirements and inventory records.

Build docs developers (and LLMs) love