Skip to content

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

Enable account balance update for fee and interest activities (#3145)

rodriguestiago03b895afc9e3a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bcf2ad4f59..eafcc9d2ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- Added support to update the cash balance of an account when adding a fee activity
+- Added support to update the cash balance of an account when adding an interest activity
- Extended the content of the _General_ section by the product roadmap on the Frequently Asked Questions (FAQ) page
### Changed
diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts
index 1603ed5304..3efb5fe95b 100644
--- a/apps/api/src/app/order/order.service.ts
+++ b/apps/api/src/app/order/order.service.ts
@@ -148,7 +148,7 @@ export class OrderService {
.plus(data.fee)
.toNumber();
- if (data.type === 'BUY') {
+ if (['BUY', 'FEE'].includes(data.type)) {
amount = new Big(amount).mul(-1).toNumber();
}
diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
index 34da992fe4..b628aba468 100644
--- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
+++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
@@ -260,6 +260,17 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.activityForm.controls['currency'].setValue(currency);
this.activityForm.controls['currencyOfFee'].setValue(currency);
this.activityForm.controls['currencyOfUnitPrice'].setValue(currency);
+
+ if (['FEE', 'INTEREST'].includes(type)) {
+ if (this.activityForm.controls['accountId'].value) {
+ this.activityForm.controls['updateAccountBalance'].enable();
+ } else {
+ this.activityForm.controls['updateAccountBalance'].disable();
+ this.activityForm.controls['updateAccountBalance'].setValue(
+ false
+ );
+ }
+ }
}
}
);
@@ -374,8 +385,15 @@ export class CreateOrUpdateActivityDialog implements OnDestroy {
this.activityForm.controls['unitPriceInCustomCurrency'].setValue(0);
}
- this.activityForm.controls['updateAccountBalance'].disable();
- this.activityForm.controls['updateAccountBalance'].setValue(false);
+ if (
+ ['FEE', 'INTEREST'].includes(type) &&
+ this.activityForm.controls['accountId'].value
+ ) {
+ this.activityForm.controls['updateAccountBalance'].enable();
+ } else {
+ this.activityForm.controls['updateAccountBalance'].disable();
+ this.activityForm.controls['updateAccountBalance'].setValue(false);
+ }
} else {
this.activityForm.controls['accountId'].setValidators(
Validators.required