fix(demo): Scope budget auto-fill to family entries to prevent FK violations (#3078)

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
This commit is contained in:
sentry[bot]
2026-08-19 22:30:12 +02:00
committed by GitHub
parent e5750a6c09
commit 3c299a76f0
+1 -1
View File
@@ -363,7 +363,7 @@ class Demo::Generator
# Fetch expense transactions in the analysis period (positive amounts = expenses)
txns = Entry.joins("INNER JOIN transactions ON transactions.id = entries.entryable_id")
.joins("INNER JOIN categories ON categories.id = transactions.category_id")
.where(entries: { entryable_type: "Transaction", date: analysis_period })
.where(entries: { entryable_type: "Transaction", date: analysis_period, account_id: family.accounts.select(:id) })
.where("entries.amount > 0")
spend_per_cat = txns.group("categories.id").sum("entries.amount")