[BB-6629] Automatically set budgets for billable accounts
Description
Implements changes necessary to complete #57 (closed). It introduces the following changes into the application
- Creates a relationship between sustainability
Account
andBudget
objects, by replacing thename
attribute withaccount
foreign key attribute - Adds a custom migration that will link existing
Budget
objects with their respectiveAccount
objects by using thename
attribute of theBudget
and theAccount
models as the common factor. - 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 anaccount
such thatbudget.name == account.name
. If an account doesn't exist with the name of thebudget
, 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