From 432251e108b4957c221adde0d8ddcd7fd941ba71 Mon Sep 17 00:00:00 2001 From: Attila Cseh <77381875+csehatt741@users.noreply.github.com> Date: Fri, 26 Sep 2025 20:11:23 +0200 Subject: [PATCH] Feature/remove deprecated item of activity type from create or update activity dialog (#5555) * Remove deprecated item of activity type * Update changelog --- CHANGELOG.md | 1 + ...ate-or-update-activity-dialog.component.ts | 45 +++++++++---------- .../create-or-update-activity-dialog.html | 4 +- .../types/activity-type.type.ts | 8 ++++ libs/ui/src/lib/i18n.ts | 2 +- 5 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 17f0d57e0..2e5dcfe47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Extended the tags selector component to support form control +- Changed the deprecated `ITEM` activity type to `VALUABLE` in the create or update activity dialog ### Fixed 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 33698acfb..6454b9918 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 @@ -51,6 +51,7 @@ import { catchError, delay, takeUntil } from 'rxjs/operators'; import { DataService } from '../../../../services/data.service'; import { validateObjectForForm } from '../../../../util/form.util'; import { CreateOrUpdateActivityDialogParams } from './interfaces/interfaces'; +import { ActivityType } from './types/activity-type.type'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -178,9 +179,11 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { }; }) ?? []; - Object.keys(Type).forEach((type) => { - this.typesTranslationMap[Type[type]] = translate(Type[type]); - }); + for (const type of Object.keys(ActivityType)) { + this.typesTranslationMap[ActivityType[type]] = translate( + ActivityType[type] + ); + } this.activityForm = this.formBuilder.group({ accountId: [ @@ -242,7 +245,9 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { ) .subscribe(async () => { if ( - ['BUY', 'FEE', 'ITEM'].includes(this.activityForm.get('type').value) + ['BUY', 'FEE', 'VALUABLE'].includes( + this.activityForm.get('type').value + ) ) { this.total = this.activityForm.get('quantity').value * @@ -261,7 +266,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { this.activityForm.get('accountId').valueChanges.subscribe((accountId) => { const type = this.activityForm.get('type').value; - if (['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(type)) { + if (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(type)) { const currency = this.data.accounts.find(({ id }) => { return id === accountId; @@ -357,9 +362,9 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { this.activityForm .get('type') .valueChanges.pipe(takeUntil(this.unsubscribeSubject)) - .subscribe((type: Type) => { + .subscribe((type: ActivityType) => { if ( - type === 'ITEM' || + type === 'VALUABLE' || (this.activityForm.get('dataSource').value === 'MANUAL' && type === 'BUY') ) { @@ -384,7 +389,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { this.activityForm.get('name').setValidators(Validators.required); this.activityForm.get('name').updateValueAndValidity(); - if (type === 'ITEM') { + if (type === 'VALUABLE') { this.activityForm.get('quantity').setValue(1); } @@ -513,11 +518,14 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { currency: this.activityForm.get('currency').value, customCurrency: this.activityForm.get('currencyOfUnitPrice').value, date: this.activityForm.get('date').value, - dataSource: this.activityForm.get('dataSource').value, + dataSource: + this.activityForm.get('type').value === 'VALUABLE' + ? 'MANUAL' + : this.activityForm.get('dataSource').value, fee: this.activityForm.get('fee').value, quantity: this.activityForm.get('quantity').value, symbol: - (['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes( + (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( this.activityForm.get('type').value ) ? undefined @@ -526,7 +534,10 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { tags: this.activityForm.get('tags').value?.map(({ id }) => { return id; }), - type: this.activityForm.get('type').value, + type: + this.activityForm.get('type').value === 'VALUABLE' + ? 'BUY' + : this.activityForm.get('type').value, unitPrice: this.activityForm.get('unitPrice').value }; @@ -543,12 +554,6 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { object: activity }); - if (activity.type === 'ITEM') { - // Transform deprecated type ITEM - activity.dataSource = 'MANUAL'; - activity.type = 'BUY'; - } - this.dialogRef.close(activity); } else { (activity as UpdateOrderDto).id = this.data.activity?.id; @@ -560,12 +565,6 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { object: activity as UpdateOrderDto }); - if (activity.type === 'ITEM') { - // Transform deprecated type ITEM - activity.dataSource = 'MANUAL'; - activity.type = 'BUY'; - } - this.dialogRef.close(activity as UpdateOrderDto); } } catch (error) { diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html index d6c14cfdc..42fbd0ebf 100644 --- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html @@ -65,9 +65,9 @@ >Stocks, ETFs, bonds, cryptocurrencies, commodities - + {{ typesTranslationMap['ITEM'] }}{{ typesTranslationMap['VALUABLE'] }} Luxury items, real estate, private companies