Skip to content

Commit

Permalink
Refactor yearly forecast calculations to improve accuracy and clarity
Browse files Browse the repository at this point in the history
- Updated the `resolve_yearly_forecast` function to correctly handle actual revenue tracking for the current month, ensuring accurate goal calculations.
- Introduced a new variable `month_actual` to store realized revenue, enhancing the clarity of the calculations.
- Adjusted the logic for discount calculations to reflect the actual revenue, improving the reliability of the forecasting process.

These changes enhance the accuracy and reliability of yearly forecasting and revenue tracking.
  • Loading branch information
ElemarJR committed Jan 7, 2025
1 parent 386166b commit 18158f4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions backend/api/src/analytics/yearly_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ def resolve_yearly_forecast(_, info, year=None):
forecast_doi = compute_forecast(date_of_interest)

goal = main_goal / (13 - month)
month_actual = 0
if y < current_year or (y == current_year and m < current_month):
goal = 0
discount = forecast
#actual += revenue_tracking["total"] if (y != current_year or m != current_month) else 0

month_actual = forecast["summary"]["realized"]
discount = month_actual
actual += month_actual
elif y == current_year and m == current_month:
month_actual = forecast["summary"]["realized"]
# discount = month_actual
actual += month_actual


by_month.append({
Expand All @@ -51,10 +58,10 @@ def resolve_yearly_forecast(_, info, year=None):
"expected_squad_fee": forecast_doi["by_kind"]["squad"]['totals'].in_analysis,
"expected_hands_on_fee": forecast_doi["by_kind"]["hands_on"]['totals'].in_analysis,
"expected_consulting_pre_fee": forecast_doi["by_kind"]["consulting_pre"]['totals'].in_analysis,
"actual": revenue_tracking["total"] if revenue_tracking else 0
"actual": month_actual
})

#main_goal -= discount
main_goal -= discount


total_working_days = sum(len(get_working_days_in_month(y, m)) for m in range(1, 13))
Expand Down

0 comments on commit 18158f4

Please sign in to comment.