From c5df0cde60419ac023283615845541aa24a1db25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qu=E1=BB=91c=20Kh=C3=A1nh?= Date: Tue, 23 Jul 2024 13:46:26 +0700 Subject: [PATCH] fix(api): fix budget list not return correct type (#158) --- apps/api/v1/services/budget.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/v1/services/budget.service.ts b/apps/api/v1/services/budget.service.ts index 01b7fc19..72863b9c 100644 --- a/apps/api/v1/services/budget.service.ts +++ b/apps/api/v1/services/budget.service.ts @@ -5,6 +5,7 @@ import { import type { CreateBudget, UpdateBudget } from '@6pm/validation' import { type Budget, + type BudgetPeriodConfig, BudgetUserPermission, type Prisma, type User, @@ -16,6 +17,10 @@ const BUDGET_INCLUDE: Prisma.BudgetInclude = { periodConfigs: true, } +type BudgetPopulated = Budget & { + periodConfigs: BudgetPeriodConfig[] +} + export async function canUserCreateBudget({ // biome-ignore lint/correctness/noUnusedVariables: user, @@ -277,7 +282,7 @@ async function findBudgetLatestPeriodConfig({ }) } -async function verifyBudgetPeriods({ budget }: { budget: Budget }) { +async function verifyBudgetPeriods({ budget }: { budget: BudgetPopulated }) { const latestPeriodConfig = await findBudgetLatestPeriodConfig({ budgetId: budget.id, })