Skip to content

Commit 074ef33

Browse files
committed
Clean up balanceService
1 parent ff49f8e commit 074ef33

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

src/server/api/services/balanceService.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
11
import { db } from '~/server/db';
22
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-
}
333

344
/**
355
* Deep comparison of balance arrays
@@ -139,7 +109,7 @@ function assertBalancesMatch(
139109
/**
140110
* Get all balances for a user (friend balances only, no groups)
141111
*/
142-
export async function getUserBalances(userId: number): Promise<BalanceWithFriend[]> {
112+
export async function getUserBalances(userId: number) {
143113
const [oldBalances, viewBalances] = await Promise.all([
144114
db.balance.findMany({
145115
where: { userId },
@@ -302,7 +272,7 @@ export async function getBalancesWithFriend(userId: number, friendId: number) {
302272
/**
303273
* Get all group balances for a specific group
304274
*/
305-
export async function getGroupBalances(groupId: number): Promise<GroupBalanceResult[]> {
275+
export async function getGroupBalances(groupId: number) {
306276
const [oldBalances, viewBalances] = await Promise.all([
307277
db.groupBalance.findMany({
308278
where: { groupId },

0 commit comments

Comments
 (0)