The budget service manages the project layer of Sistema MRP. Each project (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.
Budget) defines cost targets in both soles and dollars and acts as the grouping key for inventory records, requirements, and dispatches. Deleting a project cascades: pending requirements are cancelled, their stock reservations are released, and all linked inventory records are frozen. Cost reporting aggregates dispatch quantities multiplied by material unit prices, giving a real-time view of spending versus budget for every project.
create_budget
budget_soles or budget_dolares are clamped to 0.0.
Active SQLAlchemy session. Commits internally.
Project name displayed throughout the application.
Cost target in Peruvian soles. Clamped to
0.0 if negative or None.Cost target in US dollars. Clamped to
0.0 if negative or None.Optional free-text notes for the project.
The newly created and refreshed
Budget ORM object.get_budgets
created_at descending. No filtering or pagination is applied.
Active SQLAlchemy session.
List of all
Budget ORM objects, newest first.update_budget
None is skipped, leaving the current value unchanged. Negative numeric values are clamped to 0.0.
Active SQLAlchemy session. Commits internally.
ID of the project to update.
New project name. Pass
None to leave unchanged.Updated target in soles. Clamped to
0.0 if negative.Updated target in dollars. Clamped to
0.0 if negative.Updated notes text.
Set project active or inactive.
True when the project was found and updated; False when not found.delete_budget
- Cancels all requirements with status
pendingorpartialthat are linked to this project (viacancel_requirement, which also releases their stock reservations). - Freezes all inventory records linked to the project by setting
is_active=False. - Deletes the
Budgetrecord.
Active SQLAlchemy session. Commits internally at the end.
ID of the project to delete.
True when the project was found and deleted; False when not found.Number of requirements that were cancelled as part of the deletion.
0 when the project was not found.finish_budget
is_finished=True, is_active=False, and finished_at=datetime.utcnow(). A finished project’s inventory and history remain intact and visible; it is simply no longer accepting new requirements or dispatches.
Active SQLAlchemy session. Commits internally.
ID of the project to finish.
True when the project was found and marked finished; False otherwise.reactivate_budget
finish_budget call. Sets is_finished=False, is_active=True, and clears finished_at. Does not restore frozen inventory records — those must be redirected or unfrozen separately via the inventory service.
Active SQLAlchemy session. Commits internally.
ID of the finished project to reactivate.
True when the project was found and reactivated; False otherwise.get_dispatch_costs
total_qty × unit_price. Results are sorted by total_cost descending. Optionally filtered by Dispatch.dispatch_date.
Active SQLAlchemy session.
Return only dispatches on or after this datetime.
Return only dispatches on or before this datetime.
List of dicts, one per material, sorted by
total_cost descending.Sum of all
total_cost values (grand total in soles).Sum of all
total_cost_dolares values (grand total in dollars).get_all_projects_cost_summary
created_at date. This function calls get_dispatch_costs once per budget, so performance scales linearly with the number of projects.
Active SQLAlchemy session.
List of dicts, one per project.