Budget query needs to look for credit for CCs

This commit is contained in:
2026-04-21 10:25:49 -04:00
parent e6f5d5a33b
commit 2a63b9120e
2 changed files with 8 additions and 2 deletions

View File

@@ -31,7 +31,10 @@ export default async function BudgetsPage({ searchParams }: { searchParams: Sear
JOIN "Account" a ON t."accountId" = a.id JOIN "Account" a ON t."accountId" = a.id
WHERE a."userId" = ${userId} WHERE a."userId" = ${userId}
AND t."budgetId" IS NOT NULL AND t."budgetId" IS NOT NULL
AND t.type = 'DEBIT' AND (
(a.type = 'CREDIT_CARD' AND t.type = 'CREDIT')
OR (a.type != 'CREDIT_CARD' AND t.type = 'DEBIT')
)
AND t.date >= ${start} AND t.date >= ${start}
AND t.date <= ${end} AND t.date <= ${end}
GROUP BY t."budgetId" GROUP BY t."budgetId"

View File

@@ -46,7 +46,10 @@ export default async function DashboardPage({ searchParams }: { searchParams: Se
JOIN "Account" a ON t."accountId" = a.id JOIN "Account" a ON t."accountId" = a.id
WHERE a."userId" = ${userId} WHERE a."userId" = ${userId}
AND t."budgetId" IS NOT NULL AND t."budgetId" IS NOT NULL
AND t.type = 'DEBIT' AND (
(a.type = 'CREDIT_CARD' AND t.type = 'CREDIT')
OR (a.type != 'CREDIT_CARD' AND t.type = 'DEBIT')
)
AND t.date >= ${start} AND t.date >= ${start}
AND t.date <= ${end} AND t.date <= ${end}
GROUP BY t."budgetId" GROUP BY t."budgetId"