Commit
·
4b9447f
1
Parent(s):
dfe0ed3
Add debug logging to track budget_amount usage and ensure user-provided amount is used
Browse files
app/smart_recommendation.py
CHANGED
|
@@ -375,16 +375,21 @@ class SmartBudgetRecommender:
|
|
| 375 |
|
| 376 |
# PRIORITY: Use provided budget_amount if available, otherwise use budget's maxAmount
|
| 377 |
# IMPORTANT: If user provided budget_amount, use it as the base for recommendation
|
|
|
|
| 378 |
if budget_amount is None or budget_amount <= 0:
|
| 379 |
budget_max_amount = float(budget_by_id.get("maxAmount", 0) or 0)
|
| 380 |
budget_spend_amount = float(budget_by_id.get("spendAmount", 0) or 0)
|
| 381 |
budget_amount = budget_spend_amount if budget_spend_amount > 0 else budget_max_amount
|
|
|
|
|
|
|
|
|
|
| 382 |
|
| 383 |
# If we have a valid budget amount, generate recommendation
|
| 384 |
if budget_amount and budget_amount > 0:
|
| 385 |
# CRITICAL: Use the provided budget_amount as average_expense
|
| 386 |
# This is what the user wants to set, so recommendations should be based on this
|
| 387 |
avg_expense = budget_amount
|
|
|
|
| 388 |
monthly_values = [avg_expense]
|
| 389 |
std_dev = avg_expense * 0.05
|
| 390 |
months_analyzed = 1
|
|
|
|
| 375 |
|
| 376 |
# PRIORITY: Use provided budget_amount if available, otherwise use budget's maxAmount
|
| 377 |
# IMPORTANT: If user provided budget_amount, use it as the base for recommendation
|
| 378 |
+
original_budget_amount = budget_amount # Store original for logging
|
| 379 |
if budget_amount is None or budget_amount <= 0:
|
| 380 |
budget_max_amount = float(budget_by_id.get("maxAmount", 0) or 0)
|
| 381 |
budget_spend_amount = float(budget_by_id.get("spendAmount", 0) or 0)
|
| 382 |
budget_amount = budget_spend_amount if budget_spend_amount > 0 else budget_max_amount
|
| 383 |
+
print(f"📊 Using budget's maxAmount/spendAmount: {budget_amount:,.2f} (user did not provide budget_amount)")
|
| 384 |
+
else:
|
| 385 |
+
print(f"✅ Using user-provided budget_amount: {budget_amount:,.2f} (ignoring budget's maxAmount)")
|
| 386 |
|
| 387 |
# If we have a valid budget amount, generate recommendation
|
| 388 |
if budget_amount and budget_amount > 0:
|
| 389 |
# CRITICAL: Use the provided budget_amount as average_expense
|
| 390 |
# This is what the user wants to set, so recommendations should be based on this
|
| 391 |
avg_expense = budget_amount
|
| 392 |
+
print(f"💰 Setting average_expense = {avg_expense:,.2f} (from user's budget_amount)")
|
| 393 |
monthly_values = [avg_expense]
|
| 394 |
std_dev = avg_expense * 0.05
|
| 395 |
months_analyzed = 1
|