Browse Source
Bugfix/account cash balance calculation for SELL activities with fees (#6862)
* Fix account cash balance calculation for SELL activities with fees
* Update changelog
pull/1685/merge
Chris Ian Fiel
1 week ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
6 additions and
6 deletions
-
CHANGELOG.md
-
apps/api/src/app/activities/activities.service.ts
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
|
### Fixed |
|
|
### 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 |
|
|
- Resolved an exception in the portfolio details endpoint when an asset profile is unmatched |
|
|
|
|
|
|
|
|
## 3.3.0 - 2026-05-14 |
|
|
## 3.3.0 - 2026-05-14 |
|
|
|
|
|
@ -214,19 +214,18 @@ export class ActivitiesService { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (updateAccountBalance === true) { |
|
|
if (updateAccountBalance === true) { |
|
|
let amount = new Big(data.unitPrice) |
|
|
let amount = new Big(data.unitPrice).mul(data.quantity); |
|
|
.mul(data.quantity) |
|
|
|
|
|
.plus(data.fee) |
|
|
|
|
|
.toNumber(); |
|
|
|
|
|
|
|
|
|
|
|
if (['BUY', 'FEE'].includes(data.type)) { |
|
|
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({ |
|
|
await this.accountService.updateAccountBalance({ |
|
|
accountId, |
|
|
accountId, |
|
|
amount, |
|
|
|
|
|
userId, |
|
|
userId, |
|
|
|
|
|
amount: amount.toNumber(), |
|
|
currency: data.SymbolProfile.connectOrCreate.create.currency, |
|
|
currency: data.SymbolProfile.connectOrCreate.create.currency, |
|
|
date: data.date as Date |
|
|
date: data.date as Date |
|
|
}); |
|
|
}); |
|
|
|