Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Bugfix/race condition in upsert of account balance (#8306)

Thomas Kaul1de6f660c19a
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<AccountBalance> {
+ 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
}
}
});