Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/Http/Controllers/AiAnalysisController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function index()
'anomalies' => $snapshot->anomalies,
'budgetUtilization' => $snapshot->budgetUtilization,
'currentMonthComplete' => $snapshot->currentMonthComplete,
'topGrowingCategories' => $snapshot->topGrowingCategories,
'topShrinkingCategories' => $snapshot->topShrinkingCategories,
'monthlyRatios' => $snapshot->monthlyRatios,
'history' => FinancialAnalyst::history(),
]);
}
Expand Down
11 changes: 7 additions & 4 deletions resources/js/Pages/AI/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const props = defineProps({
anomalies: { type: Array, default: () => [] },
budgetUtilization: { type: Array, default: () => [] },
currentMonthComplete: { type: Boolean, default: true },
topGrowingCategories: { type: Array, default: () => [] },
topShrinkingCategories: { type: Array, default: () => [] },
monthlyRatios: { type: Array, default: () => [] },
history: { type: Array, default: () => [] },
});

Expand Down Expand Up @@ -259,9 +262,9 @@ const hasCategoryComments = computed(() => {
return structured.value?.categoryInsights?.some(c => c.comment?.trim());
});

// Monthly comparison: last two complete months
// Monthly comparison: last two complete months (from Inertia props, always available)
const monthlyComparison = computed(() => {
const ratios = snapshot.value?.monthlyRatios?.filter(m => !m.incomplete) ?? [];
const ratios = props.monthlyRatios.filter(m => !m.incomplete);
if (ratios.length < 2) return null;
const current = ratios[ratios.length - 1];
const previous = ratios[ratios.length - 2];
Expand All @@ -274,8 +277,8 @@ const monthlyComparison = computed(() => {
expenses: current.expenses,
prevExpenses: previous.expenses,
expensesChange: +(current.expenses - previous.expenses).toFixed(1),
growing: snapshot.value?.topGrowingCategories ?? [],
shrinking: snapshot.value?.topShrinkingCategories ?? [],
growing: props.topGrowingCategories,
shrinking: props.topShrinkingCategories,
};
});

Expand Down
Loading