Fix AI insight prompt passing raw cents instead of dollar amounts
recentExpenses and chart were JSON-stringified with raw amountCents/ expensesCents/paychecksCents values, causing the model to read e.g. 10000 as $10,000 instead of $100. Both arrays are now mapped through centsToDisplay() before inclusion in the prompt, matching the pattern already used for totals and category breakdown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -112,8 +112,8 @@ function buildInsightPrompt(snapshot: Awaited<ReturnType<typeof getDashboardSnap
|
|||||||
? `Pay schedule: biweekly, ${centsToDisplay(snapshot.paySchedule.amountCents)} per paycheck, projected pay dates this month: ${snapshot.paySchedule.projectedDates.join(", ") || "none"}`
|
? `Pay schedule: biweekly, ${centsToDisplay(snapshot.paySchedule.amountCents)} per paycheck, projected pay dates this month: ${snapshot.paySchedule.projectedDates.join(", ") || "none"}`
|
||||||
: null,
|
: null,
|
||||||
`Category breakdown: ${JSON.stringify(categoryBreakdown)}`,
|
`Category breakdown: ${JSON.stringify(categoryBreakdown)}`,
|
||||||
`Recent expenses: ${JSON.stringify(snapshot.recentExpenses)}`,
|
`Recent expenses: ${JSON.stringify(snapshot.recentExpenses.map((e) => ({ title: e.title, amount: centsToDisplay(e.amountCents), date: e.date, category: getCategoryLabel(e.category as CategoryValue) })))}`,
|
||||||
`Daily chart points: ${JSON.stringify(snapshot.chart)}`,
|
`Daily chart points: ${JSON.stringify(snapshot.chart.map((p) => ({ date: p.date, expenses: centsToDisplay(p.expensesCents), paychecks: centsToDisplay(p.paychecksCents) })))}`,
|
||||||
"Do not mention missing data unless it materially affects the advice.",
|
"Do not mention missing data unless it materially affects the advice.",
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|||||||
Reference in New Issue
Block a user