|
1 | 1 | import { db } from '~/server/db'; |
2 | 2 | import type { Balance, BalanceView, GroupBalance, User } from '@prisma/client'; |
3 | | -import { group } from 'console'; |
4 | | - |
5 | | -/** |
6 | | - * Balance Service |
7 | | - * |
8 | | - * This service provides methods for querying user balances. |
9 | | - * During the migration phase, it queries both the old Balance/GroupBalance tables |
10 | | - * AND the new BalanceView, asserting they match. |
11 | | - */ |
12 | | - |
13 | | -interface BalanceWithFriend { |
14 | | - userId: number; |
15 | | - currency: string; |
16 | | - friendId: number; |
17 | | - amount: bigint; |
18 | | - createdAt: Date; |
19 | | - updatedAt: Date; |
20 | | - importedFromSplitwise: boolean; |
21 | | - friend: User; |
22 | | - hasMore?: boolean; |
23 | | -} |
24 | | - |
25 | | -interface GroupBalanceResult { |
26 | | - groupId: number; |
27 | | - currency: string; |
28 | | - userId: number; |
29 | | - firendId: number; |
30 | | - amount: bigint; |
31 | | - updatedAt: Date; |
32 | | -} |
33 | 3 |
|
34 | 4 | /** |
35 | 5 | * Deep comparison of balance arrays |
@@ -139,7 +109,7 @@ function assertBalancesMatch( |
139 | 109 | /** |
140 | 110 | * Get all balances for a user (friend balances only, no groups) |
141 | 111 | */ |
142 | | -export async function getUserBalances(userId: number): Promise<BalanceWithFriend[]> { |
| 112 | +export async function getUserBalances(userId: number) { |
143 | 113 | const [oldBalances, viewBalances] = await Promise.all([ |
144 | 114 | db.balance.findMany({ |
145 | 115 | where: { userId }, |
@@ -302,7 +272,7 @@ export async function getBalancesWithFriend(userId: number, friendId: number) { |
302 | 272 | /** |
303 | 273 | * Get all group balances for a specific group |
304 | 274 | */ |
305 | | -export async function getGroupBalances(groupId: number): Promise<GroupBalanceResult[]> { |
| 275 | +export async function getGroupBalances(groupId: number) { |
306 | 276 | const [oldBalances, viewBalances] = await Promise.all([ |
307 | 277 | db.groupBalance.findMany({ |
308 | 278 | where: { groupId }, |
|
0 commit comments