Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/account cash balance calculation for SELL activities with fees (#6862)
Chris Ian Fiel29e9336baf5f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex be6630ae14..d7676efeed 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed+- Resolved an issue with the cash balance calculation of an account for `SELL` activities to ensure fees are correctly subtracted- Resolved an exception in the portfolio details endpoint when an asset profile is unmatched## 3.3.0 - 2026-05-14diff --git a/apps/api/src/app/activities/activities.service.ts b/apps/api/src/app/activities/activities.service.tsindex 58b9c11a41..821185e117 100644--- a/apps/api/src/app/activities/activities.service.ts+++ b/apps/api/src/app/activities/activities.service.ts@@ -214,19 +214,18 @@ export class ActivitiesService {});if (updateAccountBalance === true) {- let amount = new Big(data.unitPrice)- .mul(data.quantity)- .plus(data.fee)- .toNumber();+ let amount = new Big(data.unitPrice).mul(data.quantity);if (['BUY', 'FEE'].includes(data.type)) {- amount = new Big(amount).mul(-1).toNumber();+ amount = amount.mul(-1);}+ amount = amount.minus(data.fee);+await this.accountService.updateAccountBalance({accountId,- amount,userId,+ amount: amount.toNumber(),currency: data.SymbolProfile.connectOrCreate.create.currency,date: data.date as Date});