diff --git a/src/app/api/funds/[slug]/invest/route.ts b/src/app/api/funds/[slug]/invest/route.ts index 7a926b1..d6fe347 100644 --- a/src/app/api/funds/[slug]/invest/route.ts +++ b/src/app/api/funds/[slug]/invest/route.ts @@ -70,7 +70,7 @@ export async function POST(req: NextRequest, { params }: { params: { slug: strin // Deduct from investor (returns updated user with new balance) prisma.user.update({ where: { id: session.user.id }, data: { balance: round2(investor.balance - amount) } }), // Add to fund's cash - prisma.user.update({ where: { id: fund.userId }, data: { balance: { increment: amount } } }), + prisma.user.update({ where: { id: fund.userId }, data: { balance: round2(fund.user.balance + amount) } }), // Upsert FundInvestment record prisma.fundInvestment.upsert({ where: { fundId_userId: { fundId: fund.id, userId: session.user.id } }, diff --git a/src/app/api/funds/[slug]/redeem/route.ts b/src/app/api/funds/[slug]/redeem/route.ts index 87e7a77..bc08d0d 100644 --- a/src/app/api/funds/[slug]/redeem/route.ts +++ b/src/app/api/funds/[slug]/redeem/route.ts @@ -66,7 +66,7 @@ export async function POST(req: NextRequest, { params }: { params: { slug: strin // Return cash to investor prisma.user.update({ where: { id: session.user.id }, data: { balance: round2(investor.balance + payout) } }), // Deduct from fund's cash - prisma.user.update({ where: { id: fund.userId }, data: { balance: { decrement: payout } } }), + prisma.user.update({ where: { id: fund.userId }, data: { balance: round2(fund.user.balance - payout) } }), // Update or delete FundInvestment ...(remainingShares > 0 ? [prisma.fundInvestment.update({