fix: credit balance issues (#21904)
* fix creating user balance * fix org check if teamId is given * adjust hasAvailableCredits function * improve comments * fix creditBalance.create * adjust test --------- Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
1 parent
a37f1d9798
commit
c215dc5864
4 files changed
+22
-3
No files matched your search
@@ -180,8 +180,17 @@ export class CreditsRepository {
|
||||
}
|
||||
|
||||
static async createCreditBalance(data: Prisma.CreditBalanceUncheckedCreateInput, tx?: PrismaTransaction) {
|
||||
const { teamId, userId } = data;
|
||||
|
||||
if (!teamId && !userId) {
|
||||
throw new Error("Team or user ID is required");
|
||||
}
|
||||
|
||||
return (tx ?? prisma).creditBalance.create({
|
||||
data,
|
||||
data: {
|
||||
...data,
|
||||
...(!teamId ? { userId } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user