From 08e958286de8858a018fec3af08daafa7e70d639 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Fri, 15 Mar 2024 18:39:32 +0100 Subject: [PATCH] Enable update balance for fee --- apps/api/src/app/order/order.service.ts | 2 +- ...create-or-update-activity-dialog.component.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index 1603ed530..3efb5fe95 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 87cdf57d7..b628aba46 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,7 +385,10 @@ export class CreateOrUpdateActivityDialog implements OnDestroy { this.activityForm.controls['unitPriceInCustomCurrency'].setValue(0); } - if (type === 'INTEREST') { + if ( + ['FEE', 'INTEREST'].includes(type) && + this.activityForm.controls['accountId'].value + ) { this.activityForm.controls['updateAccountBalance'].enable(); } else { this.activityForm.controls['updateAccountBalance'].disable();