Planning API Reference
planning.serializers
Serializers for the planning application.
Handles the logic for setting category spending limits (auto-mapping to the current active budget) and calculating savings targets based on deadlines.
BudgetCategoryLimitSerializer
Bases: ModelSerializer
Serializer for establishing a category spending limit for the current month.
This serializer is specialized for 'Quick Planning' where the system automatically finds or creates the current month's budget container.
Source code in planning/serializers.py
Meta
create(validated_data)
Link the category limit to the current month's budget.
Automatically finds or creates a Budget instance for the current month/year and attaches the new limit to it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
validated_data
|
dict
|
Validated input data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BudgetCategoryLimit |
Created instance. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If a limit for the category already exists for the month. |
Source code in planning/serializers.py
validate_limit(value)
Ensure the limit provided is a positive number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Decimal
|
The input limit value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Decimal |
Validated limit. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the value is non-positive. |
Source code in planning/serializers.py
SavingsGoalSerializer
Bases: ModelSerializer
Serializer for savings goals with advanced planning metrics.
Computes 'monthly_savings_needed' based on the distance to the deadline and the remaining target amount.
Source code in planning/serializers.py
Meta
Metadata for SavingsGoalSerializer.
Source code in planning/serializers.py
get_monthly_savings_needed(obj)
Calculate the required monthly contribution to reach the goal by its deadline.
Returns:
| Name | Type | Description |
|---|---|---|
float |
Amount needed per month, or None if no deadline is set. |
Source code in planning/serializers.py
get_progress_percentage(obj)
Calculate the percentage completion of the savings goal.
Returns:
| Name | Type | Description |
|---|---|---|
float |
Percentage value rounded to 2 decimal places. |
Source code in planning/serializers.py
planning.views
Views for the planning application.
Provides simplified endpoints for setting quick budget limits and managing savings goals without navigating the full finance hierarchy.
BudgetLimitView
Bases: APIView
Shortcut view for creating a spending limit within the current month's budget.
This view simplifies the process by auto-calculating the budget period.
Source code in planning/views.py
post(request)
Create a new category limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The HTTP request containing 'category' and 'limit'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
Success confirmation or validation errors. |
Source code in planning/views.py
SavingsGoalView
Bases: APIView
View for listing and creating personal savings goals.
Source code in planning/views.py
get(request)
Fetch all goals for the user.
Returns:
| Name | Type | Description |
|---|---|---|
Response |
List of serialized savings goals. |
Source code in planning/views.py
post(request)
Create a new goal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The HTTP request containing goal details. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Response |
Created goal data or validation errors. |