From 1de6f660c19a68c401054418b63ce6cad072a2c5 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 25 Oct 2026 13:10:01 +0100 Subject: [PATCH] Bugfix/race condition in upsert of account balance (#8306) * Fix race condition in upsert of account balance * Update changelog --- CHANGELOG.md | 1 + .../account-balance/account-balance.service.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2ca220f7..91f0ab98de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed a race condition in the creation of an account balance - Fixed the handling of an output of the model which does not agree with the schema in the import of activities with _Ghostfolio AI_ (experimental) ## 3.92.0 - 2026-10-24 diff --git a/apps/api/src/app/account-balance/account-balance.service.ts b/apps/api/src/app/account-balance/account-balance.service.ts index afa4386e01..15358a8486 100644 --- a/apps/api/src/app/account-balance/account-balance.service.ts +++ b/apps/api/src/app/account-balance/account-balance.service.ts @@ -51,17 +51,13 @@ export class AccountBalanceService { }: CreateAccountBalanceDto & { userId: string; }): Promise { + const dateOfBalance = resetHours(parseISO(date)); + const accountBalance = await this.prismaService.accountBalance.upsert({ create: { - account: { - connect: { - id_userId: { - userId, - id: accountId - } - } - }, - date: resetHours(parseISO(date)), + accountId, + userId, + date: dateOfBalance, value: balance }, update: { @@ -71,7 +67,7 @@ export class AccountBalanceService { accountId_userId_date: { accountId, userId, - date: resetHours(parseISO(date)) + date: dateOfBalance } } });