Skip to content

[BB-6629] Automatically set budgets for billable accounts

Description

Implements changes necessary to complete #57 (closed). It introduces the following changes into the application

  1. Creates a relationship between sustainability Account and Budget objects, by replacing the name attribute with account foreign key attribute
  2. Adds a custom migration that will link existing Budget objects with their respective Account objects by using the name attribute of the Budget and the Account models as the common factor.
  3. Introduces a new endpoint at /sustainability/populate_budgets/ which can be used to start the background task via a HTTP POST request

Assumptions

  • The existing Account names are unique.
  • Each budget item will be linked to an account such that budget.name == account.name. If an account doesn't exist with the name of the budget, then a new account is created with that name and then linked

Testing instructions

  • Run the migrations using make dev.migrate
  • Trigger the task by sending a post request using Swagger to /sustainability/populate_budgets/
  • Running the celery task should create budgets for all the billable account for the previous month which can be verified at the admin URL /admin/sustainability/budget/
Edited by Arunmozhi P

Merge request reports