mirror of
https://github.com/we-promise/sure.git
synced 2026-09-09 00:24:15 +00:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user